mech_step(#state{server = Server} = S, ClientIn) ->
User = iolist_to_binary([randoms:get_string(),
- jlib:integer_to_binary(p1_time_compat:unique_integer([positive]))]),
+ integer_to_binary(p1_time_compat:unique_integer([positive]))]),
case ejabberd_auth:is_user_exists(User, Server) of
true -> mech_step(S, ClientIn);
false -> {ok, [{username, User}, {authzid, User}, {auth_module, ejabberd_auth_anonymous}]}
-spec new_uniq_id() -> binary().
new_uniq_id() ->
iolist_to_binary([randoms:get_string(),
- jlib:integer_to_binary(p1_time_compat:unique_integer([positive]))]).
+ integer_to_binary(p1_time_compat:unique_integer([positive]))]).
-spec get_conn_type(state()) -> c2s | c2s_tls | c2s_compressed | websocket |
c2s_compressed_tls | http_bind.
end.
get_transfer_protocol(PortString) ->
- PortNumber = jlib:binary_to_integer(PortString),
+ PortNumber = binary_to_integer(PortString),
PortListeners = get_port_listeners(PortNumber),
get_captcha_transfer_protocol(PortListeners).
-define(SPAN(N, V), ?TAG_R(span, ??N, V)).
-define(STR(A), ?SPAN(str,[<<"\"">>, A, <<"\"">>])).
--define(NUM(A), ?SPAN(num,jlib:integer_to_binary(A))).
+-define(NUM(A), ?SPAN(num,integer_to_binary(A))).
-define(FIELD(A), ?SPAN(field,A)).
-define(ID(A), ?SPAN(id,A)).
-define(OP(A), ?SPAN(op,A)).
[?XML(member, Indent,
[?XML_L(name, Indent, 1, ?ID_A(Name)),
?XML(value, Indent, 1,
- [?XML_L(integer, Indent, 2, ?ID(jlib:integer_to_binary(Int)))])])];
+ [?XML_L(integer, Indent, 2, ?ID(integer_to_binary(Int)))])])];
xml_gen({Name, string}, Str, Indent, HTMLOutput) ->
[?XML(member, Indent,
[?XML_L(name, Indent, 1, ?ID_A(Name)),
request_headers = add_header(Name, Auth, State)};
{ok,
{http_header, _, 'Content-Length' = Name, _, SLen}} ->
- case catch jlib:binary_to_integer(SLen) of
+ case catch binary_to_integer(SLen) of
Len when is_integer(Len) ->
State#state{request_content_length = Len,
request_headers = add_header(Name, SLen, State)};
case {SockMod, PortList} of
{gen_tcp, []} -> {Host, 80, http};
{gen_tcp, [Port]} ->
- {Host, jlib:binary_to_integer(Port), http};
+ {Host, binary_to_integer(Port), http};
{fast_tls, []} -> {Host, 443, https};
{fast_tls, [Port]} ->
- {Host, jlib:binary_to_integer(Port), https}
+ {Host, binary_to_integer(Port), https}
end.
%% XXX bard: search through request handlers looking for one that
of
{value, _} ->
[{<<"Content-Length">>,
- jlib:integer_to_binary(byte_size(Data))}
+ integer_to_binary(byte_size(Data))}
| Headers];
_ ->
[{<<"Content-Type">>, <<"text/html; charset=utf-8">>},
{<<"Content-Length">>,
- jlib:integer_to_binary(byte_size(Data))}
+ integer_to_binary(byte_size(Data))}
| Headers]
end,
HeadersOut = case {State#state.request_version,
_ -> Reason
end,
SL = [Version,
- jlib:integer_to_binary(Status), <<" ">>,
+ integer_to_binary(Status), <<" ">>,
NewReason, <<"\r\n">>],
Data2 = case State#state.request_method of
'HEAD' -> <<"">>;
%% We did not miss any packet, we can process it immediately:
NewRid == OldRid + 1 ->
case catch
- jlib:binary_to_integer(fxml:get_attr_s(<<"pause">>,
+ binary_to_integer(fxml:get_attr_s(<<"pause">>,
Attrs))
of
{'EXIT', _} -> {true, 0};
if Xmlns /= (?NS_HTTP_BIND) -> {error, bad_request};
true ->
case catch
- jlib:binary_to_integer(fxml:get_attr_s(<<"rid">>,
+ binary_to_integer(fxml:get_attr_s(<<"rid">>,
Attrs))
of
{'EXIT', _} -> {error, bad_request};
{MSec, Sec, USec}.
dec_priority(Prio) ->
- case catch jlib:binary_to_integer(Prio) of
+ case catch binary_to_integer(Prio) of
{'EXIT', _} ->
undefined;
Int ->
enc_priority(undefined) ->
<<"">>;
enc_priority(Int) when is_integer(Int) ->
- jlib:integer_to_binary(Int).
+ integer_to_binary(Int).
row_to_session(LServer, {USec, PidS, User, Resource, PrioS, InfoS}) ->
Now = timestamp_to_now(USec),
sqlite_to_odbc(_Host, [{columns, Columns}, {rows, TRows}]) ->
Rows = [lists:map(
fun(I) when is_integer(I) ->
- jlib:integer_to_binary(I);
+ integer_to_binary(I);
(B) ->
B
end, tuple_to_list(Row)) || Row <- TRows],
{selected, [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc(<<"INSERT ", OIDN/binary>>) ->
[_OID, N] = str:tokens(OIDN, <<" ">>),
- {updated, jlib:binary_to_integer(N)};
+ {updated, binary_to_integer(N)};
pgsql_item_to_odbc(<<"DELETE ", N/binary>>) ->
- {updated, jlib:binary_to_integer(N)};
+ {updated, binary_to_integer(N)};
pgsql_item_to_odbc(<<"UPDATE ", N/binary>>) ->
- {updated, jlib:binary_to_integer(N)};
+ {updated, binary_to_integer(N)};
pgsql_item_to_odbc({error, Error}) -> {error, Error};
pgsql_item_to_odbc(_) -> {updated, undefined}.
to_odbc({selected, Columns, Recs}) ->
Rows = [lists:map(
fun(I) when is_integer(I) ->
- jlib:integer_to_binary(I);
+ integer_to_binary(I);
(B) ->
B
end, Row) || Row <- Recs],
process_command2([<<"setlh">>, SNode, NewValueString],
From, To) ->
Node = jlib:binary_to_atom(SNode),
- NewValue = jlib:binary_to_integer(NewValueString),
+ NewValue = binary_to_integer(NewValueString),
remote_command(Node, [setlh, NewValue], From, To);
process_command2([<<"help">>], From, To) ->
send_message(To, From, help());
Users = ejabberd_auth:get_vh_registered_users(Host),
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
[S1, S2] = ejabberd_regexp:split(Diap, <<"-">>),
- N1 = jlib:binary_to_integer(S1),
- N2 = jlib:binary_to_integer(S2),
+ N1 = binary_to_integer(S1),
+ N2 = binary_to_integer(S2),
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
[list_given_users(Host, Sub, <<"../../">>, Lang,
URLFunc)].
"://",
(jlib:ip_to_list(IP))/binary,
":",
- (jlib:integer_to_binary(Port))/binary,
+ (integer_to_binary(Port))/binary,
"#",
(jlib:atom_to_binary(Node))/binary>>
end,
get_port_data(PortIP, Opts) ->
{Port, IPT, IPS, _IPV, NetProt, OptsClean} =
ejabberd_listener:parse_listener_portip(PortIP, Opts),
- SPort = jlib:integer_to_binary(Port),
+ SPort = integer_to_binary(Port),
SSPort = list_to_binary(
lists:map(fun (N) ->
io_lib:format("~.16b", [N])
TimeStamp = fxml:get_attr_s(<<"last">>, Attrs),
Status = fxml:get_tag_cdata(El),
catch mod_last:store_last_info(User, Server,
- jlib:binary_to_integer(TimeStamp),
+ binary_to_integer(TimeStamp),
Status),
ok;
?NS_VCARD ->
{resourceprep, 1},
{jid_tolower, 1},
{jid_remove_resource, 1},
- {jid_replace_resource, 2}]).
+ {jid_replace_resource, 2},
+ {integer_to_binary, 1},
+ {binary_to_integer, 1}]).
-include("ejabberd.hrl").
-include("jlib.hrl").
import(_LServer, {sql, _}, _DBType, <<"caps_features">>,
[Node, SubNode, Feature, _TimeStamp]) ->
- Feature1 = case catch jlib:binary_to_integer(Feature) of
+ Feature1 = case catch binary_to_integer(Feature) of
I when is_integer(I), I>0 -> I;
_ -> Feature
end,
?SQL("select @(feature)s from caps_features where"
" node=%(Node)s and subnode=%(SubNode)s")) of
{selected, [{H}|_] = Fs} ->
- case catch jlib:binary_to_integer(H) of
+ case catch binary_to_integer(H) of
Int when is_integer(Int), Int>=0 ->
{ok, Int};
_ ->
%%%===================================================================
sql_write_features_t({Node, SubNode}, Features) ->
NewFeatures = if is_integer(Features) ->
- [jlib:integer_to_binary(Features)];
+ [integer_to_binary(Features)];
true ->
Features
end,
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
try
[S1, S2] = ejabberd_regexp:split(Diap, <<"-">>),
- N1 = jlib:binary_to_integer(S1),
- N2 = jlib:binary_to_integer(S2),
+ N1 = binary_to_integer(S1),
+ N2 = binary_to_integer(S2),
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
{result, lists:map(
fun({S, U}) ->
IPs1 = [ejabberd_sm:get_user_ip(User, Server, Resource)
|| Resource <- Resources],
IPs = [<<(jlib:ip_to_list(IP))/binary, ":",
- (jlib:integer_to_binary(Port))/binary>>
+ (integer_to_binary(Port))/binary>>
|| {IP, Port} <- IPs1],
Items = ejabberd_hooks:run_fold(roster_get, Server, [],
[{User, Server}]),
- Rostersize = jlib:integer_to_binary(erlang:length(Items)),
+ Rostersize = integer_to_binary(erlang:length(Items)),
{result,
#xdata{type = form,
fields = [?HFIELD(),
end.
stop_node(From, Host, ENode, Action, XData) ->
- Delay = jlib:binary_to_integer(get_value(<<"delay">>, XData)),
+ Delay = binary_to_integer(get_value(<<"delay">>, XData)),
Subject = case get_value(<<"subject">>, XData) of
<<"">> ->
[];
get_api_version(#request{path = Path}) ->
get_api_version(lists:reverse(Path));
get_api_version([<<"v", String/binary>> | Tail]) ->
- case catch jlib:binary_to_integer(String) of
+ case catch binary_to_integer(String) of
N when is_integer(N) ->
N;
_ ->
-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(STR_TO_INT(Str, B), jlib:binary_to_integer(iolist_to_binary(Str), B)).
+-define(STR_TO_INT(Str, B), binary_to_integer(iolist_to_binary(Str), B)).
-define(DEFAULT_CONTENT_TYPE, <<"application/octet-stream">>).
-define(CONTENT_TYPES,
[{<<".avi">>, <<"video/avi">>},
create_slot(#state{service_url = undefined, max_size = MaxSize},
JID, File, Size, _ContentType, Lang) when MaxSize /= infinity,
Size > MaxSize ->
- Text = <<"File larger than ", (jlib:integer_to_binary(MaxSize))/binary,
+ Text = <<"File larger than ", (integer_to_binary(MaxSize))/binary,
" Bytes.">>,
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
[File, jid:to_string(JID), Size]),
Lang) ->
Options = [{body_format, binary}, {full_result, false}],
HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}],
- SizeStr = jlib:integer_to_binary(Size),
+ SizeStr = integer_to_binary(Size),
GetRequest = binary_to_list(ServiceURL) ++
"?jid=" ++ ?URL_ENC(jid:to_string({U, S, <<"">>})) ++
"&name=" ++ ?URL_ENC(File) ++
infinity ->
AddInfo;
MaxSize ->
- MaxSizeStr = jlib:integer_to_binary(MaxSize),
+ MaxSizeStr = integer_to_binary(MaxSize),
Fields = [#xdata_field{type = hidden,
var = <<"FORM_TYPE">>,
values = [?NS_HTTP_UPLOAD]},
[{<<"select username, seconds, state from last">>,
fun([LUser, TimeStamp, State]) ->
#last_activity{us = {LUser, LServer},
- timestamp = jlib:binary_to_integer(
+ timestamp = binary_to_integer(
TimeStamp),
status = State}
end}].
_ ->
LPeer = {PUser, PServer, _} = jid:tolower(Peer),
TS = p1_time_compat:timestamp(),
- ID = jlib:integer_to_binary(now_to_usec(TS)),
+ ID = integer_to_binary(now_to_usec(TS)),
F = fun() ->
mnesia:write(
#archive_msg{us = {LUser, LServer},
Result = {lists:map(
fun(Msg) ->
{Msg#archive_msg.id,
- jlib:binary_to_integer(Msg#archive_msg.id),
+ binary_to_integer(Msg#archive_msg.id),
mod_mam:msg_to_el(Msg, MsgType, JidRequestor,
JidArchive)}
end, FilteredMsgs), IsComplete, Count},
store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir) ->
TSinteger = p1_time_compat:system_time(micro_seconds),
- ID = jlib:integer_to_binary(TSinteger),
+ ID = integer_to_binary(TSinteger),
SUser = case Type of
chat -> LUser;
groupchat -> jid:to_string({LUser, LHost, <<>>})
fun([TS, XML, PeerBin, Kind, Nick]) ->
try
#xmlel{} = El = fxml_stream:parse_element(XML),
- Now = usec_to_now(jlib:binary_to_integer(TS)),
+ Now = usec_to_now(binary_to_integer(TS)),
PeerJid = jid:tolower(jid:from_string(PeerBin)),
T = case Kind of
<<"">> -> chat;
null -> chat;
_ -> jlib:binary_to_atom(Kind)
end,
- [{TS, jlib:binary_to_integer(TS),
+ [{TS, binary_to_integer(TS),
mod_mam:msg_to_el(#archive_msg{timestamp = Now,
packet = El,
type = T,
[Err, TS, XML, PeerBin, Kind, Nick]),
[]
end
- end, Res1), IsComplete, jlib:binary_to_integer(Count)};
+ end, Res1), IsComplete, binary_to_integer(Count)};
_ ->
{[], false, 0}
end.
_ -> fun ejabberd_sql:escape/1
end,
LimitClause = if is_integer(Max), Max >= 0, ODBCType /= mssql ->
- [<<" limit ">>, jlib:integer_to_binary(Max+1)];
+ [<<" limit ">>, integer_to_binary(Max+1)];
true ->
[]
end,
TopClause = if is_integer(Max), Max >= 0, ODBCType == mssql ->
- [<<" TOP ">>, jlib:integer_to_binary(Max+1)];
+ [<<" TOP ">>, integer_to_binary(Max+1)];
true ->
[]
end,
_ ->
[]
end,
- PageClause = case catch jlib:binary_to_integer(ID) of
+ PageClause = case catch binary_to_integer(ID) of
I when is_integer(I), I >= 0 ->
case Direction of
before ->
StartClause = case Start of
{_, _, _} ->
[<<" and timestamp >= ">>,
- jlib:integer_to_binary(now_to_usec(Start))];
+ integer_to_binary(now_to_usec(Start))];
_ ->
[]
end,
EndClause = case End of
{_, _, _} ->
[<<" and timestamp <= ">>,
- jlib:integer_to_binary(now_to_usec(End))];
+ integer_to_binary(now_to_usec(End))];
_ ->
[]
end,
password -> ValueString;
subject ->ValueString;
subject_author ->ValueString;
- max_users -> jlib:binary_to_integer(ValueString);
+ max_users -> binary_to_integer(ValueString);
_ -> jlib:binary_to_atom(ValueString)
end,
change_room_option(Name, Service, Option, Value).
([xdata()], jid(), jid(), binary(), binary()) -> [xdata()].
get_info(_Acc, #jid{luser = U, lserver = S, lresource = R},
#jid{luser = U, lserver = S}, ?NS_FLEX_OFFLINE, _Lang) ->
- N = jlib:integer_to_binary(count_offline_messages(U, S)),
+ N = integer_to_binary(count_offline_messages(U, S)),
case ejabberd_sm:get_session_pid(U, S, R) of
Pid when is_pid(Pid) ->
Pid ! dont_ask_offline;
[<<"select id from privacy_list order by "
"id desc limit 1;">>]) of
{selected, [<<"id">>], [[I]]} ->
- put(id, jlib:binary_to_integer(I));
+ put(id, binary_to_integer(I));
_ ->
put(id, 0)
end,
-define(INTEGER_CONFIG_FIELD(Label, Var),
?STRINGXFIELD(Label,
<<"pubsub#", (atom_to_binary(Var, latin1))/binary>>,
- (jlib:integer_to_binary(get_option(Options, Var))))).
+ (integer_to_binary(get_option(Options, Var))))).
-define(JLIST_CONFIG_FIELD(Label, Var, Opts),
?LISTXFIELD(Label,
set_xoption(Host, Opts, add_opt(Opt, Val, NewOpts))).
-define(SET_INTEGER_XOPT(Opt, Val, Min, Max),
- case catch jlib:binary_to_integer(Val) of
+ case catch binary_to_integer(Val) of
IVal when is_integer(IVal), IVal >= Min ->
if (Max =:= undefined) orelse (IVal =< Max) ->
set_xoption(Host, Opts, add_opt(Opt, IVal, NewOpts));
[?XCT(<<"td">>, <<"Description:">>),
?XE(<<"td">>,
[?TEXTAREA(<<"description">>,
- jlib:integer_to_binary(lists:max([3,
+ integer_to_binary(lists:max([3,
DescNL])),
<<"20">>, Description)])]),
?XE(<<"tr">>,
[?XCT(<<"td">>, <<"Members:">>),
?XE(<<"td">>,
[?TEXTAREA(<<"members">>,
- jlib:integer_to_binary(lists:max([3,
+ integer_to_binary(lists:max([3,
byte_size(FMembers)])),
<<"20">>, FMembers)])]),
?XE(<<"tr">>,
[?XCT(<<"td">>, <<"Displayed Groups:">>),
?XE(<<"td">>,
[?TEXTAREA(<<"dispgroups">>,
- jlib:integer_to_binary(lists:max([3, length(FDisplayedGroups)])),
+ integer_to_binary(lists:max([3, length(FDisplayedGroups)])),
<<"20">>,
list_to_binary(FDisplayedGroups))])])])])),
(?H1GL((?T(<<"Shared Roster Groups">>)),
infinity ->
<<"">>;
Val ->
- [<<" LIMIT ">>, jlib:integer_to_binary(Val)]
+ [<<" LIMIT ">>, integer_to_binary(Val)]
end,
case catch ejabberd_sql:sql_query(
LServer,
timestamp_to_sql(T) -> jlib:now_to_utc_string(T).
-sql_to_integer(N) -> jlib:binary_to_integer(N).
+sql_to_integer(N) -> binary_to_integer(N).
sql_to_boolean(B) -> B == <<"1">>.
val_xfield(deliver = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(digest = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(digest_frequency = Opt, [Val]) ->
- case catch jlib:binary_to_integer(Val) of
+ case catch binary_to_integer(Val) of
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
val_xfield(subscription_type, [<<"nodes">>]) -> nodes;
val_xfield(subscription_depth, [<<"all">>]) -> all;
val_xfield(subscription_depth = Opt, [Depth]) ->
- case catch jlib:binary_to_integer(Depth) of
+ case catch binary_to_integer(Depth) of
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
val_xfield(deliver = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(digest = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(digest_frequency = Opt, [Val]) ->
- case catch jlib:binary_to_integer(Val) of
+ case catch binary_to_integer(Val) of
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
val_xfield(subscription_type, [<<"nodes">>]) -> nodes;
val_xfield(subscription_depth, [<<"all">>]) -> all;
val_xfield(subscription_depth = Opt, [Depth]) ->
- case catch jlib:binary_to_integer(Depth) of
+ case catch binary_to_integer(Depth) of
N when is_integer(N) -> N;
_ ->
Txt = <<"Value of '~s' should be integer">>,
get_string() ->
R = crypto:rand_uniform(0, 16#10000000000000000),
- jlib:integer_to_binary(R).
+ integer_to_binary(R).
dec_tzo(Val) ->
[H1, M1] = str:tokens(Val, <<":">>),
- H = jlib:binary_to_integer(H1),
- M = jlib:binary_to_integer(M1),
+ H = binary_to_integer(H1),
+ M = binary_to_integer(M1),
if H >= -12, H =< 12, M >= 0, M < 60 -> {H, M} end.
decode_thumbnail(__TopXMLNS, __IgnoreEls,
-spec dec_tzo(_) -> {integer(), integer()}.
dec_tzo(Val) ->
[H1, M1] = str:tokens(Val, <<":">>),
- H = jlib:binary_to_integer(H1),
- M = jlib:binary_to_integer(M1),
+ H = binary_to_integer(H1),
+ M = binary_to_integer(M1),
if H >= -12, H =< 12, M >= 0, M < 60 ->
{H, M}
end.