25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Deprecate jlib.erl in favor of aux.erl

Since the main goal of jlib.erl is lost, all auxiliary functions
are now moved to aux.erl, and the whole jlib.erl is now deprecated.
This commit is contained in:
Evgeniy Khramtsov 2017-03-30 14:17:13 +03:00
parent 997ac58329
commit 7bcbea2108
55 changed files with 422 additions and 205 deletions

199
src/aux.erl Normal file
View File

@ -0,0 +1,199 @@
%%%-------------------------------------------------------------------
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
%%% @doc
%%% This is the place for some unsorted auxiliary functions
%%% Some functions from jlib.erl are moved here
%%% Mild rubbish heap is accepted ;)
%%% @end
%%% Created : 30 Mar 2017 by Evgeny Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2017 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%-------------------------------------------------------------------
-module(aux).
%% API
-export([tolower/1, term_to_base64/1, base64_to_term/1,
decode_base64/1, encode_base64/1, ip_to_list/1,
hex_to_bin/1, hex_to_base64/1, expand_keyword/3,
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1]).
%%%===================================================================
%%% API
%%%===================================================================
-spec tolower(binary()) -> binary().
tolower(B) ->
iolist_to_binary(tolower_s(binary_to_list(B))).
tolower_s([C | Cs]) ->
if C >= $A, C =< $Z -> [C + 32 | tolower_s(Cs)];
true -> [C | tolower_s(Cs)]
end;
tolower_s([]) -> [].
-spec term_to_base64(term()) -> binary().
term_to_base64(Term) ->
encode_base64(term_to_binary(Term)).
-spec base64_to_term(binary()) -> {term, term()} | error.
base64_to_term(Base64) ->
case catch binary_to_term(decode_base64(Base64), [safe]) of
{'EXIT', _} ->
error;
Term ->
{term, Term}
end.
-spec decode_base64(binary()) -> binary().
decode_base64(S) ->
case catch binary:last(S) of
C when C == $\n; C == $\s ->
decode_base64(binary:part(S, 0, byte_size(S) - 1));
_ ->
decode_base64_bin(S, <<>>)
end.
take_without_spaces(Bin, Count) ->
take_without_spaces(Bin, Count, <<>>).
take_without_spaces(Bin, 0, Acc) ->
{Acc, Bin};
take_without_spaces(<<>>, _, Acc) ->
{Acc, <<>>};
take_without_spaces(<<$\s, Tail/binary>>, Count, Acc) ->
take_without_spaces(Tail, Count, Acc);
take_without_spaces(<<$\t, Tail/binary>>, Count, Acc) ->
take_without_spaces(Tail, Count, Acc);
take_without_spaces(<<$\n, Tail/binary>>, Count, Acc) ->
take_without_spaces(Tail, Count, Acc);
take_without_spaces(<<$\r, Tail/binary>>, Count, Acc) ->
take_without_spaces(Tail, Count, Acc);
take_without_spaces(<<Char:8, Tail/binary>>, Count, Acc) ->
take_without_spaces(Tail, Count-1, <<Acc/binary, Char:8>>).
decode_base64_bin(<<>>, Acc) ->
Acc;
decode_base64_bin(Bin, Acc) ->
case take_without_spaces(Bin, 4) of
{<<A, B, $=, $=>>, _} ->
<<Acc/binary, (d(A)):6, (d(B) bsr 4):2>>;
{<<A, B, C, $=>>, _} ->
<<Acc/binary, (d(A)):6, (d(B)):6, (d(C) bsr 2):4>>;
{<<A, B, C, D>>, Tail} ->
Acc2 = <<Acc/binary, (d(A)):6, (d(B)):6, (d(C)):6, (d(D)):6>>,
decode_base64_bin(Tail, Acc2);
_ ->
<<"">>
end.
d(X) when X >= $A, X =< $Z -> X - 65;
d(X) when X >= $a, X =< $z -> X - 71;
d(X) when X >= $0, X =< $9 -> X + 4;
d($+) -> 62;
d($/) -> 63;
d(_) -> 63.
%% Convert Erlang inet IP to list
-spec encode_base64(binary()) -> binary().
encode_base64(Data) ->
encode_base64_bin(Data, <<>>).
encode_base64_bin(<<A:6, B:6, C:6, D:6, Tail/binary>>, Acc) ->
encode_base64_bin(Tail, <<Acc/binary, (e(A)):8, (e(B)):8, (e(C)):8, (e(D)):8>>);
encode_base64_bin(<<A:6, B:6, C:4>>, Acc) ->
<<Acc/binary, (e(A)):8, (e(B)):8, (e(C bsl 2)):8, $=>>;
encode_base64_bin(<<A:6, B:2>>, Acc) ->
<<Acc/binary, (e(A)):8, (e(B bsl 4)):8, $=, $=>>;
encode_base64_bin(<<>>, Acc) ->
Acc.
e(X) when X >= 0, X < 26 -> X + 65;
e(X) when X > 25, X < 52 -> X + 71;
e(X) when X > 51, X < 62 -> X - 4;
e(62) -> $+;
e(63) -> $/;
e(X) -> exit({bad_encode_base64_token, X}).
-spec ip_to_list(inet:ip_address() | undefined |
{inet:ip_address(), inet:port_number()}) -> binary().
ip_to_list({IP, _Port}) ->
ip_to_list(IP);
%% This function clause could use inet_parse too:
ip_to_list(undefined) ->
<<"unknown">>;
ip_to_list(IP) ->
list_to_binary(inet_parse:ntoa(IP)).
-spec hex_to_bin(binary()) -> binary().
hex_to_bin(Hex) ->
hex_to_bin(binary_to_list(Hex), []).
-spec hex_to_bin(list(), list()) -> binary().
hex_to_bin([], Acc) ->
list_to_binary(lists:reverse(Acc));
hex_to_bin([H1, H2 | T], Acc) ->
{ok, [V], []} = io_lib:fread("~16u", [H1, H2]),
hex_to_bin(T, [V | Acc]).
-spec hex_to_base64(binary()) -> binary().
hex_to_base64(Hex) ->
encode_base64(hex_to_bin(Hex)).
-spec expand_keyword(binary(), binary(), binary()) -> binary().
expand_keyword(Keyword, Input, Replacement) ->
Parts = binary:split(Input, Keyword, [global]),
str:join(Parts, Replacement).
binary_to_atom(Bin) ->
erlang:binary_to_atom(Bin, utf8).
tuple_to_binary(T) ->
iolist_to_binary(tuple_to_list(T)).
atom_to_binary(A) ->
erlang:atom_to_binary(A, utf8).
expr_to_term(Expr) ->
Str = binary_to_list(<<Expr/binary, ".">>),
{ok, Tokens, _} = erl_scan:string(Str),
{ok, Term} = erl_parse:parse_term(Tokens),
Term.
term_to_expr(Term) ->
list_to_binary(io_lib:print(Term)).
l2i(I) when is_integer(I) -> I;
l2i(L) when is_binary(L) -> binary_to_integer(L).
i2l(I) when is_integer(I) -> integer_to_binary(I);
i2l(L) when is_binary(L) -> L.
i2l(I, N) when is_integer(I) -> i2l(i2l(I), N);
i2l(L, N) when is_binary(L) ->
case str:len(L) of
N -> L;
C when C > N -> L;
_ -> i2l(<<$0, L/binary>>, N)
end.
%%%===================================================================
%%% Internal functions
%%%===================================================================

View File

@ -128,14 +128,14 @@ mech_step(#state{step = 2} = State, ClientIn) ->
str:substr(ClientIn,
str:str(ClientIn, <<"n=">>)),
ServerNonce =
jlib:encode_base64(randoms:bytes(?NONCE_LENGTH)),
aux:encode_base64(randoms:bytes(?NONCE_LENGTH)),
ServerFirstMessage =
iolist_to_binary(
["r=",
ClientNonce,
ServerNonce,
",", "s=",
jlib:encode_base64(Salt),
aux:encode_base64(Salt),
",", "i=",
integer_to_list(IterationCount)]),
{continue, ServerFirstMessage,
@ -161,7 +161,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
ClientProofAttribute] ->
case parse_attribute(GS2ChannelBindingAttribute) of
{$c, CVal} ->
ChannelBindingSupport = binary:at(jlib:decode_base64(CVal), 0),
ChannelBindingSupport = binary:at(aux:decode_base64(CVal), 0),
if (ChannelBindingSupport == $n)
or (ChannelBindingSupport == $y) ->
Nonce = <<(State#state.client_nonce)/binary,
@ -170,7 +170,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
{$r, CompareNonce} when CompareNonce == Nonce ->
case parse_attribute(ClientProofAttribute) of
{$p, ClientProofB64} ->
ClientProof = jlib:decode_base64(ClientProofB64),
ClientProof = aux:decode_base64(ClientProofB64),
AuthMessage = iolist_to_binary(
[State#state.auth_message,
",",
@ -191,7 +191,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
{auth_module, State#state.auth_module},
{authzid, State#state.username}],
<<"v=",
(jlib:encode_base64(ServerSignature))/binary>>};
(aux:encode_base64(ServerSignature))/binary>>};
true -> {error, not_authorized, State#state.username}
end;
_ -> {error, bad_attribute}

View File

@ -510,8 +510,8 @@ auth_modules(Server) ->
Default = ejabberd_config:default_db(LServer, ?MODULE),
Methods = ejabberd_config:get_option(
{auth_method, LServer}, opt_type(auth_method), [Default]),
[jlib:binary_to_atom(<<"ejabberd_auth_",
(jlib:atom_to_binary(M))/binary>>)
[aux:binary_to_atom(<<"ejabberd_auth_",
(aux:atom_to_binary(M))/binary>>)
|| M <- Methods].
export(Server) ->

View File

@ -361,8 +361,8 @@ result_attrs(#state{uids = UIDs,
%%%----------------------------------------------------------------------
parse_options(Host) ->
Cfg = eldap_utils:get_config(Host, []),
Eldap_ID = jlib:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Bind_Eldap_ID = jlib:atom_to_binary(
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Bind_Eldap_ID = aux:atom_to_binary(
gen_mod:get_module_proc(Host, bind_ejabberd_auth_ldap)),
UIDsTemp = gen_mod:get_opt(
{ldap_uids, Host}, [],

View File

@ -129,7 +129,7 @@ check_password(User, AuthzId, Server, Password, Digest,
true -> (Passwd == Password) and (Password /= <<"">>)
end;
[#passwd{password = Scram}] when is_record(Scram, scram) ->
Passwd = jlib:decode_base64(Scram#scram.storedkey),
Passwd = aux:decode_base64(Scram#scram.storedkey),
DigRes = if Digest /= <<"">> ->
Digest == DigestGen(Passwd);
true -> false
@ -294,9 +294,9 @@ get_password(User, Server) ->
Password;
[#passwd{password = Scram}]
when is_record(Scram, scram) ->
{jlib:decode_base64(Scram#scram.storedkey),
jlib:decode_base64(Scram#scram.serverkey),
jlib:decode_base64(Scram#scram.salt),
{aux:decode_base64(Scram#scram.storedkey),
aux:decode_base64(Scram#scram.serverkey),
aux:decode_base64(Scram#scram.salt),
Scram#scram.iterationcount};
_ -> false
end.
@ -480,9 +480,9 @@ password_to_scram(Password, IterationCount) ->
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
ServerKey = scram:server_key(SaltedPassword),
#scram{storedkey = jlib:encode_base64(StoredKey),
serverkey = jlib:encode_base64(ServerKey),
salt = jlib:encode_base64(Salt),
#scram{storedkey = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
iterationcount = IterationCount}.
is_password_scram_valid(Password, Scram) ->
@ -491,12 +491,12 @@ is_password_scram_valid(Password, Scram) ->
false;
_ ->
IterationCount = Scram#scram.iterationcount,
Salt = jlib:decode_base64(Scram#scram.salt),
Salt = aux:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
jlib:decode_base64(Scram#scram.storedkey) == StoredKey
aux:decode_base64(Scram#scram.storedkey) == StoredKey
end.
export(_Server) ->

View File

@ -108,7 +108,7 @@ check_password(User, AuthzId, Server, Password, Digest,
end;
{ok, #passwd{password = Scram}}
when is_record(Scram, scram) ->
Passwd = jlib:decode_base64(Scram#scram.storedkey),
Passwd = aux:decode_base64(Scram#scram.storedkey),
DigRes = if Digest /= <<"">> ->
Digest == DigestGen(Passwd);
true -> false
@ -213,9 +213,9 @@ get_password(User, Server) ->
Password;
{ok, #passwd{password = Scram}}
when is_record(Scram, scram) ->
{jlib:decode_base64(Scram#scram.storedkey),
jlib:decode_base64(Scram#scram.serverkey),
jlib:decode_base64(Scram#scram.salt),
{aux:decode_base64(Scram#scram.storedkey),
aux:decode_base64(Scram#scram.serverkey),
aux:decode_base64(Scram#scram.salt),
Scram#scram.iterationcount};
_ -> false
end.
@ -287,9 +287,9 @@ password_to_scram(Password, IterationCount) ->
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
ServerKey = scram:server_key(SaltedPassword),
#scram{storedkey = jlib:encode_base64(StoredKey),
serverkey = jlib:encode_base64(ServerKey),
salt = jlib:encode_base64(Salt),
#scram{storedkey = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
iterationcount = IterationCount}.
is_password_scram_valid(Password, Scram) ->
@ -298,12 +298,12 @@ is_password_scram_valid(Password, Scram) ->
false;
_ ->
IterationCount = Scram#scram.iterationcount,
Salt = jlib:decode_base64(Scram#scram.salt),
Salt = aux:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
jlib:decode_base64(Scram#scram.storedkey) == StoredKey
aux:decode_base64(Scram#scram.storedkey) == StoredKey
end.
export(_Server) ->

View File

@ -301,9 +301,9 @@ get_password(User, Server) ->
LServer, LUser) of
{selected,
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
{jlib:decode_base64(StoredKey),
jlib:decode_base64(ServerKey),
jlib:decode_base64(Salt),
{aux:decode_base64(StoredKey),
aux:decode_base64(ServerKey),
aux:decode_base64(Salt),
IterationCount};
_ -> false
end;
@ -423,9 +423,9 @@ password_to_scram(Password, IterationCount) ->
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
ServerKey = scram:server_key(SaltedPassword),
#scram{storedkey = jlib:encode_base64(StoredKey),
serverkey = jlib:encode_base64(ServerKey),
salt = jlib:encode_base64(Salt),
#scram{storedkey = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
iterationcount = IterationCount}.
is_password_scram_valid_stored(Pass, {scram,Pass,<<>>,<<>>,0}, LUser, LServer) ->
@ -443,12 +443,12 @@ is_password_scram_valid(Password, Scram) ->
false;
_ ->
IterationCount = Scram#scram.iterationcount,
Salt = jlib:decode_base64(Scram#scram.salt),
Salt = aux:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
jlib:decode_base64(Scram#scram.storedkey) == StoredKey
aux:decode_base64(Scram#scram.storedkey) == StoredKey
end.
-define(BATCH_SIZE, 1000).

View File

@ -438,7 +438,7 @@ handle_auth_success(User, Mech, AuthModule,
?INFO_MSG("(~s) Accepted c2s ~s authentication for ~s@~s by ~s backend from ~s",
[SockMod:pp(Socket), Mech, User, LServer,
ejabberd_auth:backend_type(AuthModule),
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
State1 = State#{auth_module => AuthModule},
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State1, [true, User]).
@ -450,7 +450,7 @@ handle_auth_failure(User, Mech, Reason,
if User /= <<"">> -> ["for ", User, "@", LServer, " "];
true -> ""
end,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)), Reason]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP)), Reason]),
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State, [false, User]).
handle_unbinded_packet(Pkt, #{lserver := LServer} = State) ->

View File

@ -73,7 +73,7 @@ start() ->
nocookie ->
str:sha(randoms:get_string());
Cookie ->
str:sha(jlib:atom_to_binary(Cookie))
str:sha(aux:atom_to_binary(Cookie))
end,
State2 = set_option({node_start, global}, UnixTime, State1),
State3 = set_option({shared_key, global}, SharedKey, State2),

View File

@ -258,7 +258,7 @@ process_header(State, Data) ->
request_version = Version, request_path = Path,
request_keepalive = KeepAlive};
{ok, {http_header, _, 'Connection' = Name, _, Conn}} ->
KeepAlive1 = case jlib:tolower(Conn) of
KeepAlive1 = case aux:tolower(Conn) of
<<"keep-alive">> -> true;
<<"close">> -> false;
_ -> State#state.request_keepalive
@ -520,7 +520,7 @@ make_bad_request(State) ->
analyze_ip_xff(IP, [], _Host) -> IP;
analyze_ip_xff({IPLast, Port}, XFF, Host) ->
[ClientIP | ProxiesIPs] = str:tokens(XFF, <<", ">>) ++
[jlib:ip_to_list(IPLast)],
[aux:ip_to_list(IPLast)],
TrustedProxies = ejabberd_config:get_option(
{trusted_proxies, Host},
fun(all) -> all;
@ -735,7 +735,7 @@ rest_dir(N, Path, <<_H, T/binary>>) -> rest_dir(N, Path, T).
expand_custom_headers(Headers) ->
lists:map(fun({K, V}) ->
{K, jlib:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
{K, aux:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
end, Headers).
%% hex_to_integer
@ -801,7 +801,7 @@ code_to_phrase(505) -> <<"HTTP Version Not Supported">>.
-spec parse_auth(binary()) -> {binary(), binary()} | {oauth, binary(), []} | undefined.
parse_auth(<<"Basic ", Auth64/binary>>) ->
Auth = jlib:decode_base64(Auth64),
Auth = aux:decode_base64(Auth64),
%% Auth should be a string with the format: user@server:password
%% Note that password can contain additional characters '@' and ':'
case str:chr(Auth, $:) of

View File

@ -283,7 +283,7 @@ cancel_timer(Timer) ->
receive {timeout, Timer, _} -> ok after 0 -> ok end.
get_human_html_xmlel() ->
Heading = <<"ejabberd ", (jlib:atom_to_binary(?MODULE))/binary>>,
Heading = <<"ejabberd ", (aux:atom_to_binary(?MODULE))/binary>>,
#xmlel{name = <<"html">>,
attrs =
[{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}],

View File

@ -206,10 +206,10 @@ parse_listener_portip(PortIP, Opts) ->
case add_proto(PortIP, Opts) of
{P, Prot} ->
T = get_ip_tuple(IPOpt, IPVOpt),
S = jlib:ip_to_list(T),
S = aux:ip_to_list(T),
{P, T, S, Prot};
{P, T, Prot} when is_integer(P) and is_tuple(T) ->
S = jlib:ip_to_list(T),
S = aux:ip_to_list(T),
{P, T, S, Prot};
{P, S, Prot} when is_integer(P) and is_binary(S) ->
[S | _] = str:tokens(S, <<"/">>),

View File

@ -84,7 +84,7 @@ is_connected() ->
%% @private
get_proc(I) ->
jlib:binary_to_atom(
aux:binary_to_atom(
iolist_to_binary(
[atom_to_list(?MODULE), $_, integer_to_list(I)])).

View File

@ -146,7 +146,7 @@ find_routes() ->
enc_local_hint(undefined) ->
<<"">>;
enc_local_hint(LocalHint) ->
jlib:term_to_expr(LocalHint).
aux:term_to_expr(LocalHint).
dec_local_hint(<<"">>) ->
undefined;

View File

@ -669,7 +669,7 @@ transform_options({{s2s_host, Host}, Action}, Opts) ->
?WARNING_MSG("Option 's2s_host' is deprecated. "
"The option is still supported but it is better to "
"fix your config: use access rules instead.", []),
ACLName = jlib:binary_to_atom(
ACLName = aux:binary_to_atom(
iolist_to_binary(["s2s_access_", Host])),
[{acl, ACLName, {server, Host}},
{access, s2s, [{Action, ACLName}]},

View File

@ -182,7 +182,7 @@ handle_auth_success(RServer, Mech, _AuthModule,
lserver := LServer} = State) ->
?INFO_MSG("(~s) Accepted inbound s2s ~s authentication ~s -> ~s (~s)",
[SockMod:pp(Socket), Mech, RServer, LServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
State1 = case ejabberd_s2s:allow_host(ServerHost, RServer) of
true ->
AuthDomains1 = sets:add_element(RServer, AuthDomains),
@ -200,7 +200,7 @@ handle_auth_failure(RServer, Mech, Reason,
lserver := LServer} = State) ->
?INFO_MSG("(~s) Failed inbound s2s ~s authentication ~s -> ~s (~s): ~s",
[SockMod:pp(Socket), Mech, RServer, LServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)), Reason]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP)), Reason]),
ejabberd_hooks:run_fold(s2s_in_auth_result,
ServerHost, State, [false, RServer]).

View File

@ -230,7 +230,7 @@ handle_auth_success(Mech, #{sockmod := SockMod,
server := LServer} = State) ->
?INFO_MSG("(~s) Accepted outbound s2s ~s authentication ~s -> ~s (~s)",
[SockMod:pp(Socket), Mech, LServer, RServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [true]).
handle_auth_failure(Mech, Reason,
@ -241,7 +241,7 @@ handle_auth_failure(Mech, Reason,
server := LServer} = State) ->
?INFO_MSG("(~s) Failed outbound s2s ~s authentication ~s -> ~s (~s): ~s",
[SockMod:pp(Socket), Mech, LServer, RServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)),
ejabberd_config:may_hide_data(aux:ip_to_list(IP)),
xmpp_stream_out:format_error(Reason)]),
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [{false, Reason}]).

View File

@ -153,7 +153,7 @@ get_password_fun(#{remote_server := RemoteServer,
?INFO_MSG("(~s) Domain ~s is unconfigured for "
"external component from ~s",
[SockMod:pp(Socket), RemoteServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
{false, undefined}
end
end.
@ -165,7 +165,7 @@ handle_auth_success(_, Mech, _,
?INFO_MSG("(~s) Accepted external component ~s authentication "
"for ~s from ~s",
[SockMod:pp(Socket), Mech, RemoteServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
lists:foreach(
fun (H) ->
ejabberd_router:register_route(H, ?MYNAME),
@ -180,7 +180,7 @@ handle_auth_failure(_, Mech, Reason,
?INFO_MSG("(~s) Failed external component ~s authentication "
"for ~s from ~s: ~s",
[SockMod:pp(Socket), Mech, RemoteServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)),
ejabberd_config:may_hide_data(aux:ip_to_list(IP)),
Reason]),
State.

View File

@ -65,7 +65,7 @@ init() ->
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
priority = Priority, info = Info}) ->
InfoS = jlib:term_to_expr(Info),
InfoS = aux:term_to_expr(Info),
PrioS = enc_priority(Priority),
TS = now_to_timestamp(Now),
PidS = enc_pid(Pid),

View File

@ -630,7 +630,7 @@ generic_sql_query_format(SQLQuery) ->
generic_escape() ->
#sql_escape{string = fun(X) -> <<"'", (escape(X))/binary, "'">> end,
integer = fun(X) -> jlib:i2l(X) end,
integer = fun(X) -> aux:i2l(X) end,
boolean = fun(true) -> <<"1">>;
(false) -> <<"0">>
end
@ -647,7 +647,7 @@ sqlite_sql_query_format(SQLQuery) ->
sqlite_escape() ->
#sql_escape{string = fun(X) -> <<"'", (standard_escape(X))/binary, "'">> end,
integer = fun(X) -> jlib:i2l(X) end,
integer = fun(X) -> aux:i2l(X) end,
boolean = fun(true) -> <<"1">>;
(false) -> <<"0">>
end
@ -671,7 +671,7 @@ pgsql_prepare(SQLQuery, State) ->
pgsql_execute_escape() ->
#sql_escape{string = fun(X) -> X end,
integer = fun(X) -> [jlib:i2l(X)] end,
integer = fun(X) -> [aux:i2l(X)] end,
boolean = fun(true) -> "1";
(false) -> "0"
end

View File

@ -296,14 +296,14 @@ process_command1(From, To, Body) ->
process_command2(str:tokens(Body, <<" ">>), From, To).
process_command2([<<"kill">>, SNode, SPid], From, To) ->
Node = jlib:binary_to_atom(SNode),
Node = aux:binary_to_atom(SNode),
remote_command(Node, [kill, SPid], From, To);
process_command2([<<"showlh">>, SNode], From, To) ->
Node = jlib:binary_to_atom(SNode),
Node = aux:binary_to_atom(SNode),
remote_command(Node, [showlh], From, To);
process_command2([<<"setlh">>, SNode, NewValueString],
From, To) ->
Node = jlib:binary_to_atom(SNode),
Node = aux:binary_to_atom(SNode),
NewValue = binary_to_integer(NewValueString),
remote_command(Node, [setlh, NewValue], From, To);
process_command2([<<"help">>], From, To) ->

File diff suppressed because one or more lines are too long

View File

@ -152,7 +152,7 @@ handshake(#ws{headers = Headers} = State) ->
V ->
[<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>]
end,
Hash = jlib:encode_base64(
Hash = aux:encode_base64(
crypto:hash(sha, <<Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11">>)),
{State, [<<"HTTP/1.1 101 Switching Protocols\r\n">>,
<<"Upgrade: websocket\r\n">>,

View File

@ -145,7 +145,7 @@
%%% API
%%%----------------------------------------------------------------------
start_link(Name) ->
Reg_name = jlib:binary_to_atom(<<"eldap_",
Reg_name = aux:binary_to_atom(<<"eldap_",
Name/binary>>),
gen_fsm:start_link({local, Reg_name}, ?MODULE, [], []).
@ -153,7 +153,7 @@ start_link(Name) ->
binary(), tlsopts()) -> any().
start_link(Name, Hosts, Port, Rootdn, Passwd, Opts) ->
Reg_name = jlib:binary_to_atom(<<"eldap_",
Reg_name = aux:binary_to_atom(<<"eldap_",
Name/binary>>),
gen_fsm:start_link({local, Reg_name}, ?MODULE,
[Hosts, Port, Rootdn, Passwd, Opts], []).
@ -548,7 +548,7 @@ extensibleMatch_opts([], MRA) -> MRA.
get_handle(Pid) when is_pid(Pid) -> Pid;
get_handle(Atom) when is_atom(Atom) -> Atom;
get_handle(Name) when is_binary(Name) ->
jlib:binary_to_atom(<<"eldap_",
aux:binary_to_atom(<<"eldap_",
Name/binary>>).
%%%----------------------------------------------------------------------

View File

@ -83,4 +83,4 @@ do_request(Name, {F, Args}) ->
end.
make_id(Name) ->
jlib:binary_to_atom(<<"eldap_pool_", Name/binary>>).
aux:binary_to_atom(<<"eldap_pool_", Name/binary>>).

View File

@ -160,9 +160,9 @@ available() ->
lists:keystore(Key, 1, Acc, {Key, Val})
end, Jungle, Standalone)).
available(Module) when is_atom(Module) ->
available(jlib:atom_to_binary(Module));
available(aux:atom_to_binary(Module));
available(Package) when is_binary(Package) ->
Available = [jlib:atom_to_binary(K) || K<-proplists:get_keys(available())],
Available = [aux:atom_to_binary(K) || K<-proplists:get_keys(available())],
lists:member(Package, Available).
available_command() ->
@ -171,18 +171,18 @@ available_command() ->
installed() ->
modules_spec(modules_dir(), "*").
installed(Module) when is_atom(Module) ->
installed(jlib:atom_to_binary(Module));
installed(aux:atom_to_binary(Module));
installed(Package) when is_binary(Package) ->
Installed = [jlib:atom_to_binary(K) || K<-proplists:get_keys(installed())],
Installed = [aux:atom_to_binary(K) || K<-proplists:get_keys(installed())],
lists:member(Package, Installed).
installed_command() ->
[short_spec(Item) || Item <- installed()].
install(Module) when is_atom(Module) ->
install(jlib:atom_to_binary(Module));
install(aux:atom_to_binary(Module));
install(Package) when is_binary(Package) ->
Spec = [S || {Mod, S} <- available(), jlib:atom_to_binary(Mod)==Package],
Spec = [S || {Mod, S} <- available(), aux:atom_to_binary(Mod)==Package],
case {Spec, installed(Package), is_contrib_allowed()} of
{_, _, false} ->
{error, not_allowed};
@ -191,7 +191,7 @@ install(Package) when is_binary(Package) ->
{_, true, _} ->
{error, conflict};
{[Attrs], _, _} ->
Module = jlib:binary_to_atom(Package),
Module = aux:binary_to_atom(Package),
case compile_and_install(Module, Attrs) of
ok ->
code:add_patha(module_ebin_dir(Module)),
@ -207,11 +207,11 @@ install(Package) when is_binary(Package) ->
end.
uninstall(Module) when is_atom(Module) ->
uninstall(jlib:atom_to_binary(Module));
uninstall(aux:atom_to_binary(Module));
uninstall(Package) when is_binary(Package) ->
case installed(Package) of
true ->
Module = jlib:binary_to_atom(Package),
Module = aux:binary_to_atom(Package),
case erlang:function_exported(Module, pre_uninstall, 0) of
true -> Module:pre_uninstall();
_ -> ok
@ -230,7 +230,7 @@ uninstall(Package) when is_binary(Package) ->
upgrade() ->
[{Package, upgrade(Package)} || {Package, _Spec} <- installed()].
upgrade(Module) when is_atom(Module) ->
upgrade(jlib:atom_to_binary(Module));
upgrade(aux:atom_to_binary(Module));
upgrade(Package) when is_binary(Package) ->
uninstall(Package),
install(Package).
@ -240,7 +240,7 @@ add_sources(Path) when is_list(Path) ->
add_sources(_, "") ->
{error, no_url};
add_sources(Module, Path) when is_atom(Module), is_list(Path) ->
add_sources(jlib:atom_to_binary(Module), Path);
add_sources(aux:atom_to_binary(Module), Path);
add_sources(Package, Path) when is_binary(Package), is_list(Path) ->
DestDir = sources_dir(),
RepDir = filename:join(DestDir, module_name(Path)),
@ -261,18 +261,18 @@ add_sources(Package, Path) when is_binary(Package), is_list(Path) ->
end.
del_sources(Module) when is_atom(Module) ->
del_sources(jlib:atom_to_binary(Module));
del_sources(aux:atom_to_binary(Module));
del_sources(Package) when is_binary(Package) ->
case uninstall(Package) of
ok ->
SrcDir = module_src_dir(jlib:binary_to_atom(Package)),
SrcDir = module_src_dir(aux:binary_to_atom(Package)),
delete_path(SrcDir);
Error ->
Error
end.
check(Module) when is_atom(Module) ->
check(jlib:atom_to_binary(Module));
check(aux:atom_to_binary(Module));
check(Package) when is_binary(Package) ->
case {available(Package), installed(Package)} of
{false, _} ->
@ -281,11 +281,11 @@ check(Package) when is_binary(Package) ->
Status = install(Package),
uninstall(Package),
case Status of
ok -> check_sources(jlib:binary_to_atom(Package));
ok -> check_sources(aux:binary_to_atom(Package));
Error -> Error
end;
_ ->
check_sources(jlib:binary_to_atom(Package))
check_sources(aux:binary_to_atom(Package))
end.
%% -- archives and variables functions
@ -420,7 +420,7 @@ module_name(Id) ->
filename:basename(filename:rootname(Id)).
module(Id) ->
jlib:binary_to_atom(iolist_to_binary(module_name(Id))).
aux:binary_to_atom(iolist_to_binary(module_name(Id))).
module_spec(Spec) ->
[{path, filename:dirname(Spec)}

View File

@ -35,6 +35,7 @@
binary_to_integer/1,
integer_to_binary/1]}).
%% The following functions are deprected: use functions from aux.erl
-export([tolower/1, term_to_base64/1, base64_to_term/1,
decode_base64/1, encode_base64/1, ip_to_list/1,
hex_to_bin/1, hex_to_base64/1, expand_keyword/3,
@ -111,7 +112,24 @@
{binary_to_integer, 1},
{binary_to_integer, 2},
{integer_to_binary, 1},
{integer_to_binary, 2}]).
{integer_to_binary, 2},
{tolower, 1},
{term_to_base64, 1},
{base64_to_term, 1},
{decode_base64, 1},
{encode_base64, 1},
{ip_to_list, 1},
{hex_to_bin, 1},
{hex_to_base64, 1},
{expand_keyword, 3},
{atom_to_binary, 1},
{binary_to_atom, 1},
{tuple_to_binary, 1},
{l2i, 1},
{i2l, 1},
{i2l, 2},
{expr_to_term, 1},
{term_to_expr, 1}]).
-include("ejabberd.hrl").
-include("jlib.hrl").

View File

@ -673,7 +673,7 @@ get_cookie() ->
atom_to_list(erlang:get_cookie()).
restart_module(Host, Module) when is_binary(Module) ->
restart_module(Host, jlib:binary_to_atom(Module));
restart_module(Host, aux:binary_to_atom(Module));
restart_module(Host, Module) when is_atom(Module) ->
List = gen_mod:loaded_modules_with_opts(Host),
case proplists:get_value(Module, List) of
@ -1031,8 +1031,8 @@ set_presence(User, Host, Resource, Type, Show, Status, Priority0) ->
From = jid:make(User, Host, Resource),
To = jid:make(User, Host),
Presence = #presence{from = From, to = To,
type = jlib:binary_to_atom(Type),
show = jlib:binary_to_atom(Show),
type = aux:binary_to_atom(Type),
show = aux:binary_to_atom(Show),
status = xmpp:mk_text(Status),
priority = Priority},
Pid ! {route, Presence},
@ -1317,7 +1317,7 @@ build_roster_item(U, S, {add, Nick, Subs, Group}) ->
Groups = binary:split(Group,<<";">>, [global]),
#roster_item{jid = jid:make(U, S),
name = Nick,
subscription = jlib:binary_to_atom(Subs),
subscription = aux:binary_to_atom(Subs),
groups = Groups};
build_roster_item(U, S, remove) ->
#roster_item{jid = jid:make(U, S), subscription = remove}.
@ -1410,7 +1410,7 @@ srg_get_info(Group, Host) ->
Os when is_list(Os) -> Os;
error -> []
end,
[{jlib:atom_to_binary(Title), btl(Value)} || {Title, Value} <- Opts].
[{aux:atom_to_binary(Title), btl(Value)} || {Title, Value} <- Opts].
btl([]) -> [];
btl([B|L]) -> [btl(B)|btl(L)];
@ -1443,7 +1443,7 @@ send_message(Type, From, To, Subject, Body) ->
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
build_packet(Type, Subject, Body) ->
#message{type = jlib:binary_to_atom(Type),
#message{type = aux:binary_to_atom(Type),
body = xmpp:mk_text(Body),
subject = xmpp:mk_text(Subject)}.

View File

@ -420,7 +420,7 @@ make_my_disco_hash(Host) ->
make_disco_hash(DiscoInfo, Algo) ->
Concat = list_to_binary([concat_identities(DiscoInfo),
concat_features(DiscoInfo), concat_info(DiscoInfo)]),
jlib:encode_base64(case Algo of
aux:encode_base64(case Algo of
md5 -> erlang:md5(Concat);
sha -> crypto:hash(sha, Concat);
sha224 -> crypto:hash(sha224, Concat);

View File

@ -919,7 +919,7 @@ get_form(Host,
ENode/binary>>,
Instr = ?T(Lang, <<"Choose modules to stop">>),
Fs = lists:map(fun(M) ->
S = jlib:atom_to_binary(M),
S = aux:atom_to_binary(M),
?XFIELD(boolean, S, S, <<"0">>)
end, SModules),
{result, #xdata{title = Title,
@ -1224,7 +1224,7 @@ set_form(_From, _Host,
Node ->
lists:foreach(
fun(#xdata_field{var = SVar, values = SVals}) ->
Table = jlib:binary_to_atom(SVar),
Table = aux:binary_to_atom(SVar),
Type = case SVals of
[<<"unknown">>] -> unknown;
[<<"ram_copies">>] -> ram_copies;
@ -1258,7 +1258,7 @@ set_form(_From, Host,
fun(#xdata_field{var = Var, values = Vals}) ->
case Vals of
[<<"1">>] ->
Module = jlib:binary_to_atom(Var),
Module = aux:binary_to_atom(Var),
ejabberd_cluster:call(Node, gen_mod, stop_module,
[Host, Module]);
_ -> ok
@ -1657,7 +1657,7 @@ set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
Server),
IPs1 = [ejabberd_sm:get_user_ip(User, Server, Resource)
|| Resource <- Resources],
IPs = [<<(jlib:ip_to_list(IP))/binary, ":",
IPs = [<<(aux:ip_to_list(IP))/binary, ":",
(integer_to_binary(Port))/binary>>
|| {IP, Port} <- IPs1],
Items = ejabberd_hooks:run_fold(roster_get, Server, [],
@ -1719,7 +1719,7 @@ stop_node(From, Host, ENode, Action, XData) ->
mod_announce:announce_commands(empty, From, To, Request)
end,
Time = timer:seconds(Delay),
Node = jlib:binary_to_atom(ENode),
Node = aux:binary_to_atom(ENode),
{ok, _} = timer:apply_after(Time, rpc, call, [Node, init, Action, []]),
{result, undefined}.

View File

@ -166,7 +166,7 @@ code_change(_OldVsn, State, _Extra) ->
-spec log_and_disconnect(ejabberd_c2s:state(), pos_integer(), non_neg_integer())
-> {stop, ejabberd_c2s:state()}.
log_and_disconnect(#{ip := {Addr, _}, lang := Lang} = State, Attempts, UnbanTS) ->
IP = jlib:ip_to_list(Addr),
IP = aux:ip_to_list(Addr),
UnbanDate = format_date(
calendar:now_to_universal_time(seconds_to_now(UnbanTS))),
Format = <<"Too many (~p) failed authentications "

View File

@ -272,7 +272,7 @@ get_api_version([]) ->
handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
case ejabberd_commands:get_command_format(Call, Auth, Version) of
{ArgsSpec, _} when is_list(ArgsSpec) ->
Args2 = [{jlib:binary_to_atom(Key), Value} || {Key, Value} <- Args],
Args2 = [{aux:binary_to_atom(Key), Value} || {Key, Value} <- Args],
Spec = lists:foldr(
fun ({Key, binary}, Acc) ->
[{Key, <<>>}|Acc];
@ -290,13 +290,13 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
catch throw:not_found ->
{404, <<"not_found">>};
throw:{not_found, Why} when is_atom(Why) ->
{404, jlib:atom_to_binary(Why)};
{404, aux:atom_to_binary(Why)};
throw:{not_found, Msg} ->
{404, iolist_to_binary(Msg)};
throw:not_allowed ->
{401, <<"not_allowed">>};
throw:{not_allowed, Why} when is_atom(Why) ->
{401, jlib:atom_to_binary(Why)};
{401, aux:atom_to_binary(Why)};
throw:{not_allowed, Msg} ->
{401, iolist_to_binary(Msg)};
throw:{error, account_unprivileged} ->
@ -306,11 +306,11 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
throw:{invalid_parameter, Msg} ->
{400, iolist_to_binary(Msg)};
throw:{error, Why} when is_atom(Why) ->
{400, jlib:atom_to_binary(Why)};
{400, aux:atom_to_binary(Why)};
throw:{error, Msg} ->
{400, iolist_to_binary(Msg)};
throw:Error when is_atom(Error) ->
{400, jlib:atom_to_binary(Error)};
{400, aux:atom_to_binary(Error)};
throw:Msg when is_list(Msg); is_binary(Msg) ->
{400, iolist_to_binary(Msg)};
_Error ->
@ -456,45 +456,45 @@ format_command_result(Cmd, Auth, Result, Version) ->
end.
format_result(Atom, {Name, atom}) ->
{jlib:atom_to_binary(Name), jlib:atom_to_binary(Atom)};
{aux:atom_to_binary(Name), aux:atom_to_binary(Atom)};
format_result(Int, {Name, integer}) ->
{jlib:atom_to_binary(Name), Int};
{aux:atom_to_binary(Name), Int};
format_result([String | _] = StringList, {Name, string}) when is_list(String) ->
Binarized = iolist_to_binary(string:join(StringList, "\n")),
{jlib:atom_to_binary(Name), Binarized};
{aux:atom_to_binary(Name), Binarized};
format_result(String, {Name, string}) ->
{jlib:atom_to_binary(Name), iolist_to_binary(String)};
{aux:atom_to_binary(Name), iolist_to_binary(String)};
format_result(Code, {Name, rescode}) ->
{jlib:atom_to_binary(Name), Code == true orelse Code == ok};
{aux:atom_to_binary(Name), Code == true orelse Code == ok};
format_result({Code, Text}, {Name, restuple}) ->
{jlib:atom_to_binary(Name),
{aux:atom_to_binary(Name),
{[{<<"res">>, Code == true orelse Code == ok},
{<<"text">>, iolist_to_binary(Text)}]}};
format_result(Code, {Name, restuple}) ->
{jlib:atom_to_binary(Name),
{aux:atom_to_binary(Name),
{[{<<"res">>, Code == true orelse Code == ok},
{<<"text">>, <<"">>}]}};
format_result(Els, {Name, {list, {_, {tuple, [{_, atom}, _]}} = Fmt}}) ->
{jlib:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
{aux:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
format_result(Els, {Name, {list, Def}}) ->
{jlib:atom_to_binary(Name), [element(2, format_result(El, Def)) || El <- Els]};
{aux:atom_to_binary(Name), [element(2, format_result(El, Def)) || El <- Els]};
format_result(Tuple, {_Name, {tuple, [{_, atom}, ValFmt]}}) ->
{Name2, Val} = Tuple,
{_, Val2} = format_result(Val, ValFmt),
{jlib:atom_to_binary(Name2), Val2};
{aux:atom_to_binary(Name2), Val2};
format_result(Tuple, {Name, {tuple, Def}}) ->
Els = lists:zip(tuple_to_list(Tuple), Def),
{jlib:atom_to_binary(Name), {[format_result(El, ElDef) || {El, ElDef} <- Els]}};
{aux:atom_to_binary(Name), {[format_result(El, ElDef) || {El, ElDef} <- Els]}};
format_result(404, {_Name, _}) ->
"not_found".
@ -537,7 +537,7 @@ json_error(HTTPCode, JSONCode, Message) ->
}.
log(Call, Args, {Addr, Port}) ->
AddrS = jlib:ip_to_list({Addr, Port}),
AddrS = aux:ip_to_list({Addr, Port}),
?INFO_MSG("API call ~s ~p from ~s:~p", [Call, Args, AddrS, Port]);
log(Call, Args, IP) ->
?INFO_MSG("API call ~s ~p (~p)", [Call, Args, IP]).

View File

@ -32,7 +32,7 @@
-define(SLOT_TIMEOUT, 18000000). % 5 hours.
-define(FORMAT(Error), file:format_error(Error)).
-define(URL_ENC(URL), binary_to_list(ejabberd_http:url_encode(URL))).
-define(ADDR_TO_STR(IP), ejabberd_config:may_hide_data(jlib:ip_to_list(IP))).
-define(ADDR_TO_STR(IP), ejabberd_config:may_hide_data(aux:ip_to_list(IP))).
-define(STR_TO_INT(Str, B), binary_to_integer(iolist_to_binary(Str), B)).
-define(DEFAULT_CONTENT_TYPE, <<"application/octet-stream">>).
-define(CONTENT_TYPES,
@ -502,12 +502,12 @@ get_proc_name(ServerHost, ModuleName) ->
expand_home(Input) ->
{ok, [[Home]]} = init:get_argument(home),
jlib:expand_keyword(<<"@HOME@">>, Input, Home).
aux:expand_keyword(<<"@HOME@">>, Input, Home).
-spec expand_host(binary(), binary()) -> binary().
expand_host(Input, Host) ->
jlib:expand_keyword(<<"@HOST@">>, Input, Host).
aux:expand_keyword(<<"@HOST@">>, Input, Host).
%%--------------------------------------------------------------------
%% Internal functions.

View File

@ -55,7 +55,7 @@ get_data(LServer, Host, From) ->
set_data(LServer, Host, From, Data) ->
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
SData = jlib:term_to_expr(Data),
SData = aux:term_to_expr(Data),
F = fun () ->
?SQL_UPSERT_T(
"irc_custom",
@ -73,7 +73,7 @@ export(_Server) ->
case str:suffix(Host, IRCHost) of
true ->
SJID = jid:encode(jid:make(U, S)),
SData = jlib:term_to_expr(Data),
SData = aux:term_to_expr(Data),
[?SQL("delete from irc_custom"
" where jid=%(SJID)s and host=%(IRCHost)s;"),
?SQL("insert into irc_custom(jid, host, data)"

View File

@ -436,7 +436,7 @@ delete_old_messages(TypeBin, Days) when TypeBin == <<"chat">>;
TypeBin == <<"all">> ->
Diff = Days * 24 * 60 * 60 * 1000000,
TimeStamp = usec_to_now(p1_time_compat:system_time(micro_seconds) - Diff),
Type = jlib:binary_to_atom(TypeBin),
Type = aux:binary_to_atom(TypeBin),
DBTypes = lists:usort(
lists:map(
fun(Host) ->

View File

@ -58,7 +58,7 @@ remove_room(LServer, LName, LHost) ->
delete_old_messages(ServerHost, TimeStamp, Type) ->
TypeClause = if Type == all -> <<"">>;
true -> [<<" and kind='">>, jlib:atom_to_binary(Type), <<"'">>]
true -> [<<" and kind='">>, aux:atom_to_binary(Type), <<"'">>]
end,
TS = integer_to_binary(now_to_usec(TimeStamp)),
ejabberd_sql:sql_query(
@ -83,7 +83,7 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir) ->
jid:tolower(Peer)),
XML = fxml:element_to_binary(Pkt),
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
SType = jlib:atom_to_binary(Type),
SType = aux:atom_to_binary(Type),
case ejabberd_sql:sql_query(
LServer,
?SQL("insert into archive (username, timestamp,"
@ -107,8 +107,8 @@ write_prefs(LUser, _LServer, #archive_prefs{default = Default,
always = Always},
ServerHost) ->
SDefault = erlang:atom_to_binary(Default, utf8),
SAlways = jlib:term_to_expr(Always),
SNever = jlib:term_to_expr(Never),
SAlways = aux:term_to_expr(Always),
SNever = aux:term_to_expr(Never),
case ?SQL_UPSERT(
ServerHost,
"archive_prefs",
@ -321,7 +321,7 @@ make_archive_el(TS, XML, Peer, Kind, Nick, MsgType, JidRequestor, JidArchive) ->
T = case Kind of
<<"">> -> chat;
null -> chat;
_ -> jlib:binary_to_atom(Kind)
_ -> aux:binary_to_atom(Kind)
end,
mod_mam:msg_to_el(
#archive_msg{timestamp = Now,

View File

@ -133,7 +133,7 @@ send_metrics(Host, Probe, Peer, Port) ->
% grapherl metrics are named first with service domain, then nodename
% and name of the data itself, followed by type timestamp and value
% example => process-one.net/xmpp-1.user_receive_packet:c/1441784958:1
[_, NodeId] = str:tokens(jlib:atom_to_binary(node()), <<"@">>),
[_, NodeId] = str:tokens(aux:atom_to_binary(node()), <<"@">>),
[Node | _] = str:tokens(NodeId, <<".">>),
BaseId = <<Host/binary, "/", Node/binary, ".">>,
DateTime = erlang:universaltime(),
@ -144,11 +144,11 @@ send_metrics(Host, Probe, Peer, Port) ->
case Probe of
{Key, Val} ->
BVal = integer_to_binary(Val),
Data = <<BaseId/binary, (jlib:atom_to_binary(Key))/binary,
Data = <<BaseId/binary, (aux:atom_to_binary(Key))/binary,
":g/", TS/binary, ":", BVal/binary>>,
gen_udp:send(Socket, Peer, Port, Data);
Key ->
Data = <<BaseId/binary, (jlib:atom_to_binary(Key))/binary,
Data = <<BaseId/binary, (aux:atom_to_binary(Key))/binary,
":c/", TS/binary, ":1">>,
gen_udp:send(Socket, Peer, Port, Data)
end,

View File

@ -431,10 +431,10 @@ prepare_room_info(Room_info) ->
[NameHost,
integer_to_binary(Num_participants),
Ts_last_message,
jlib:atom_to_binary(Public),
jlib:atom_to_binary(Persistent),
jlib:atom_to_binary(Logging),
jlib:atom_to_binary(Just_created),
aux:atom_to_binary(Public),
aux:atom_to_binary(Persistent),
aux:atom_to_binary(Logging),
aux:atom_to_binary(Just_created),
Title].
@ -804,7 +804,7 @@ change_room_option(Name, Service, OptionString, ValueString) ->
end.
format_room_option(OptionString, ValueString) ->
Option = jlib:binary_to_atom(OptionString),
Option = aux:binary_to_atom(OptionString),
Value = case Option of
title -> ValueString;
description -> ValueString;
@ -812,7 +812,7 @@ format_room_option(OptionString, ValueString) ->
subject ->ValueString;
subject_author ->ValueString;
max_users -> binary_to_integer(ValueString);
_ -> jlib:binary_to_atom(ValueString)
_ -> aux:binary_to_atom(ValueString)
end,
{Option, Value}.
@ -873,9 +873,9 @@ get_room_options(Pid) ->
get_options(Config).
get_options(Config) ->
Fields = [jlib:atom_to_binary(Field) || Field <- record_info(fields, config)],
Fields = [aux:atom_to_binary(Field) || Field <- record_info(fields, config)],
[config | ValuesRaw] = tuple_to_list(Config),
Values = lists:map(fun(V) when is_atom(V) -> jlib:atom_to_binary(V);
Values = lists:map(fun(V) when is_atom(V) -> aux:atom_to_binary(V);
(V) when is_integer(V) -> integer_to_binary(V);
(V) when is_tuple(V); is_list(V) -> list_to_binary(hd(io_lib:format("~w", [V])));
(V) -> V end, ValuesRaw),
@ -917,7 +917,7 @@ get_room_affiliations(Name, Service) ->
%% If the affiliation is 'none', the action is to remove,
%% In any other case the action will be to create the affiliation.
set_room_affiliation(Name, Service, JID, AffiliationString) ->
Affiliation = jlib:binary_to_atom(AffiliationString),
Affiliation = aux:binary_to_atom(AffiliationString),
case mod_muc:find_online_room(Name, Service) of
{ok, Pid} ->
%% Get the PID for the online room so we can get the state of the room

View File

@ -537,7 +537,7 @@ make_dir_rec(Dir) ->
%% {ok, F1}=file:open("valid-xhtml10.png", [read]).
%% {ok, F1b}=file:read(F1, 1000000).
%% c("../../ejabberd/src/jlib.erl").
%% jlib:encode_base64(F1b).
%% aux:encode_base64(F1b).
image_base64(<<"powered-by-erlang.png">>) ->
<<"iVBORw0KGgoAAAANSUhEUgAAAGUAAAAfCAYAAAD+xQNoA"
@ -713,7 +713,7 @@ create_image_files(Images_dir) ->
lists:foreach(fun (Filename) ->
Filename_full = fjoin([Images_dir, Filename]),
{ok, F} = file:open(Filename_full, [write]),
Image = jlib:decode_base64(image_base64(Filename)),
Image = aux:decode_base64(image_base64(Filename)),
io:format(F, <<"~s">>, [Image]),
file:close(F)
end,
@ -1051,7 +1051,7 @@ roomconfig_to_string(Options, Lang, FileFormat) ->
allow_private_messages_from_visitors ->
<<"<div class=\"rcot\">",
OptText/binary, ": \"",
(htmlize(?T(jlib:atom_to_binary(T)),
(htmlize(?T(aux:atom_to_binary(T)),
FileFormat))/binary,
"\"</div>">>;
_ -> <<"\"", T/binary, "\"">>

View File

@ -1156,13 +1156,13 @@ handle_iq_vcard(ToJID, NewId, #iq{type = Type, sub_els = SubEls} = IQ) ->
-spec stanzaid_pack(binary(), binary()) -> binary().
stanzaid_pack(OriginalId, Resource) ->
<<"berd",
(jlib:encode_base64(<<"ejab\000",
(aux:encode_base64(<<"ejab\000",
OriginalId/binary, "\000",
Resource/binary>>))/binary>>.
-spec stanzaid_unpack(binary()) -> {binary(), binary()}.
stanzaid_unpack(<<"berd", StanzaIdBase64/binary>>) ->
StanzaId = jlib:decode_base64(StanzaIdBase64),
StanzaId = aux:decode_base64(StanzaIdBase64),
[<<"ejab">>, OriginalId, Resource] =
str:tokens(StanzaId, <<"\000">>),
{OriginalId, Resource}.

View File

@ -57,7 +57,7 @@ init(Host, Opts) ->
end.
store_room(LServer, Host, Name, Opts) ->
SOpts = jlib:term_to_expr(Opts),
SOpts = aux:term_to_expr(Opts),
F = fun () ->
?SQL_UPSERT_T(
"muc_room",
@ -296,7 +296,7 @@ export(_Server) ->
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
case str:suffix(Host, RoomHost) of
true ->
SOpts = jlib:term_to_expr(Opts),
SOpts = aux:term_to_expr(Opts),
[?SQL("delete from muc_room where name=%(Name)s"
" and host=%(RoomHost)s;"),
?SQL("insert into muc_room(name, host, opts) "

View File

@ -113,7 +113,7 @@ update(Server, JID, Dir) ->
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
"sent presence subscriptions~n",
[jid:encode(JID),
jlib:ip_to_list(IP)])
aux:ip_to_list(IP)])
end,
{stop, deny};
true ->

View File

@ -253,9 +253,9 @@ process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To,
transform_module_options(Opts) ->
lists:map(
fun({ip, IP}) when is_tuple(IP) ->
{ip, jlib:ip_to_list(IP)};
{ip, aux:ip_to_list(IP)};
({hostname, IP}) when is_tuple(IP) ->
{hostname, jlib:ip_to_list(IP)};
{hostname, aux:ip_to_list(IP)};
(Opt) ->
Opt
end, Opts).
@ -265,7 +265,7 @@ get_streamhost(Host, ServerHost) ->
{Port, IP} = get_port_ip(ServerHost),
HostName = gen_mod:get_module_opt(ServerHost, mod_proxy65, hostname,
fun iolist_to_binary/1,
jlib:ip_to_list(IP)),
aux:ip_to_list(IP)),
Resource = ejabberd_cluster:node_id(),
#streamhost{jid = jid:make(<<"">>, Host, Resource),
host = HostName,

View File

@ -3473,16 +3473,16 @@ tree(_Host, <<"virtual">>) ->
nodetree_virtual; % special case, virtual does not use any backend
tree(Host, Name) ->
case gen_mod:db_type(serverhost(Host), ?MODULE) of
mnesia -> jlib:binary_to_atom(<<"nodetree_", Name/binary>>);
sql -> jlib:binary_to_atom(<<"nodetree_", Name/binary, "_sql">>);
mnesia -> aux:binary_to_atom(<<"nodetree_", Name/binary>>);
sql -> aux:binary_to_atom(<<"nodetree_", Name/binary, "_sql">>);
_ -> Name
end.
-spec plugin(host(), binary() | atom()) -> atom().
plugin(Host, Name) ->
case gen_mod:db_type(serverhost(Host), ?MODULE) of
mnesia -> jlib:binary_to_atom(<<"node_", Name/binary>>);
sql -> jlib:binary_to_atom(<<"node_", Name/binary, "_sql">>);
mnesia -> aux:binary_to_atom(<<"node_", Name/binary>>);
sql -> aux:binary_to_atom(<<"node_", Name/binary, "_sql">>);
_ -> Name
end.

View File

@ -289,7 +289,7 @@ try_set_password(User, Server, Password, #iq{lang = Lang, meta = M} = IQ) ->
?INFO_MSG("~s has changed password from ~s",
[jid:encode({User, Server, <<"">>}),
ejabberd_config:may_hide_data(
jlib:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
aux:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
xmpp:make_iq_result(IQ);
{error, empty_password} ->
Txt = <<"Empty password">>,
@ -522,7 +522,7 @@ remove_timeout(Source) ->
end.
ip_to_string(Source) when is_tuple(Source) ->
jlib:ip_to_list(Source);
aux:ip_to_list(Source);
ip_to_string(undefined) -> <<"undefined">>;
ip_to_string(_) -> <<"unknown">>.
@ -575,7 +575,7 @@ transform_ip_access(Opts) ->
"use access rules instead.", []),
ACLs = lists:flatmap(
fun({Action, S}) ->
ACLName = jlib:binary_to_atom(
ACLName = aux:binary_to_atom(
iolist_to_binary(
["ip_", S])),
[{Action, ACLName},

View File

@ -147,7 +147,7 @@ s2s_out_auth_result(#{db_enabled := true,
%% Sending dialback request, section 2.1.1, step 1
?INFO_MSG("(~s) Retrying with s2s dialback authentication: ~s -> ~s (~s)",
[SockMod:pp(Socket), LServer, RServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
State1 = maps:remove(stop_reason, State#{on_route => queue}),
{stop, send_db_request(State1)};
s2s_out_auth_result(State, _) ->
@ -168,7 +168,7 @@ s2s_out_downgraded(#{db_enabled := true,
?INFO_MSG("(~s) Trying s2s dialback authentication with "
"non-RFC compliant server: ~s -> ~s (~s)",
[SockMod:pp(Socket), LServer, RServer,
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
{stop, send_db_request(State)};
s2s_out_downgraded(State, _) ->
State.

View File

@ -462,7 +462,7 @@ get_user_part_re(String, Pattern) ->
end.
parse_options(Host, Opts) ->
Eldap_ID = jlib:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Cfg = eldap_utils:get_config(Host, Opts),
GroupAttr = gen_mod:get_opt(ldap_groupattr, Opts,
fun iolist_to_binary/1,

View File

@ -67,7 +67,7 @@ groups_with_opts(Host) ->
end.
create_group(Host, Group, Opts) ->
SOpts = jlib:term_to_expr(Opts),
SOpts = aux:term_to_expr(Opts),
F = fun () ->
?SQL_UPSERT_T(
"sr_group",
@ -98,7 +98,7 @@ get_group_opts(Host, Group) ->
end.
set_group_opts(Host, Group, Opts) ->
SOpts = jlib:term_to_expr(Opts),
SOpts = aux:term_to_expr(Opts),
F = fun () ->
?SQL_UPSERT_T(
"sr_group",
@ -172,7 +172,7 @@ export(_Server) ->
[{sr_group,
fun(Host, #sr_group{group_host = {Group, LServer}, opts = Opts})
when LServer == Host ->
SOpts = jlib:term_to_expr(Opts),
SOpts = aux:term_to_expr(Opts),
[?SQL("delete from sr_group where name=%(Group)s;"),
?SQL("insert into sr_group(name, opts) values ("
"%(Group)s, %(SOpts)s);")];

View File

@ -570,7 +570,7 @@ route_unacked_stanzas(_State) ->
{error, binary(), non_neg_integer()}.
inherit_session_state(#{user := U, server := S,
mgmt_queue_type := QueueType} = State, ResumeID) ->
case jlib:base64_to_term(ResumeID) of
case aux:base64_to_term(ResumeID) of
{term, {R, Time}} ->
case ejabberd_sm:get_session_pid(U, S, R) of
none ->
@ -627,7 +627,7 @@ resume_session({Time, Pid}, _State) ->
-spec make_resume_id(state()) -> binary().
make_resume_id(#{sid := {Time, _}, resource := Resource}) ->
jlib:term_to_base64({Resource, Time}).
aux:term_to_base64({Resource, Time}).
-spec add_resent_delay_info(state(), stanza(), erlang:timestamp()) -> stanza();
(state(), xmlel(), erlang:timestamp()) -> xmlel().

View File

@ -362,7 +362,7 @@ parse_options(Host, Opts) ->
fun(infinity) -> 0;
(I) when is_integer(I), I>0 -> I
end, 30),
Eldap_ID = jlib:atom_to_binary(gen_mod:get_module_proc(Host, ?PROCNAME)),
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?PROCNAME)),
Cfg = eldap_utils:get_config(Host, Opts),
UIDsTemp = gen_mod:get_opt(
{ldap_uids, Host}, Opts,

View File

@ -99,7 +99,7 @@ vcard_set(LUser, LServer, VCARD) ->
<<>> -> remove_xupdate(LUser, LServer);
BinVal ->
add_xupdate(LUser, LServer,
str:sha(jlib:decode_base64(BinVal)))
str:sha(aux:decode_base64(BinVal)))
end,
ejabberd_sm:force_update_presence(US).

View File

@ -651,7 +651,7 @@ get_items(Nidx, From, undefined) ->
?SQL("select @(val)s from pubsub_node_option "
"where nodeid=%(Nidx)d and name='max_items'")) of
{selected, [{Value}]} ->
jlib:expr_to_term(Value);
aux:expr_to_term(Value);
_ ->
?MAXITEMS
end,
@ -664,7 +664,7 @@ get_items(Nidx, _From, #rsm_set{max = Max, index = IncIndex,
Before /= undefined -> {<<">">>, <<"asc">>};
true -> {<<"is not">>, <<"desc">>}
end,
SNidx = jlib:i2l(Nidx),
SNidx = aux:i2l(Nidx),
I = if After /= undefined -> After;
Before /= undefined -> Before;
true -> undefined
@ -773,8 +773,8 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
end.
get_last_items(Nidx, _From, Count) ->
Limit = jlib:i2l(Count),
SNidx = jlib:i2l(Nidx),
Limit = aux:i2l(Count),
SNidx = aux:i2l(Nidx),
Query = fun(mssql, _) ->
ejabberd_sql:sql_query_t(
[<<"select top ">>, Limit,
@ -850,7 +850,7 @@ set_item(Item) ->
Payload = Item#pubsub_item.payload,
XML = str:join([fxml:element_to_binary(X) || X<-Payload], <<>>),
S = fun ({T1, T2, T3}) ->
str:join([jlib:i2l(T1, 6), jlib:i2l(T2, 6), jlib:i2l(T3, 6)], <<":">>)
str:join([aux:i2l(T1, 6), aux:i2l(T2, 6), aux:i2l(T3, 6)], <<":">>)
end,
SM = S(M),
SC = S(C),
@ -876,7 +876,7 @@ del_items(Nidx, [ItemId]) ->
del_item(Nidx, ItemId);
del_items(Nidx, ItemIds) ->
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
SNidx = jlib:i2l(Nidx),
SNidx = aux:i2l(Nidx),
catch
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
I, <<") and nodeid='">>, SNidx, <<"';">>]).
@ -1030,7 +1030,7 @@ raw_to_item(Nidx, {ItemId, SJID, Creation, Modification, XML}) ->
JID = decode_jid(SJID),
ToTime = fun (Str) ->
[T1, T2, T3] = str:tokens(Str, <<":">>),
{jlib:l2i(T1), jlib:l2i(T2), jlib:l2i(T3)}
{aux:l2i(T1), aux:l2i(T2), aux:l2i(T3)}
end,
Payload = case fxml_stream:parse_element(XML) of
{error, _Reason} -> [];

View File

@ -125,11 +125,11 @@ get_subnodes_tree(Host, Node) ->
{error, _} ->
[];
Rec ->
BasePlugin = jlib:binary_to_atom(<<"node_",
BasePlugin = aux:binary_to_atom(<<"node_",
(Rec#pubsub_node.type)/binary>>),
BasePath = BasePlugin:node_to_path(Node),
mnesia:foldl(fun (#pubsub_node{nodeid = {H, N}} = R, Acc) ->
Plugin = jlib:binary_to_atom(<<"node_",
Plugin = aux:binary_to_atom(<<"node_",
(R#pubsub_node.type)/binary>>),
Path = Plugin:node_to_path(N),
case lists:prefix(BasePath, Path) and (H == Host) of

View File

@ -101,7 +101,7 @@ set_node(Record) when is_record(Record, pubsub_node) ->
_ ->
lists:foreach(fun ({Key, Value}) ->
SKey = iolist_to_binary(atom_to_list(Key)),
SValue = jlib:term_to_expr(Value),
SValue = aux:term_to_expr(Value),
catch
ejabberd_sql:sql_query_t(
?SQL("insert into pubsub_node_option(nodeid, "
@ -278,13 +278,13 @@ raw_to_node(Host, {Node, Parent, Type, Nidx}) ->
of
{selected, ROptions} ->
DbOpts = lists:map(fun ({Key, Value}) ->
RKey = jlib:binary_to_atom(Key),
RKey = aux:binary_to_atom(Key),
Tokens = element(2, erl_scan:string(binary_to_list(<<Value/binary, ".">>))),
RValue = element(2, erl_parse:parse_term(Tokens)),
{RKey, RValue}
end,
ROptions),
Module = jlib:binary_to_atom(<<"node_", Type/binary, "_sql">>),
Module = aux:binary_to_atom(<<"node_", Type/binary, "_sql">>),
StdOpts = Module:options(),
lists:foldl(fun ({Key, Value}, Acc) ->
lists:keyreplace(Key, 1, Acc, {Key, Value})

View File

@ -113,9 +113,9 @@ maybe_get_scram_auth(Data) ->
case proplists:get_value(<<"iteration_count">>, Data, no_ic) of
IC when is_float(IC) -> %% A float like 4096.0 is read
#scram{
storedkey = jlib:hex_to_base64(proplists:get_value(<<"stored_key">>, Data, <<"">>)),
serverkey = jlib:hex_to_base64(proplists:get_value(<<"server_key">>, Data, <<"">>)),
salt = jlib:hex_to_base64(proplists:get_value(<<"salt">>, Data, <<"">>)),
storedkey = aux:hex_to_base64(proplists:get_value(<<"stored_key">>, Data, <<"">>)),
serverkey = aux:hex_to_base64(proplists:get_value(<<"server_key">>, Data, <<"">>)),
salt = aux:hex_to_base64(proplists:get_value(<<"salt">>, Data, <<"">>)),
iterationcount = round(IC)
};
_ -> <<"">>
@ -247,7 +247,7 @@ convert_roster_item(LUser, LServer, JIDstring, LuaList) ->
end, Val),
R#roster{groups = Gs};
({<<"subscription">>, Sub}, R) ->
R#roster{subscription = jlib:binary_to_atom(Sub)};
R#roster{subscription = aux:binary_to_atom(Sub)};
({<<"ask">>, <<"subscribe">>}, R) ->
R#roster{ask = out};
({<<"name">>, Name}, R) ->
@ -263,7 +263,7 @@ convert_room_affiliations(Data) ->
fun({J, Aff}) ->
try jid:decode(J) of
#jid{luser = U, lserver = S} ->
[{{U, S, <<>>}, jlib:binary_to_atom(Aff)}]
[{{U, S, <<>>}, aux:binary_to_atom(Aff)}]
catch _:{bad_jid, _} ->
[]
end
@ -301,7 +301,7 @@ convert_room_config(Data) ->
convert_privacy_item({_, Item}) ->
Action = proplists:get_value(<<"action">>, Item, <<"allow">>),
Order = proplists:get_value(<<"order">>, Item, 0),
T = jlib:binary_to_atom(proplists:get_value(<<"type">>, Item, <<"none">>)),
T = aux:binary_to_atom(proplists:get_value(<<"type">>, Item, <<"none">>)),
V = proplists:get_value(<<"value">>, Item, <<"">>),
MatchIQ = proplists:get_bool(<<"iq">>, Item),
MatchMsg = proplists:get_bool(<<"message">>, Item),
@ -317,14 +317,14 @@ convert_privacy_item({_, Item}) ->
none -> {T, none};
group -> {T, V};
jid -> {T, jid:tolower(jid:decode(V))};
subscription -> {T, jlib:binary_to_atom(V)}
subscription -> {T, aux:binary_to_atom(V)}
end
catch _:_ ->
{none, none}
end,
#listitem{type = Type,
value = Value,
action = jlib:binary_to_atom(Action),
action = aux:binary_to_atom(Action),
order = erlang:trunc(Order),
match_all = MatchAll,
match_iq = MatchIQ,