25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Rename aux.erl as misc.erl

Thanks Microsoft Windows to not support some filenames
This commit is contained in:
Christophe Romain 2017-04-11 12:13:58 +02:00
parent 265aa54bc2
commit b1acd1183f
57 changed files with 221 additions and 221 deletions

View File

@ -128,14 +128,14 @@ mech_step(#state{step = 2} = State, ClientIn) ->
str:substr(ClientIn,
str:str(ClientIn, <<"n=">>)),
ServerNonce =
aux:encode_base64(randoms:bytes(?NONCE_LENGTH)),
misc:encode_base64(randoms:bytes(?NONCE_LENGTH)),
ServerFirstMessage =
iolist_to_binary(
["r=",
ClientNonce,
ServerNonce,
",", "s=",
aux:encode_base64(Salt),
misc: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(aux:decode_base64(CVal), 0),
ChannelBindingSupport = binary:at(misc: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 = aux:decode_base64(ClientProofB64),
ClientProof = misc: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=",
(aux:encode_base64(ServerSignature))/binary>>};
(misc: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]),
[aux:binary_to_atom(<<"ejabberd_auth_",
(aux:atom_to_binary(M))/binary>>)
[misc:binary_to_atom(<<"ejabberd_auth_",
(misc: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 = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Bind_Eldap_ID = aux:atom_to_binary(
Eldap_ID = misc:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Bind_Eldap_ID = misc: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 = aux:decode_base64(Scram#scram.storedkey),
Passwd = misc: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) ->
{aux:decode_base64(Scram#scram.storedkey),
aux:decode_base64(Scram#scram.serverkey),
aux:decode_base64(Scram#scram.salt),
{misc:decode_base64(Scram#scram.storedkey),
misc:decode_base64(Scram#scram.serverkey),
misc: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 = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
#scram{storedkey = misc:encode_base64(StoredKey),
serverkey = misc:encode_base64(ServerKey),
salt = misc: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 = aux:decode_base64(Scram#scram.salt),
Salt = misc:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
aux:decode_base64(Scram#scram.storedkey) == StoredKey
misc: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 = aux:decode_base64(Scram#scram.storedkey),
Passwd = misc: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) ->
{aux:decode_base64(Scram#scram.storedkey),
aux:decode_base64(Scram#scram.serverkey),
aux:decode_base64(Scram#scram.salt),
{misc:decode_base64(Scram#scram.storedkey),
misc:decode_base64(Scram#scram.serverkey),
misc: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 = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
#scram{storedkey = misc:encode_base64(StoredKey),
serverkey = misc:encode_base64(ServerKey),
salt = misc: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 = aux:decode_base64(Scram#scram.salt),
Salt = misc:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
aux:decode_base64(Scram#scram.storedkey) == StoredKey
misc: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}]} ->
{aux:decode_base64(StoredKey),
aux:decode_base64(ServerKey),
aux:decode_base64(Salt),
{misc:decode_base64(StoredKey),
misc:decode_base64(ServerKey),
misc: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 = aux:encode_base64(StoredKey),
serverkey = aux:encode_base64(ServerKey),
salt = aux:encode_base64(Salt),
#scram{storedkey = misc:encode_base64(StoredKey),
serverkey = misc:encode_base64(ServerKey),
salt = misc: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 = aux:decode_base64(Scram#scram.salt),
Salt = misc:decode_base64(Scram#scram.salt),
SaltedPassword = scram:salted_password(Password, Salt,
IterationCount),
StoredKey =
scram:stored_key(scram:client_key(SaltedPassword)),
aux:decode_base64(Scram#scram.storedkey) == StoredKey
misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP)), Reason]),
ejabberd_config:may_hide_data(misc: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(aux:atom_to_binary(Cookie))
str:sha(misc: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 aux:tolower(Conn) of
KeepAlive1 = case misc: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, <<", ">>) ++
[aux:ip_to_list(IPLast)],
[misc: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, aux:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
{K, misc: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 = aux:decode_base64(Auth64),
Auth = misc: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 ", (aux:atom_to_binary(?MODULE))/binary>>,
Heading = <<"ejabberd ", (misc: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 = aux:ip_to_list(T),
S = misc:ip_to_list(T),
{P, T, S, Prot};
{P, T, Prot} when is_integer(P) and is_tuple(T) ->
S = aux:ip_to_list(T),
S = misc: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

@ -68,12 +68,12 @@ start_link(I) ->
?GEN_SERVER:start_link({local, get_proc(I)}, ?MODULE, [I], []).
get_proc(I) ->
aux:binary_to_atom(
misc:binary_to_atom(
iolist_to_binary(
[atom_to_list(?MODULE), $_, integer_to_list(I)])).
get_connection(I) ->
aux:binary_to_atom(
misc:binary_to_atom(
iolist_to_binary(
[atom_to_list(?MODULE), "_connection_", integer_to_list(I)])).
@ -109,7 +109,7 @@ multi(F) ->
-spec format_error(atom() | binary()) -> binary().
format_error(Reason) when is_atom(Reason) ->
format_error(aux:atom_to_binary(Reason));
format_error(misc:atom_to_binary(Reason));
format_error(Reason) ->
Reason.

View File

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

View File

@ -51,7 +51,7 @@ init() ->
end.
register_route(Domain, ServerHost, LocalHint, _, Pid) ->
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
LocalHintS = enc_local_hint(LocalHint),
Node = erlang:atom_to_binary(node(Pid), latin1),
case ?SQL_UPSERT(?MYNAME, "route",
@ -68,7 +68,7 @@ register_route(Domain, ServerHost, LocalHint, _, Pid) ->
end.
unregister_route(Domain, _, Pid) ->
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
Node = erlang:atom_to_binary(node(Pid), latin1),
ejabberd_sql:sql_query(
?MYNAME,
@ -146,7 +146,7 @@ find_routes() ->
enc_local_hint(undefined) ->
<<"">>;
enc_local_hint(LocalHint) ->
aux:term_to_expr(LocalHint).
misc:term_to_expr(LocalHint).
dec_local_hint(<<"">>) ->
undefined;
@ -156,7 +156,7 @@ dec_local_hint(S) ->
row_to_route(Domain, {ServerHost, NodeS, PidS, LocalHintS} = Row) ->
try [#route{domain = Domain,
server_host = ServerHost,
pid = aux:decode_pid(PidS, NodeS),
pid = misc:decode_pid(PidS, NodeS),
local_hint = dec_local_hint(LocalHintS)}]
catch _:{bad_node, _} ->
[];

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 = aux:binary_to_atom(
ACLName = misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP)), Reason]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP)),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP)),
ejabberd_config:may_hide_data(misc:ip_to_list(IP)),
Reason]),
State.

View File

@ -65,10 +65,10 @@ init() ->
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
priority = Priority, info = Info}) ->
InfoS = aux:term_to_expr(Info),
InfoS = misc:term_to_expr(Info),
PrioS = enc_priority(Priority),
TS = now_to_timestamp(Now),
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
Node = erlang:atom_to_binary(node(Pid), latin1),
case ?SQL_UPSERT(LServer, "sm",
["!usec=%(TS)d",
@ -194,7 +194,7 @@ enc_priority(Int) when is_integer(Int) ->
row_to_session(LServer, {USec, PidS, NodeS, User, Resource, PrioS, InfoS}) ->
Now = timestamp_to_now(USec),
Pid = aux:decode_pid(PidS, NodeS),
Pid = misc:decode_pid(PidS, NodeS),
Priority = dec_priority(PrioS),
Info = ejabberd_sql:decode_term(InfoS),
#session{sid = {Now, Pid}, us = {User, LServer},

View File

@ -644,7 +644,7 @@ generic_sql_query_format(SQLQuery) ->
generic_escape() ->
#sql_escape{string = fun(X) -> <<"'", (escape(X))/binary, "'">> end,
integer = fun(X) -> aux:i2l(X) end,
integer = fun(X) -> misc:i2l(X) end,
boolean = fun(true) -> <<"1">>;
(false) -> <<"0">>
end
@ -661,7 +661,7 @@ sqlite_sql_query_format(SQLQuery) ->
sqlite_escape() ->
#sql_escape{string = fun(X) -> <<"'", (standard_escape(X))/binary, "'">> end,
integer = fun(X) -> aux:i2l(X) end,
integer = fun(X) -> misc:i2l(X) end,
boolean = fun(true) -> <<"1">>;
(false) -> <<"0">>
end
@ -685,7 +685,7 @@ pgsql_prepare(SQLQuery, State) ->
pgsql_execute_escape() ->
#sql_escape{string = fun(X) -> X end,
integer = fun(X) -> [aux:i2l(X)] end,
integer = fun(X) -> [misc: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 = aux:binary_to_atom(SNode),
Node = misc:binary_to_atom(SNode),
remote_command(Node, [kill, SPid], From, To);
process_command2([<<"showlh">>, SNode], From, To) ->
Node = aux:binary_to_atom(SNode),
Node = misc:binary_to_atom(SNode),
remote_command(Node, [showlh], From, To);
process_command2([<<"setlh">>, SNode, NewValueString],
From, To) ->
Node = aux:binary_to_atom(SNode),
Node = misc: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 = aux:encode_base64(
Hash = misc: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 = aux:binary_to_atom(<<"eldap_",
Reg_name = misc: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 = aux:binary_to_atom(<<"eldap_",
Reg_name = misc: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) ->
aux:binary_to_atom(<<"eldap_",
misc:binary_to_atom(<<"eldap_",
Name/binary>>).
%%%----------------------------------------------------------------------

View File

@ -83,4 +83,4 @@ do_request(Name, {F, Args}) ->
end.
make_id(Name) ->
aux:binary_to_atom(<<"eldap_pool_", Name/binary>>).
misc: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(aux:atom_to_binary(Module));
available(misc:atom_to_binary(Module));
available(Package) when is_binary(Package) ->
Available = [aux:atom_to_binary(K) || K<-proplists:get_keys(available())],
Available = [misc: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(aux:atom_to_binary(Module));
installed(misc:atom_to_binary(Module));
installed(Package) when is_binary(Package) ->
Installed = [aux:atom_to_binary(K) || K<-proplists:get_keys(installed())],
Installed = [misc: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(aux:atom_to_binary(Module));
install(misc:atom_to_binary(Module));
install(Package) when is_binary(Package) ->
Spec = [S || {Mod, S} <- available(), aux:atom_to_binary(Mod)==Package],
Spec = [S || {Mod, S} <- available(), misc: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 = aux:binary_to_atom(Package),
Module = misc: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(aux:atom_to_binary(Module));
uninstall(misc:atom_to_binary(Module));
uninstall(Package) when is_binary(Package) ->
case installed(Package) of
true ->
Module = aux:binary_to_atom(Package),
Module = misc: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(aux:atom_to_binary(Module));
upgrade(misc: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(aux:atom_to_binary(Module), Path);
add_sources(misc: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(aux:atom_to_binary(Module));
del_sources(misc:atom_to_binary(Module));
del_sources(Package) when is_binary(Package) ->
case uninstall(Package) of
ok ->
SrcDir = module_src_dir(aux:binary_to_atom(Package)),
SrcDir = module_src_dir(misc:binary_to_atom(Package)),
delete_path(SrcDir);
Error ->
Error
end.
check(Module) when is_atom(Module) ->
check(aux:atom_to_binary(Module));
check(misc: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(aux:binary_to_atom(Package));
ok -> check_sources(misc:binary_to_atom(Package));
Error -> Error
end;
_ ->
check_sources(aux:binary_to_atom(Package))
check_sources(misc:binary_to_atom(Package))
end.
%% -- archives and variables functions
@ -420,7 +420,7 @@ module_name(Id) ->
filename:basename(filename:rootname(Id)).
module(Id) ->
aux:binary_to_atom(iolist_to_binary(module_name(Id))).
misc:binary_to_atom(iolist_to_binary(module_name(Id))).
module_spec(Spec) ->
[{path, filename:dirname(Spec)}

View File

@ -25,7 +25,7 @@
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%-------------------------------------------------------------------
-module(aux).
-module(misc).
%% API
-export([tolower/1, term_to_base64/1, base64_to_term/1,

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, aux:binary_to_atom(Module));
restart_module(Host, misc: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 = aux:binary_to_atom(Type),
show = aux:binary_to_atom(Show),
type = misc:binary_to_atom(Type),
show = misc: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 = aux:binary_to_atom(Subs),
subscription = misc: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,
[{aux:atom_to_binary(Title), btl(Value)} || {Title, Value} <- Opts].
[{misc: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 = aux:binary_to_atom(Type),
#message{type = misc:binary_to_atom(Type),
body = xmpp:mk_text(Body),
subject = xmpp:mk_text(Subject)}.

View File

@ -34,7 +34,7 @@ init() ->
end.
open_session(SID, Pid) ->
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
Node = erlang:atom_to_binary(node(Pid), latin1),
case ?SQL_UPSERT(?MYNAME, "bosh",
["!sid=%(SID)s",
@ -57,7 +57,7 @@ find_session(SID) ->
?MYNAME,
?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of
{selected, [{Pid, Node}]} ->
try {ok, aux:decode_pid(Pid, Node)}
try {ok, misc:decode_pid(Pid, Node)}
catch _:{bad_node, _} -> error
end;
{selected, []} ->

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)]),
aux:encode_base64(case Algo of
misc: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 = aux:atom_to_binary(M),
S = misc: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 = aux:binary_to_atom(SVar),
Table = misc: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 = aux:binary_to_atom(Var),
Module = misc: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 = [<<(aux:ip_to_list(IP))/binary, ":",
IPs = [<<(misc: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 = aux:binary_to_atom(ENode),
Node = misc: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 = aux:ip_to_list(Addr),
IP = misc: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 = [{aux:binary_to_atom(Key), Value} || {Key, Value} <- Args],
Args2 = [{misc: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, aux:atom_to_binary(Why)};
{404, misc: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, aux:atom_to_binary(Why)};
{401, misc: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, aux:atom_to_binary(Why)};
{400, misc:atom_to_binary(Why)};
throw:{error, Msg} ->
{400, iolist_to_binary(Msg)};
throw:Error when is_atom(Error) ->
{400, aux:atom_to_binary(Error)};
{400, misc: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}) ->
{aux:atom_to_binary(Name), aux:atom_to_binary(Atom)};
{misc:atom_to_binary(Name), misc:atom_to_binary(Atom)};
format_result(Int, {Name, integer}) ->
{aux:atom_to_binary(Name), Int};
{misc:atom_to_binary(Name), Int};
format_result([String | _] = StringList, {Name, string}) when is_list(String) ->
Binarized = iolist_to_binary(string:join(StringList, "\n")),
{aux:atom_to_binary(Name), Binarized};
{misc:atom_to_binary(Name), Binarized};
format_result(String, {Name, string}) ->
{aux:atom_to_binary(Name), iolist_to_binary(String)};
{misc:atom_to_binary(Name), iolist_to_binary(String)};
format_result(Code, {Name, rescode}) ->
{aux:atom_to_binary(Name), Code == true orelse Code == ok};
{misc:atom_to_binary(Name), Code == true orelse Code == ok};
format_result({Code, Text}, {Name, restuple}) ->
{aux:atom_to_binary(Name),
{misc:atom_to_binary(Name),
{[{<<"res">>, Code == true orelse Code == ok},
{<<"text">>, iolist_to_binary(Text)}]}};
format_result(Code, {Name, restuple}) ->
{aux:atom_to_binary(Name),
{misc:atom_to_binary(Name),
{[{<<"res">>, Code == true orelse Code == ok},
{<<"text">>, <<"">>}]}};
format_result(Els, {Name, {list, {_, {tuple, [{_, atom}, _]}} = Fmt}}) ->
{aux:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
{misc:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
format_result(Els, {Name, {list, Def}}) ->
{aux:atom_to_binary(Name), [element(2, format_result(El, Def)) || El <- Els]};
{misc: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),
{aux:atom_to_binary(Name2), Val2};
{misc:atom_to_binary(Name2), Val2};
format_result(Tuple, {Name, {tuple, Def}}) ->
Els = lists:zip(tuple_to_list(Tuple), Def),
{aux:atom_to_binary(Name), {[format_result(El, ElDef) || {El, ElDef} <- Els]}};
{misc: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 = aux:ip_to_list({Addr, Port}),
AddrS = misc: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(aux:ip_to_list(IP))).
-define(ADDR_TO_STR(IP), ejabberd_config:may_hide_data(misc: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),
aux:expand_keyword(<<"@HOME@">>, Input, Home).
misc:expand_keyword(<<"@HOME@">>, Input, Home).
-spec expand_host(binary(), binary()) -> binary().
expand_host(Input, Host) ->
aux:expand_keyword(<<"@HOST@">>, Input, Host).
misc: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 = aux:term_to_expr(Data),
SData = misc: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 = aux:term_to_expr(Data),
SData = misc: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 = aux:binary_to_atom(TypeBin),
Type = misc: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='">>, aux:atom_to_binary(Type), <<"'">>]
true -> [<<" and kind='">>, misc: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 = aux:atom_to_binary(Type),
SType = misc: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 = aux:term_to_expr(Always),
SNever = aux:term_to_expr(Never),
SAlways = misc:term_to_expr(Always),
SNever = misc: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;
_ -> aux:binary_to_atom(Kind)
_ -> misc: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(aux:atom_to_binary(node()), <<"@">>),
[_, NodeId] = str:tokens(misc: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, (aux:atom_to_binary(Key))/binary,
Data = <<BaseId/binary, (misc:atom_to_binary(Key))/binary,
":g/", TS/binary, ":", BVal/binary>>,
gen_udp:send(Socket, Peer, Port, Data);
Key ->
Data = <<BaseId/binary, (aux:atom_to_binary(Key))/binary,
Data = <<BaseId/binary, (misc:atom_to_binary(Key))/binary,
":c/", TS/binary, ":1">>,
gen_udp:send(Socket, Peer, Port, Data)
end,

View File

@ -450,10 +450,10 @@ prepare_room_info(Room_info) ->
[NameHost,
integer_to_binary(Num_participants),
Ts_last_message,
aux:atom_to_binary(Public),
aux:atom_to_binary(Persistent),
aux:atom_to_binary(Logging),
aux:atom_to_binary(Just_created),
misc:atom_to_binary(Public),
misc:atom_to_binary(Persistent),
misc:atom_to_binary(Logging),
misc:atom_to_binary(Just_created),
Title].
@ -823,7 +823,7 @@ change_room_option(Name, Service, OptionString, ValueString) ->
end.
format_room_option(OptionString, ValueString) ->
Option = aux:binary_to_atom(OptionString),
Option = misc:binary_to_atom(OptionString),
Value = case Option of
title -> ValueString;
description -> ValueString;
@ -831,7 +831,7 @@ format_room_option(OptionString, ValueString) ->
subject ->ValueString;
subject_author ->ValueString;
max_users -> binary_to_integer(ValueString);
_ -> aux:binary_to_atom(ValueString)
_ -> misc:binary_to_atom(ValueString)
end,
{Option, Value}.
@ -892,9 +892,9 @@ get_room_options(Pid) ->
get_options(Config).
get_options(Config) ->
Fields = [aux:atom_to_binary(Field) || Field <- record_info(fields, config)],
Fields = [misc:atom_to_binary(Field) || Field <- record_info(fields, config)],
[config | ValuesRaw] = tuple_to_list(Config),
Values = lists:map(fun(V) when is_atom(V) -> aux:atom_to_binary(V);
Values = lists:map(fun(V) when is_atom(V) -> misc: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),
@ -936,7 +936,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 = aux:binary_to_atom(AffiliationString),
Affiliation = misc: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").
%% aux:encode_base64(F1b).
%% misc: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 = aux:decode_base64(image_base64(Filename)),
Image = misc: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(aux:atom_to_binary(T)),
(htmlize(?T(misc: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",
(aux:encode_base64(<<"ejab\000",
(misc:encode_base64(<<"ejab\000",
OriginalId/binary, "\000",
Resource/binary>>))/binary>>.
-spec stanzaid_unpack(binary()) -> {binary(), binary()}.
stanzaid_unpack(<<"berd", StanzaIdBase64/binary>>) ->
StanzaId = aux:decode_base64(StanzaIdBase64),
StanzaId = misc: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 = aux:term_to_expr(Opts),
SOpts = misc:term_to_expr(Opts),
F = fun () ->
?SQL_UPSERT_T(
"muc_room",
@ -171,7 +171,7 @@ search_affiliation(_ServerHost, _Room, _Host, _Affiliation) ->
{error, not_implemented}.
register_online_room(ServerHost, Room, Host, Pid) ->
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
NodeS = erlang:atom_to_binary(node(Pid), latin1),
case ?SQL_UPSERT(ServerHost,
"muc_online_room",
@ -188,7 +188,7 @@ register_online_room(ServerHost, Room, Host, Pid) ->
unregister_online_room(ServerHost, Room, Host, Pid) ->
%% TODO: report errors
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
NodeS = erlang:atom_to_binary(node(Pid), latin1),
ejabberd_sql:sql_query(
ServerHost,
@ -201,7 +201,7 @@ find_online_room(ServerHost, Room, Host) ->
?SQL("select @(pid)s, @(node)s from muc_online_room where "
"name=%(Room)s and host=%(Host)s")) of
{selected, [{PidS, NodeS}]} ->
try {ok, aux:decode_pid(PidS, NodeS)}
try {ok, misc:decode_pid(PidS, NodeS)}
catch _:{bad_node, _} -> error
end;
{selected, []} ->
@ -231,7 +231,7 @@ get_online_rooms(ServerHost, Host, _RSM) ->
{selected, Rows} ->
lists:flatmap(
fun({Room, PidS, NodeS}) ->
try [{Room, Host, aux:decode_pid(PidS, NodeS)}]
try [{Room, Host, misc:decode_pid(PidS, NodeS)}]
catch _:{bad_node, _} -> []
end
end, Rows);
@ -296,7 +296,7 @@ export(_Server) ->
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
case str:suffix(Host, RoomHost) of
true ->
SOpts = aux:term_to_expr(Opts),
SOpts = misc: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),
aux:ip_to_list(IP)])
misc: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, aux:ip_to_list(IP)};
{ip, misc:ip_to_list(IP)};
({hostname, IP}) when is_tuple(IP) ->
{hostname, aux:ip_to_list(IP)};
{hostname, misc: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,
aux:ip_to_list(IP)),
misc:ip_to_list(IP)),
Resource = ejabberd_cluster:node_id(),
#streamhost{jid = jid:make(<<"">>, Host, Resource),
host = HostName,

View File

@ -50,7 +50,7 @@ init() ->
end.
register_stream(SID, Pid) ->
PidS = aux:encode_pid(Pid),
PidS = misc:encode_pid(Pid),
NodeS = erlang:atom_to_binary(node(Pid), latin1),
F = fun() ->
case ejabberd_sql:sql_query_t(
@ -94,8 +94,8 @@ activate_stream(SID, IJID, MaxConnections, _Node) ->
"sid=%(SID)s")) of
{selected, [{TPidS, TNodeS, IPidS, INodeS, <<"">>}]}
when IPidS /= <<"">> ->
try {aux:decode_pid(TPidS, TNodeS),
aux:decode_pid(IPidS, INodeS)} of
try {misc:decode_pid(TPidS, TNodeS),
misc:decode_pid(IPidS, INodeS)} of
{TPid, IPid} ->
case ejabberd_sql:sql_query_t(
?SQL("update proxy65 set jid_i=%(IJID)s "

View File

@ -3439,9 +3439,9 @@ subscription_plugin(Host) ->
-spec submodule(host(), binary()) -> atom().
submodule(Host, Name) ->
case gen_mod:db_type(serverhost(Host), ?MODULE) of
mnesia -> aux:binary_to_atom(Name);
Type -> aux:binary_to_atom(<<Name/binary, "_",
(aux:atom_to_binary(Type))/binary>>)
mnesia -> misc:binary_to_atom(Name);
Type -> misc:binary_to_atom(<<Name/binary, "_",
(misc:atom_to_binary(Type))/binary>>)
end.
-spec config(binary(), any()) -> any().

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(
aux:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
misc: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) ->
aux:ip_to_list(Source);
misc: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 = aux:binary_to_atom(
ACLName = misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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(aux:ip_to_list(IP))]),
ejabberd_config:may_hide_data(misc: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 = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Eldap_ID = misc: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 = aux:term_to_expr(Opts),
SOpts = misc: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 = aux:term_to_expr(Opts),
SOpts = misc: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 = aux:term_to_expr(Opts),
SOpts = misc: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 aux:base64_to_term(ResumeID) of
case misc: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}) ->
aux:term_to_base64({Resource, Time}).
misc: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 = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?PROCNAME)),
Eldap_ID = misc: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(aux:decode_base64(BinVal)))
str:sha(misc:decode_base64(BinVal)))
end,
ejabberd_sm:force_update_presence(US).

View File

@ -652,7 +652,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}]} ->
aux:expr_to_term(Value);
misc:expr_to_term(Value);
_ ->
?MAXITEMS
end,
@ -665,7 +665,7 @@ get_items(Nidx, _From, #rsm_set{max = Max, index = IncIndex,
Before /= undefined -> {<<">">>, <<"asc">>};
true -> {<<"is not">>, <<"desc">>}
end,
SNidx = aux:i2l(Nidx),
SNidx = misc:i2l(Nidx),
I = if After /= undefined -> After;
Before /= undefined -> Before;
true -> undefined
@ -774,8 +774,8 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
end.
get_last_items(Nidx, _From, Count) ->
Limit = aux:i2l(Count),
SNidx = aux:i2l(Nidx),
Limit = misc:i2l(Count),
SNidx = misc:i2l(Nidx),
Query = fun(mssql, _) ->
ejabberd_sql:sql_query_t(
[<<"select top ">>, Limit,
@ -851,7 +851,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([aux:i2l(T1, 6), aux:i2l(T2, 6), aux:i2l(T3, 6)], <<":">>)
str:join([misc:i2l(T1, 6), misc:i2l(T2, 6), misc:i2l(T3, 6)], <<":">>)
end,
SM = S(M),
SC = S(C),
@ -877,7 +877,7 @@ del_items(Nidx, [ItemId]) ->
del_item(Nidx, ItemId);
del_items(Nidx, ItemIds) ->
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
SNidx = aux:i2l(Nidx),
SNidx = misc:i2l(Nidx),
catch
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
I, <<") and nodeid='">>, SNidx, <<"';">>]).
@ -1031,7 +1031,7 @@ raw_to_item(Nidx, {ItemId, SJID, Creation, Modification, XML}) ->
JID = decode_jid(SJID),
ToTime = fun (Str) ->
[T1, T2, T3] = str:tokens(Str, <<":">>),
{aux:l2i(T1), aux:l2i(T2), aux:l2i(T3)}
{misc:l2i(T1), misc:l2i(T2), misc: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 = aux:binary_to_atom(<<"node_",
BasePlugin = misc: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 = aux:binary_to_atom(<<"node_",
Plugin = misc: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 = aux:term_to_expr(Value),
SValue = misc: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 = aux:binary_to_atom(Key),
RKey = misc: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 = aux:binary_to_atom(<<"node_", Type/binary, "_sql">>),
Module = misc: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 = 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, <<"">>)),
storedkey = misc:hex_to_base64(proplists:get_value(<<"stored_key">>, Data, <<"">>)),
serverkey = misc:hex_to_base64(proplists:get_value(<<"server_key">>, Data, <<"">>)),
salt = misc: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 = aux:binary_to_atom(Sub)};
R#roster{subscription = misc: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, <<>>}, aux:binary_to_atom(Aff)}]
[{{U, S, <<>>}, misc: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 = aux:binary_to_atom(proplists:get_value(<<"type">>, Item, <<"none">>)),
T = misc: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, aux:binary_to_atom(V)}
subscription -> {T, misc:binary_to_atom(V)}
end
catch _:_ ->
{none, none}
end,
#listitem{type = Type,
value = Value,
action = aux:binary_to_atom(Action),
action = misc:binary_to_atom(Action),
order = erlang:trunc(Order),
match_all = MatchAll,
match_iq = MatchIQ,