acl_rule_verify(_Spec) ->
false.
invalid_syntax(Msg, Data) ->
- throw({invalid_syntax, iolist_to_binary(io_lib:format(Msg, Data))}).
+ throw({invalid_syntax, (str:format(Msg, Data))}).
acl_rules_verify([{acl, Name} | Rest], true) when is_atom(Name) ->
acl_rules_verify(Rest, true);
end.
report_error(Format, Args) ->
- throw({invalid_syntax, iolist_to_binary(io_lib:format(Format, Args))}).
+ throw({invalid_syntax, (str:format(Format, Args))}).
parse_error(Format, Args) ->
- {error, iolist_to_binary(io_lib:format(Format, Args))}.
+ {error, (str:format(Format, Args))}.
opt_type(api_permissions) ->
fun parse_api_permissions/1;
%%%
stop_kindly(DelaySeconds, AnnouncementTextString) ->
- Subject = list_to_binary(io_lib:format("Server stop in ~p seconds!", [DelaySeconds])),
- WaitingDesc = list_to_binary(io_lib:format("Waiting ~p seconds", [DelaySeconds])),
+ Subject = (str:format("Server stop in ~p seconds!", [DelaySeconds])),
+ WaitingDesc = (str:format("Waiting ~p seconds", [DelaySeconds])),
AnnouncementText = list_to_binary(AnnouncementTextString),
Steps = [
{"Stopping ejabberd port listeners",
ok.
send_service_message_all_mucs(Subject, AnnouncementText) ->
- Message = list_to_binary(
- io_lib:format("~s~n~s", [Subject, AnnouncementText])),
+ Message = str:format("~s~n~s", [Subject, AnnouncementText]),
lists:foreach(
fun(ServerHost) ->
MUCHost = gen_mod:get_module_opt_host(
true -> {AmK, <<"true">>};
false -> {AmK, <<"false">>};
I when is_integer(I), I >= 0 ->
- {AmK, iolist_to_binary(integer_to_list(I))};
+ {AmK, integer_to_binary(I)};
_ -> {AmK, V}
end;
({K, V}) -> {K, V}
BodyString1 = translate:translate(Lang,
<<"Your messages to ~s are being blocked. "
"To unblock them, visit ~s">>),
- BodyString = iolist_to_binary(io_lib:format(BodyString1,
+ BodyString = (str:format(BodyString1,
[JID, get_url(Id)])),
Body = xmpp:mk_text(BodyString, Lang),
OOB = #oob_x{url = get_url(Id)},
of
{value, _} ->
[{<<"Content-Length">>,
- iolist_to_binary(integer_to_list(byte_size(Data)))}
+ integer_to_binary(byte_size(Data))}
| Headers];
_ ->
[{<<"Content-Type">>, <<"text/html; charset=utf-8">>},
{<<"Content-Length">>,
- iolist_to_binary(integer_to_list(byte_size(Data)))}
+ integer_to_binary(byte_size(Data))}
| Headers]
end,
HeadersOut = case {State#state.request_version,
end,
HeadersOut),
SL = [Version,
- iolist_to_binary(integer_to_list(Status)), <<" ">>,
+ integer_to_binary(Status), <<" ">>,
code_to_phrase(Status), <<"\r\n">>],
Data2 = case State#state.request_method of
'HEAD' -> <<"">>;
[{<<"xmlns">>, ?NS_HTTP_BIND},
{<<"sid">>, Sid},
{<<"wait">>,
- iolist_to_binary(integer_to_list(Wait))},
+ integer_to_binary(Wait)},
{<<"requests">>,
- iolist_to_binary(integer_to_list(Hold
- +
- 1))},
+ integer_to_binary(Hold + 1)},
{<<"inactivity">>,
- iolist_to_binary(integer_to_list(trunc(MaxInactivity
- /
- 1000)))},
+ integer_to_binary(
+ trunc(MaxInactivity / 1000))},
{<<"maxpause">>,
- iolist_to_binary(integer_to_list(MaxPause))},
+ integer_to_binary(MaxPause)},
{<<"polling">>,
- iolist_to_binary(integer_to_list(trunc((?MIN_POLLING)
- /
- 1000000)))},
+ integer_to_binary(
+ trunc((?MIN_POLLING) / 1000000))},
{<<"ver">>, ?BOSH_VERSION},
{<<"from">>, From},
{<<"secure">>, <<"true">>}]
StoredKeyB64 = base64:encode(StoredKey),
ServerKeyB64 = base64:encode(ServerKey),
SaltB64 = base64:encode(Salt),
- IterationCountBin = list_to_binary(integer_to_list(IterationCount)),
+ IterationCountBin = (integer_to_binary(IterationCount)),
<<"scram:", StoredKeyB64/binary, ",", ServerKeyB64/binary, ",", SaltB64/binary, ",", IterationCountBin/binary>>.
parse_scram_password(PassData) ->
storedkey = StoredKeyB64,
serverkey = ServerKeyB64,
salt = SaltB64,
- iterationcount = list_to_integer(binary_to_list(IterationCountBin))
+ iterationcount = (binary_to_integer(IterationCountBin))
}.
-spec get_vcard(binary(), binary()) -> [xmlel()].
make_filename_template() ->
{{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
- list_to_binary(
- io_lib:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
- [Year, Month, Day, Hour, Minute, Second])).
+ str:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
+ [Year, Month, Day, Hour, Minute, Second]).
make_main_basefilename(Dir, FnT) ->
Filename2 = <<FnT/binary, ".xml">>,
<<"b_", B/binary>> ->
B;
<<"i_", B/binary>> ->
- list_to_integer(binary_to_list(B));
+ (binary_to_integer(B));
B ->
erlang:binary_to_term(B)
end].
encode_key(Bin) when is_binary(Bin) ->
<<"b_", Bin/binary>>;
encode_key(Int) when is_integer(Int) ->
- <<"i_", (list_to_binary(integer_to_list(Int)))/binary>>;
+ <<"i_", ((integer_to_binary(Int)))/binary>>;
encode_key(Term) ->
erlang:term_to_binary(Term).
ok.
make_invalid_object(Val) ->
- list_to_binary(io_lib:fwrite("Invalid object: ~p", [Val])).
+ (str:format("Invalid object: ~p", [Val])).
get_random_pid() ->
PoolPid = ejabberd_riak_sup:get_random_pid(),
Host = (?MYNAME),
JIDs = get_admin_jids(),
DetailedInfo = detailed_info(Pid),
- Body = iolist_to_binary(
- io_lib:format("(~w) The process ~w is consuming too "
- "much memory:~n~p~n~s",
- [node(), Pid, Info, DetailedInfo])),
+ Body = str:format("(~w) The process ~w is consuming too "
+ "much memory:~n~p~n~s",
+ [node(), Pid, Info, DetailedInfo]),
From = jid:make(<<"">>, Host, <<"watchdog">>),
Hint = [#hint{type = 'no-permanent-store'}],
lists:foreach(
[?XAE(<<"form">>,
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
[?TEXTAREA(<<"acls">>,
- (iolist_to_binary(integer_to_list(lists:max([16,
- NumLines])))),
+ (integer_to_binary(lists:max([16,
+ NumLines]))),
<<"80">>, <<(iolist_to_binary(ACLsP))/binary, ".">>),
?BR,
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
[?XAE(<<"form">>,
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
[?TEXTAREA(<<"access">>,
- (iolist_to_binary(integer_to_list(lists:max([16,
- NumLines])))),
+ (integer_to_binary(lists:max([16,
+ NumLines]))),
<<"80">>, <<(iolist_to_binary(AccessP))/binary, ".">>),
?BR,
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
Rs1 -> Rs1
end,
make_xhtml([?XC(<<"h1">>,
- list_to_binary(io_lib:format(
+ (str:format(
?T(<<"~s access rule configuration">>),
[SName])))]
++
%% @spec (T::any()) -> StringLine::string()
term_to_string(T) ->
StringParagraph =
- iolist_to_binary(io_lib:format("~1000000p", [T])),
+ (str:format("~1000000p", [T])),
ejabberd_regexp:greplace(StringParagraph, <<"\\n ">>,
<<"">>).
{{Year, Month, Day},
{Hour, Minute, Second}} =
calendar:now_to_local_time(TimeStamp),
- iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+ (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year,
Month,
Day,
Shift rem 1000000, 0},
{{Year, Month, Day}, {Hour, Minute, Second}} =
calendar:now_to_local_time(TimeStamp),
- iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+ (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year, Month, Day,
Hour, Minute,
Second]))
end;
_ -> ?T(<<"Online">>)
end,
- [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"User ~s">>),
+ [?XC(<<"h1">>, (str:format(?T(<<"User ~s">>),
[us_to_list(US)])))]
++
case Res of
[?XAE(<<"li">>,
[{<<"style">>,
<<"width:",
- (iolist_to_binary(integer_to_list(trunc(90 * V
- /
- Max))))/binary,
+ (integer_to_binary(trunc(90 * V / Max)))/binary,
"%;">>}],
[{xmlcdata, pretty_string_int(V)}])
|| V <- Hist ++ Tail])]
Base = get_base_path(global, Node),
MenuItems2 = make_menu_items(global, Node, Base, Lang),
[?XC(<<"h1">>,
- list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node])))]
+ (str:format(?T(<<"Node ~p">>), [Node])))]
++
case Res of
ok -> [?XREST(<<"Submitted">>)];
get_node(Host, Node, [], _Query, Lang) ->
Base = get_base_path(Host, Node),
MenuItems2 = make_menu_items(Host, Node, Base, Lang),
- [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node]))),
+ [?XC(<<"h1">>, (str:format(?T(<<"Node ~p">>), [Node]))),
?XE(<<"ul">>,
([?LI([?ACT(<<Base/binary, "modules/">>,
<<"Modules">>)])]
end,
STables),
[?XC(<<"h1">>,
- list_to_binary(io_lib:format(?T(<<"Database Tables at ~p">>),
+ (str:format(?T(<<"Database Tables at ~p">>),
[Node]))
)]
++
ok -> [?XREST(<<"Submitted">>)];
{error, Error} ->
[?XRES(<<(?T(<<"Error">>))/binary, ": ",
- (list_to_binary(io_lib:format("~p", [Error])))/binary>>)]
+ ((str:format("~p", [Error])))/binary>>)]
end,
- [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Backup of ~p">>), [Node])))]
+ [?XC(<<"h1">>, (str:format(?T(<<"Backup of ~p">>), [Node])))]
++
ResS ++
[?XCT(<<"p">>,
{'EXIT', _Reason} -> error;
{is_added, ok} -> ok;
{is_added, {error, Reason}} ->
- {error, iolist_to_binary(io_lib:format("~p", [Reason]))};
+ {error, (str:format("~p", [Reason]))};
_ -> nothing
end,
NewPorts = lists:sort(ejabberd_cluster:call(Node, ejabberd_config,
end,
NewModules = lists:sort(ejabberd_cluster:call(Node, gen_mod,
loaded_modules_with_opts, [Host])),
- H1String = list_to_binary(io_lib:format(?T(<<"Modules at ~p">>), [Node])),
+ H1String = (str:format(?T(<<"Modules at ~p">>), [Node])),
(?H1GL(H1String, <<"modulesoverview">>,
<<"Modules Overview">>))
++
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
[wall_clock]),
- UpTimeS = list_to_binary(io_lib:format("~.3f",
+ UpTimeS = (str:format("~.3f",
[element(1, UpTime) / 1000])),
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
- CPUTimeS = list_to_binary(io_lib:format("~.3f",
+ CPUTimeS = (str:format("~.3f",
[element(1, CPUTime) / 1000])),
OnlineUsers = ejabberd_sm:connected_users_number(),
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
TransactionsLogged = ejabberd_cluster:call(Node, mnesia, system_info,
[transaction_log_writes]),
[?XC(<<"h1">>,
- list_to_binary(io_lib:format(?T(<<"Statistics of ~p">>), [Node]))),
+ (str:format(?T(<<"Statistics of ~p">>), [Node]))),
?XAE(<<"table">>, [],
[?XE(<<"tbody">>,
[?XE(<<"tr">>,
(BeamsLis ++ SelectButtons))
end,
FmtScript = (?XC(<<"pre">>,
- list_to_binary(io_lib:format("~p", [Script])))),
+ (str:format("~p", [Script])))),
FmtLowLevelScript = (?XC(<<"pre">>,
- list_to_binary(io_lib:format("~p", [LowLevelScript])))),
+ (str:format("~p", [LowLevelScript])))),
[?XC(<<"h1">>,
- list_to_binary(io_lib:format(?T(<<"Update ~p">>), [Node])))]
+ (str:format(?T(<<"Update ~p">>), [Node])))]
++
case Res of
ok -> [?XREST(<<"Submitted">>)];
SModule, <<"15">>)]),
?XAE(<<"td">>, direction(ltr),
[?TEXTAREA(<<"opts", SSPort/binary>>,
- (iolist_to_binary(integer_to_list(NumLines))),
+ (integer_to_binary(NumLines)),
<<"35">>, SOptsClean)]),
?XE(<<"td">>,
[?INPUTT(<<"submit">>,
[?XC(<<"td">>, SModule),
?XAE(<<"td">>, direction(ltr),
[?TEXTAREA(<<"opts", SModule/binary>>,
- (iolist_to_binary(integer_to_list(NumLines))),
+ (integer_to_binary(NumLines)),
<<"40">>, SOpts)]),
?XE(<<"td">>,
[?INPUTT(<<"submit">>,
{ok, _} -> ok;
{error, Error} ->
?ERROR_MSG("~p~n", [Error]),
- {error, iolist_to_binary(io_lib:format("~p", [Error]))};
+ {error, (str:format("~p", [Error]))};
{badrpc, Error} ->
?ERROR_MSG("Bad RPC: ~p~n", [Error]),
{error,
- <<"Bad RPC: ", (iolist_to_binary(io_lib:format("~p", [Error])))/binary>>}
+ <<"Bad RPC: ", ((str:format("~p", [Error])))/binary>>}
end;
_ -> nothing
end.
element_to_list(X) when is_atom(X) ->
iolist_to_binary(atom_to_list(X));
element_to_list(X) when is_integer(X) ->
- iolist_to_binary(integer_to_list(X)).
+ integer_to_binary(X).
list_to_element(Bin) ->
{ok, Tokens, _} = erl_scan:string(binary_to_list(Bin)),
Element.
url_func({user_diapason, From, To}) ->
- <<(iolist_to_binary(integer_to_list(From)))/binary, "-",
- (iolist_to_binary(integer_to_list(To)))/binary, "/">>;
+ <<(integer_to_binary(From))/binary, "-",
+ (integer_to_binary(To))/binary, "/">>;
url_func({users_queue, Prefix, User, _Server}) ->
<<Prefix/binary, "user/", User/binary, "/queue/">>;
url_func({user, Prefix, User, _Server}) ->
%% Transform 1234567890 into "1,234,567,890"
pretty_string_int(Integer) when is_integer(Integer) ->
- pretty_string_int(iolist_to_binary(integer_to_list(Integer)));
+ pretty_string_int(integer_to_binary(Integer));
pretty_string_int(String) when is_binary(String) ->
{_, Result} = lists:foldl(fun (NewNumber, {3, Result}) ->
{1, <<NewNumber, $,, Result/binary>>};
%% http://xmpp.org/extensions/xep-0091.html#time
timestamp_to_legacy({{Year, Month, Day},
{Hour, Minute, Second}}) ->
- iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
+ (str:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second])).
-spec timestamp_to_iso_basic(calendar:datetime()) -> binary().
%% This is the ISO 8601 basic bormat
timestamp_to_iso_basic({{Year, Month, Day},
{Hour, Minute, Second}}) ->
- iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
+ (str:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
[Year, Month, Day, Hour, Minute, Second])).
-spec now_to_utc_string(erlang:timestamp()) -> binary().
Max ->
now_to_utc_string({MegaSecs, Secs + 1, 0}, Precision);
FracOfSec ->
- list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT"
+ (str:format("~4..0B-~2..0B-~2..0BT"
"~2..0B:~2..0B:~2..0B.~*..0BZ",
[Year, Month, Day, Hour, Minute, Second,
Precision, FracOfSec]))
end,
{{Year, Month, Day}, {Hour, Minute, Second}} =
LocalTime,
- list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
+ (str:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
".0B~s~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second,
MicroSecs, Sign, H, M])).
lists:map(fun (K) ->
L = K + M - 1,
Node = <<"@",
- (iolist_to_binary(integer_to_list(K)))/binary,
+ (integer_to_binary(K))/binary,
"-",
- (iolist_to_binary(integer_to_list(L)))/binary>>,
+ (integer_to_binary(L))/binary>>,
{FS, FU} = lists:nth(K, SUsers),
{LS, LU} = if L < N -> lists:nth(L, SUsers);
true -> lists:last(SUsers)
Host == FH orelse str:suffix(DotHost, FH)],
lists:map(
fun (T) ->
- Name = iolist_to_binary(
- io_lib:format(?T(Lang, <<"To ~s">>),[T])),
+ Name = str:format(?T(Lang, <<"To ~s">>),[T]),
#disco_item{jid = jid:make(Host),
node = <<"outgoing s2s/", T/binary>>,
name = Name}
lists:map(
fun ({F, _T}) ->
Node = <<"outgoing s2s/", To/binary, "/", F/binary>>,
- Name = iolist_to_binary(
- io_lib:format(?T(Lang, <<"From ~s">>), [F])),
+ Name = str:format(?T(Lang, <<"From ~s">>), [F]),
#disco_item{jid = jid:make(Host), node = Node, name = Name}
end,
lists:keysort(1,
label = ?T(Lang, <<"Message body">>)}]}};
get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
ACLs = str:tokens(
- iolist_to_binary(
- io_lib:format("~p.",
- [mnesia:dirty_select(
- acl,
- ets:fun2ms(
- fun({acl, {Name, H}, Spec}) when H == Host ->
- {acl, Name, Spec}
- end))])),
+ str:format("~p.",
+ [mnesia:dirty_select(
+ acl,
+ ets:fun2ms(
+ fun({acl, {Name, H}, Spec}) when H == Host ->
+ {acl, Name, Spec}
+ end))]),
<<"\n">>),
{result,
#xdata{title = ?T(Lang, <<"Access Control List Configuration">>),
values = ACLs}]}};
get_form(Host, [<<"config">>, <<"access">>], Lang) ->
Accs = str:tokens(
- iolist_to_binary(
- io_lib:format("~p.",
- [mnesia:dirty_select(
- access,
- ets:fun2ms(
- fun({access, {Name, H}, Acc}) when H == Host ->
- {access, Name, Acc}
- end))])),
+ str:format("~p.",
+ [mnesia:dirty_select(
+ access,
+ ets:fun2ms(
+ fun({access, {Name, H}, Acc}) when H == Host ->
+ {access, Name, Acc}
+ end))]),
<<"\n">>),
{result,
#xdata{title = ?T(Lang, <<"Access Configuration">>),
required = true}]}};
get_form(Host,
?NS_ADMINL(<<"get-registered-users-num">>), Lang) ->
- Num = list_to_binary(
- io_lib:format("~p",
- [ejabberd_auth:get_vh_registered_users_number(Host)])),
+ Num = integer_to_binary(ejabberd_auth:get_vh_registered_users_number(Host)),
{result, completed,
#xdata{type = form,
fields = [?HFIELD(),
values = [Num]}]}};
get_form(Host, ?NS_ADMINL(<<"get-online-users-num">>),
Lang) ->
- Num = list_to_binary(
- io_lib:format("~p",
- [length(ejabberd_sm:get_vh_session_list(Host))])),
+ Num = integer_to_binary(ejabberd_sm:get_vh_session_number(Host)),
{result, completed,
#xdata{type = form,
fields = [?HFIELD(),
TimeStamp = {Shift div 1000000, Shift rem 1000000, 0},
{{Year, Month, Day}, {Hour, Minute, Second}} =
calendar:now_to_local_time(TimeStamp),
- iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+ (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year, Month, Day, Hour,
Minute, Second]))
end;
var = <<"username">>,
values = [Username]},
#xdata_field{type = fixed,
- values = [iolist_to_binary(
- io_lib:format(
- translate:translate(
- Lang,
- <<"If you want to specify"
- " different ports, "
- "passwords, encodings "
- "for IRC servers, "
- "fill this list with "
- "values in format "
- "'{\"irc server\", "
- "\"encoding\", port, "
- "\"password\"}'. "
- "By default this "
- "service use \"~s\" "
- "encoding, port ~p, "
- "empty password.">>),
- [DefaultEncoding, ?DEFAULT_IRC_PORT]))]},
+ values = [str:format(
+ translate:translate(
+ Lang,
+ <<"If you want to specify"
+ " different ports, "
+ "passwords, encodings "
+ "for IRC servers, "
+ "fill this list with "
+ "values in format "
+ "'{\"irc server\", "
+ "\"encoding\", port, "
+ "\"password\"}'. "
+ "By default this "
+ "service use \"~s\" "
+ "encoding, port ~p, "
+ "empty password.">>),
+ [DefaultEncoding, ?DEFAULT_IRC_PORT])]},
#xdata_field{type = fixed,
values = [translate:translate(
Lang,
label = translate:translate(
Lang, <<"Connections parameters">>),
var = <<"connections_params">>,
- values = str:tokens(list_to_binary(
- io_lib:format(
- "~p.",
- [conn_params_to_list(
- ConnectionsParams)])),
+ values = str:tokens(str:format(
+ "~p.",
+ [conn_params_to_list(
+ ConnectionsParams)]),
<<"\n">>)}],
X = #xdata{type = form,
title = <<(translate:translate(
RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>,
To#jid.server),
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
- Body = iolist_to_binary(
- io_lib:format(
- translate:translate(
- Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
- [jid:to_string(RoomJID)])),
+ Body = str:format(
+ translate:translate(
+ Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
+ [jid:to_string(RoomJID)]),
Invite = #message{
body = xmpp:mk_text(Body, Lang),
sub_els = [#muc_user{
Port;
true -> ?DEFAULT_IRC_PORT
end,
- PortUsed =
- iolist_to_binary(integer_to_list(PortUsedInt)),
+ PortUsed = integer_to_binary(PortUsedInt),
PasswordUsed = case Password of
<<>> -> <<>>;
_ -> Password
end,
- NumberString =
- iolist_to_binary(integer_to_list(Number)),
+ NumberString = integer_to_binary(Number),
[#xdata_field{var = <<"password", NumberString/binary>>,
type = 'text-single',
- label = iolist_to_binary(
- io_lib:format(
- translate:translate(Lang, <<"Password ~b">>),
- [Number])),
+ label = str:format(
+ translate:translate(Lang, <<"Password ~b">>),
+ [Number]),
values = [PasswordUsed]},
#xdata_field{var = <<"port", NumberString/binary>>,
type = 'text-single',
- label = iolist_to_binary(
- io_lib:format(
- translate:translate(Lang, <<"Port ~b">>),
- [Number])),
+ label = str:format(
+ translate:translate(Lang, <<"Port ~b">>),
+ [Number]),
values = [PortUsed]},
#xdata_field{var = <<"encoding", NumberString/binary>>,
type = 'list-single',
- label = list_to_binary(
- io_lib:format(
- translate:translate(Lang, <<"Encoding for server ~b">>),
- [Number])),
+ label = str:format(
+ translate:translate(Lang, <<"Encoding for server ~b">>),
+ [Number]),
values = [EncodingUsed],
options = [#xdata_option{label = E, value = E}
|| E <- ?POSSIBLE_ENCODINGS]},
#xdata_field{var = <<"server", NumberString/binary>>,
type = 'text-single',
- label = list_to_binary(
- io_lib:format(
- translate:translate(Lang, <<"Server ~b">>),
- [Number])),
+ label = str:format(
+ translate:translate(Lang, <<"Server ~b">>),
+ [Number]),
values = [Server]}].
parse_connections_params(#xdata{fields = Fields}) ->
{0, 0, 0}}),
{{Year, Month, Day}, {Hour, Minute, Second}} =
calendar:universal_time_to_local_time(calendar:gregorian_seconds_to_datetime(Secs)),
- iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
+ (str:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
[Year, Month, Day, Hour, Minute, Second])).
{Dir, Filename, Rel} = case DirType of
subdirs ->
SYear =
- iolist_to_binary(io_lib:format("~4..0w",
+ (str:format("~4..0w",
[Year])),
SMonth =
- iolist_to_binary(io_lib:format("~2..0w",
+ (str:format("~2..0w",
[Month])),
- SDay = iolist_to_binary(io_lib:format("~2..0w",
+ SDay = (str:format("~2..0w",
[Day])),
{fjoin([SYear, SMonth]), SDay,
<<"../..">>};
plain ->
Date =
- iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w",
+ (str:format("~4..0w-~2..0w-~2..0w",
[Year,
Month,
Day])),
fw(F, S, [], FileFormat).
fw(F, S, O, FileFormat) ->
- S1 = list_to_binary(io_lib:format(binary_to_list(S) ++ "~n", O)),
+ S1 = (str:format(binary_to_list(S) ++ "~n", O)),
S2 = case FileFormat of
html ->
S1;
Hdrs = get_messages_subset(US, Server, HdrsAll),
FMsgs = format_user_queue(Hdrs),
[?XC(<<"h1">>,
- list_to_binary(io_lib:format(?T(<<"~s's Offline Messages Queue">>),
+ (str:format(?T(<<"~s's Offline Messages Queue">>),
[us_to_list(US)])))]
++
case Res of
QueueLen = count_offline_messages(jid:nodeprep(User),
jid:nameprep(Server)),
FQueueLen = [?AC(<<"queue/">>,
- (iolist_to_binary(integer_to_list(QueueLen))))],
+ (integer_to_binary(QueueLen)))],
Acc ++
[?XCT(<<"h3">>, <<"Offline Messages:">>)] ++
FQueueLen ++
-spec uniqid() -> mod_pubsub:itemId().
uniqid() ->
{T1, T2, T3} = p1_time_compat:timestamp(),
- iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+ (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
-spec itemsEls([#pubsub_item{}]) -> [ps_item()].
itemsEls(Items) ->
[] -> ok;
JIDs when is_list(JIDs) ->
Body =
- iolist_to_binary(io_lib:format("[~s] The account ~s was registered from "
+ (str:format("[~s] The account ~s was registered from "
"IP address ~s on node ~w using ~p.",
[get_time_string(),
jid:to_string(UJID),
case need_record_route(LServer) of
true ->
RR_URI = get_configured_record_route(LServer),
- TS = list_to_binary(integer_to_list(p1_time_compat:system_time(seconds))),
+ TS = (integer_to_binary(p1_time_compat:system_time(seconds))),
Sign = make_sign(TS, Hdrs),
User = <<TS/binary, $-, Sign/binary>>,
NewRR_URI = RR_URI#uri{user = User},
is_signed_by_me(TS_Sign, Hdrs) ->
try
[TSBin, Sign] = str:tokens(TS_Sign, <<"-">>),
- TS = list_to_integer(binary_to_list(TSBin)),
+ TS = (binary_to_integer(TSBin)),
NowTS = p1_time_compat:system_time(seconds),
true = (NowTS - TS) =< ?SIGN_LIFETIME,
Sign == make_sign(TSBin, Hdrs)
60.
to_integer(Bin, Min, Max) ->
- case catch list_to_integer(binary_to_list(Bin)) of
+ case catch (binary_to_integer(Bin)) of
N when N >= Min, N =< Max ->
{ok, N};
_ ->
{'EXIT', _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Users ->
- ?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
+ ?STATVAL((integer_to_binary(length(Users))),
<<"users">>)
end;
get_local_stat(Server, [], Name)
{'EXIT', _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
NUsers ->
- ?STATVAL((iolist_to_binary(integer_to_list(NUsers))),
+ ?STATVAL((integer_to_binary(NUsers)),
<<"users">>)
end;
get_local_stat(_Server, [], Name)
when Name == <<"users/all-hosts/online">> ->
Users = ejabberd_sm:connected_users_number(),
- ?STATVAL((iolist_to_binary(integer_to_list(Users))), <<"users">>);
+ ?STATVAL((integer_to_binary(Users)), <<"users">>);
get_local_stat(_Server, [], Name)
when Name == <<"users/all-hosts/total">> ->
NumUsers = lists:foldl(fun (Host, Total) ->
+ Total
end,
0, ?MYHOSTS),
- ?STATVAL((iolist_to_binary(integer_to_list(NumUsers))),
+ ?STATVAL((integer_to_binary(NumUsers)),
<<"users">>);
get_local_stat(_Server, _, Name) ->
?STATERR(404, <<"Not Found">>).
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
CPUTime ->
- ?STATVAL(list_to_binary(
- io_lib:format("~.3f",
- [element(1, CPUTime) / 1000])),
+ ?STATVAL(str:format("~.3f", [element(1, CPUTime) / 1000]),
<<"seconds">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
RunTime ->
- ?STATVAL(list_to_binary(
- io_lib:format("~.3f",
- [element(1, RunTime) / 1000])),
+ ?STATVAL(str:format("~.3f", [element(1, RunTime) / 1000]),
<<"seconds">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Users ->
- ?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
+ ?STATVAL((integer_to_binary(length(Users))),
<<"users">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Transactions ->
- ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+ ?STATVAL((integer_to_binary(Transactions)),
<<"transactions">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Transactions ->
- ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+ ?STATVAL((integer_to_binary(Transactions)),
<<"transactions">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Transactions ->
- ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+ ?STATVAL((integer_to_binary(Transactions)),
<<"transactions">>)
end;
get_node_stat(Node, Name)
{badrpc, _Reason} ->
?STATERR(500, <<"Internal Server Error">>);
Transactions ->
- ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+ ?STATVAL((integer_to_binary(Transactions)),
<<"transactions">>)
end;
get_node_stat(_, Name) ->
OSType = list_to_binary([atom_to_list(Osfamily), $/, atom_to_list(Osname)]),
OSVersion = case os:version() of
{Major, Minor, Release} ->
- iolist_to_binary(io_lib:format("~w.~w.~w",
+ (str:format("~w.~w.~w",
[Major, Minor, Release]));
VersionString -> VersionString
end,
N -> integer_to_sql(N)
end}.
-integer_to_sql(N) -> iolist_to_binary(integer_to_list(N)).
+integer_to_sql(N) -> integer_to_binary(N).
boolean_to_sql(true) -> <<"1">>;
boolean_to_sql(false) -> <<"0">>.
-spec make_subid() -> SubId::mod_pubsub:subId().
make_subid() ->
{T1, T2, T3} = p1_time_compat:timestamp(),
- iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+ (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
%%
%% Subscription XForm processing.
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end;
val_xfield(expire = Opt, [Val]) ->
try xmpp_util:decode_timestamp(Val)
catch _:{bad_timestamp, _} ->
Txt = <<"Value of '~s' should be datetime string">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end;
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end.
xopt_to_bool(_, <<"true">>) -> true;
xopt_to_bool(Option, _) ->
Txt = <<"Value of '~s' should be boolean">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
+ ErrTxt = (str:format(Txt, [Option])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
%% Return a field for an XForm for Key, with data filled in, if
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
%xfield_val(digest_frequency, Val) ->
-% [iolist_to_binary(integer_to_list(Val))];
+% [integer_to_binary(Val))];
%xfield_val(expire, Val) ->
% [jlib:now_to_utc_string(Val)];
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
xfield_val(subscription_depth, all) -> [<<"all">>];
xfield_val(subscription_depth, N) ->
- [iolist_to_binary(integer_to_list(N))].
+ [integer_to_binary(N)].
bool_to_xopt(true) -> <<"true">>;
-spec make_subid() -> mod_pubsub:subId().
make_subid() ->
{T1, T2, T3} = p1_time_compat:timestamp(),
- iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+ (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
%%
%% Subscription XForm processing.
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end;
val_xfield(expire = Opt, [Val]) ->
try xmpp_util:decode_timestamp(Val)
catch _:{bad_timestamp, _} ->
Txt = <<"Value of '~s' should be datetime string">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end;
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+ ErrTxt = (str:format(Txt, [Opt])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end.
xopt_to_bool(_, <<"true">>) -> true;
xopt_to_bool(Option, _) ->
Txt = <<"Value of '~s' should be boolean">>,
- ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
+ ErrTxt = (str:format(Txt, [Option])),
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
%% Return a field for an XForm for Key, with data filled in, if
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
%xfield_val(digest_frequency, Val) ->
-% [iolist_to_binary(integer_to_list(Val))];
+% [integer_to_binary(Val))];
%xfield_val(expire, Val) ->
% [jlib:now_to_utc_string(Val)];
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
xfield_val(subscription_depth, all) -> [<<"all">>];
xfield_val(subscription_depth, N) ->
- [iolist_to_binary(integer_to_list(N))].
+ [integer_to_binary(N)].
bool_to_xopt(false) -> <<"false">>;
bool_to_xopt(true) -> <<"true">>.