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

Replace TYPE/1 with is_TYPE/1 (EJAB-922)

SVN Revision: 2057
This commit is contained in:
Badlop 2009-05-06 16:54:43 +00:00
parent 69349925a3
commit 1d3947c0da
11 changed files with 59 additions and 48 deletions

View File

@ -1,5 +1,16 @@
2009-05-06 Badlop <badlop@process-one.net>
* src/ejabberd_c2s.erl: Replace TYPE/1 with is_TYPE/1 (EJAB-922)
* src/ejabberd_logger_h.erl:
* src/ejabberd_s2s.erl:
* src/eldap/eldap.erl:
* src/mod_offline.erl:
* src/mod_offline_odbc.erl:
* src/mod_roster.erl:
* src/odbc/odbc_queries.erl:
* src/p1_fsm.erl:
* src/xml.erl:
* src/Makefile.in: Prevent Erlang R13B compilation warning:
behaviour X undefined (EJAB-920)

View File

@ -1809,7 +1809,7 @@ resend_offline_messages(#state{user = UserB,
StateData#state.server,
[],
[UserB, ServerB]) of
Rs when list(Rs) ->
Rs when is_list(Rs) ->
lists:foreach(
fun({route,
From, To, Packet}) ->

View File

@ -117,7 +117,7 @@ reopen_log() ->
write_event(Fd, {Time, {error, _GL, {Pid, Format, Args}}}) ->
T = write_time(Time),
case catch io_lib:format(add_node(Format,Pid), Args) of
S when list(S) ->
S when is_list(S) ->
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
F = add_node("ERROR: ~p - ~p~n", Pid),
@ -126,7 +126,7 @@ write_event(Fd, {Time, {error, _GL, {Pid, Format, Args}}}) ->
write_event(Fd, {Time, {emulator, _GL, Chars}}) ->
T = write_time(Time),
case catch io_lib:format(Chars, []) of
S when list(S) ->
S when is_list(S) ->
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
file:write(Fd, io_lib:format(T ++ "ERROR: ~p ~n", [Chars]))
@ -145,7 +145,7 @@ write_event(Fd, {Time, {info_report, _GL, {Pid, std_info, Rep}}}) ->
write_event(Fd, {Time, {info_msg, _GL, {Pid, Format, Args}}}) ->
T = write_time(Time, "INFO REPORT"),
case catch io_lib:format(add_node(Format,Pid), Args) of
S when list(S) ->
S when is_list(S) ->
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
F = add_node("ERROR: ~p - ~p~n", Pid),
@ -154,7 +154,7 @@ write_event(Fd, {Time, {info_msg, _GL, {Pid, Format, Args}}}) ->
write_event(_, _) ->
ok.
format_report(Rep) when list(Rep) ->
format_report(Rep) when is_list(Rep) ->
case string_p(Rep) of
true ->
io_lib:format("~s~n",[Rep]);
@ -171,7 +171,7 @@ format_rep([Other|Rep]) ->
format_rep(_) ->
[].
add_node(X, Pid) when atom(X) ->
add_node(X, Pid) when is_atom(X) ->
add_node(atom_to_list(X), Pid);
add_node(X, Pid) when node(Pid) /= node() ->
lists:concat([X,"** at node ",node(Pid)," **~n"]);
@ -183,7 +183,7 @@ string_p([]) ->
string_p(Term) ->
string_p1(Term).
string_p1([H|T]) when integer(H), H >= $\s, H < 255 ->
string_p1([H|T]) when is_integer(H), H >= $\s, H < 255 ->
string_p1(T);
string_p1([$\n|T]) -> string_p1(T);
string_p1([$\r|T]) -> string_p1(T);
@ -192,7 +192,7 @@ string_p1([$\v|T]) -> string_p1(T);
string_p1([$\b|T]) -> string_p1(T);
string_p1([$\f|T]) -> string_p1(T);
string_p1([$\e|T]) -> string_p1(T);
string_p1([H|T]) when list(H) ->
string_p1([H|T]) when is_list(H) ->
case string_p1(H) of
true -> string_p1(T);
_ -> false

View File

@ -277,7 +277,7 @@ do_route(From, To, Packet) ->
?DEBUG("s2s manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
[From, To, Packet, 8]),
case find_connection(From, To) of
{atomic, Pid} when pid(Pid) ->
{atomic, Pid} when is_pid(Pid) ->
?DEBUG("sending to process ~p~n", [Pid]),
NewPacket1 = exmpp_stanza:set_sender(Packet, From),
NewPacket = exmpp_stanza:set_recipient(NewPacket1, To),

View File

@ -143,14 +143,14 @@ close(Handle) ->
%%% {"telephoneNumber", ["545 555 00"]}]
%%% )
%%% --------------------------------------------------------------------
add(Handle, Entry, Attributes) when list(Entry),list(Attributes) ->
add(Handle, Entry, Attributes) when is_list(Entry), is_list(Attributes) ->
Handle1 = get_handle(Handle),
gen_fsm:sync_send_event(Handle1, {add, Entry, add_attrs(Attributes)},
?CALL_TIMEOUT).
%%% Do sanity check !
add_attrs(Attrs) ->
F = fun({Type,Vals}) when list(Type),list(Vals) ->
F = fun({Type,Vals}) when is_list(Type), is_list(Vals) ->
%% Confused ? Me too... :-/
{'AddRequest_attributes',Type, Vals}
end,
@ -169,7 +169,7 @@ add_attrs(Attrs) ->
%%% "cn=Bill Valentine, ou=people, o=Bluetail AB, dc=bluetail, dc=com"
%%% )
%%% --------------------------------------------------------------------
delete(Handle, Entry) when list(Entry) ->
delete(Handle, Entry) when is_list(Entry) ->
Handle1 = get_handle(Handle),
gen_fsm:sync_send_event(Handle1, {delete, Entry}, ?CALL_TIMEOUT).
@ -184,7 +184,7 @@ delete(Handle, Entry) when list(Entry) ->
%%% add("description", ["LDAP hacker"])]
%%% )
%%% --------------------------------------------------------------------
modify(Handle, Object, Mods) when list(Object), list(Mods) ->
modify(Handle, Object, Mods) when is_list(Object), is_list(Mods) ->
Handle1 = get_handle(Handle),
gen_fsm:sync_send_event(Handle1, {modify, Object, Mods}, ?CALL_TIMEOUT).
@ -193,9 +193,9 @@ modify(Handle, Object, Mods) when list(Object), list(Mods) ->
%%% Example:
%%% replace("telephoneNumber", ["555 555 00"])
%%%
mod_add(Type, Values) when list(Type), list(Values) -> m(add, Type, Values).
mod_delete(Type, Values) when list(Type), list(Values) -> m(delete, Type, Values).
mod_replace(Type, Values) when list(Type), list(Values) -> m(replace, Type, Values).
mod_add(Type, Values) when is_list(Type), is_list(Values) -> m(add, Type, Values).
mod_delete(Type, Values) when is_list(Type), is_list(Values) -> m(delete, Type, Values).
mod_replace(Type, Values) when is_list(Type), is_list(Values) -> m(replace, Type, Values).
m(Operation, Type, Values) ->
#'ModifyRequest_modification_SEQOF'{
@ -217,7 +217,7 @@ m(Operation, Type, Values) ->
%%% )
%%% --------------------------------------------------------------------
modify_dn(Handle, Entry, NewRDN, DelOldRDN, NewSup)
when list(Entry),list(NewRDN),atom(DelOldRDN),list(NewSup) ->
when is_list(Entry), is_list(NewRDN), is_atom(DelOldRDN), is_list(NewSup) ->
Handle1 = get_handle(Handle),
gen_fsm:sync_send_event(
Handle1,
@ -234,7 +234,7 @@ modify_dn(Handle, Entry, NewRDN, DelOldRDN, NewSup)
%%% "secret")
%%% --------------------------------------------------------------------
bind(Handle, RootDN, Passwd)
when list(RootDN),list(Passwd) ->
when is_list(RootDN), is_list(Passwd) ->
Handle1 = get_handle(Handle),
gen_fsm:sync_send_event(Handle1, {bind, RootDN, Passwd}, ?CALL_TIMEOUT).
@ -270,13 +270,13 @@ optional(Value) -> Value.
%%% []}}
%%%
%%% --------------------------------------------------------------------
search(Handle, A) when record(A, eldap_search) ->
search(Handle, A) when is_record(A, eldap_search) ->
call_search(Handle, A);
search(Handle, L) when list(L) ->
search(Handle, L) when is_list(L) ->
case catch parse_search_args(L) of
{error, Emsg} -> {error, Emsg};
{'EXIT', Emsg} -> {error, Emsg};
A when record(A, eldap_search) -> call_search(Handle, A)
A when is_record(A, eldap_search) -> call_search(Handle, A)
end.
call_search(Handle, A) ->
@ -296,7 +296,7 @@ parse_search_args([{attributes, Attrs}|T],A) ->
parse_search_args(T,A#eldap_search{attributes = Attrs});
parse_search_args([{types_only, TypesOnly}|T],A) ->
parse_search_args(T,A#eldap_search{types_only = TypesOnly});
parse_search_args([{timeout, Timeout}|T],A) when integer(Timeout) ->
parse_search_args([{timeout, Timeout}|T],A) when is_integer(Timeout) ->
parse_search_args(T,A#eldap_search{timeout = Timeout});
parse_search_args([{limit, Limit}|T],A) when is_integer(Limit) ->
parse_search_args(T,A#eldap_search{limit = Limit});
@ -315,9 +315,9 @@ wholeSubtree() -> wholeSubtree.
%%%
%%% Boolean filter operations
%%%
'and'(ListOfFilters) when list(ListOfFilters) -> {'and',ListOfFilters}.
'or'(ListOfFilters) when list(ListOfFilters) -> {'or', ListOfFilters}.
'not'(Filter) when tuple(Filter) -> {'not',Filter}.
'and'(ListOfFilters) when is_list(ListOfFilters) -> {'and',ListOfFilters}.
'or'(ListOfFilters) when is_list(ListOfFilters) -> {'or', ListOfFilters}.
'not'(Filter) when is_tuple(Filter) -> {'not',Filter}.
%%%
%%% The following Filter parameters consist of an attribute
@ -335,7 +335,7 @@ av_assert(Desc, Value) ->
%%%
%%% Filter to check for the presence of an attribute
%%%
present(Attribute) when list(Attribute) ->
present(Attribute) when is_list(Attribute) ->
{present, Attribute}.
@ -354,15 +354,15 @@ present(Attribute) when list(Attribute) ->
%%% Example: substrings("sn",[{initial,"To"},{any,"kv"},{final,"st"}])
%%% will match entries containing: 'sn: Tornkvist'
%%%
substrings(Type, SubStr) when list(Type), list(SubStr) ->
substrings(Type, SubStr) when is_list(Type), is_list(SubStr) ->
Ss = {'SubstringFilter_substrings',v_substr(SubStr)},
{substrings,#'SubstringFilter'{type = Type,
substrings = Ss}}.
get_handle(Pid) when pid(Pid) -> Pid;
get_handle(Atom) when atom(Atom) -> Atom;
get_handle(Name) when list(Name) -> list_to_atom("eldap_" ++ Name).
get_handle(Pid) when is_pid(Pid) -> Pid;
get_handle(Atom) when is_atom(Atom) -> Atom;
get_handle(Name) when is_list(Name) -> list_to_atom("eldap_" ++ Name).
%%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm
%%%----------------------------------------------------------------------
@ -835,7 +835,7 @@ cmd_timeout(Timer, Id, S) ->
polish(Entries) ->
polish(Entries, [], []).
polish([H|T], Res, Ref) when record(H, 'SearchResultEntry') ->
polish([H|T], Res, Ref) when is_record(H, 'SearchResultEntry') ->
ObjectName = H#'SearchResultEntry'.objectName,
F = fun({_,A,V}) -> {A,V} end,
Attrs = lists:map(F, H#'SearchResultEntry'.attributes),
@ -913,7 +913,7 @@ v_filter({greaterOrEqual,AV}) -> {greaterOrEqual,AV};
v_filter({lessOrEqual,AV}) -> {lessOrEqual,AV};
v_filter({approxMatch,AV}) -> {approxMatch,AV};
v_filter({present,A}) -> {present,A};
v_filter({substrings,S}) when record(S,'SubstringFilter') -> {substrings,S};
v_filter({substrings,S}) when is_record(S,'SubstringFilter') -> {substrings,S};
v_filter(_Filter) -> throw({error,concat(["unknown filter: ",_Filter])}).
v_modifications(Mods) ->
@ -925,7 +925,7 @@ v_modifications(Mods) ->
end,
lists:foreach(F, Mods).
v_substr([{Key,Str}|T]) when list(Str),Key==initial;Key==any;Key==final ->
v_substr([{Key,Str}|T]) when is_list(Str),Key==initial;Key==any;Key==final ->
[{Key,Str}|v_substr(T)];
v_substr([H|_]) ->
throw({error,{substring_arg,H}});
@ -940,11 +940,11 @@ v_bool(true) -> true;
v_bool(false) -> false;
v_bool(_Bool) -> throw({error,concat(["not Boolean: ",_Bool])}).
v_timeout(I) when integer(I), I>=0 -> I;
v_timeout(I) when is_integer(I), I>=0 -> I;
v_timeout(_I) -> throw({error,concat(["timeout not positive integer: ",_I])}).
v_attributes(Attrs) ->
F = fun(A) when list(A) -> A;
F = fun(A) when is_list(A) -> A;
(A) -> throw({error,concat(["attribute not String: ",A])})
end,
lists:map(F,Attrs).
@ -979,7 +979,7 @@ parse(Entries) ->
get_integer(Key, List) ->
case lists:keysearch(Key, 1, List) of
{value, {Key, Value}} when integer(Value) ->
{value, {Key, Value}} when is_integer(Value) ->
Value;
{value, {Key, _Value}} ->
throw({error, "Bad Value in Config for " ++ atom_to_list(Key)});
@ -989,7 +989,7 @@ get_integer(Key, List) ->
get_list(Key, List) ->
case lists:keysearch(Key, 1, List) of
{value, {Key, Value}} when list(Value) ->
{value, {Key, Value}} when is_list(Value) ->
Value;
{value, {Key, _Value}} ->
throw({error, "Bad Value in Config for " ++ atom_to_list(Key)});
@ -998,13 +998,13 @@ get_list(Key, List) ->
end.
get_hosts(Key, List) ->
lists:map(fun({Key1, {A,B,C,D}}) when integer(A),
integer(B),
integer(C),
integer(D),
lists:map(fun({Key1, {A,B,C,D}}) when is_integer(A),
is_integer(B),
is_integer(C),
is_integer(D),
Key == Key1->
{A,B,C,D};
({Key1, Value}) when list(Value),
({Key1, Value}) when is_list(Value),
Key == Key1->
Value;
({_Else, _Value}) ->

View File

@ -87,7 +87,7 @@ start(Host, Opts) ->
init(infinity) ->
loop(infinity);
init(MaxOfflineMsgs)
when integer(MaxOfflineMsgs), MaxOfflineMsgs > 0 ->
when is_integer(MaxOfflineMsgs), MaxOfflineMsgs > 0 ->
loop(MaxOfflineMsgs).
loop(MaxOfflineMsgs) ->

View File

@ -81,7 +81,7 @@ start(Host, Opts) ->
init(Host, infinity) ->
loop(Host, infinity);
init(Host, MaxOfflineMsgs)
when integer(MaxOfflineMsgs), MaxOfflineMsgs > 0 ->
when is_integer(MaxOfflineMsgs), MaxOfflineMsgs > 0 ->
loop(Host, MaxOfflineMsgs).
loop(Host, MaxOfflineMsgs) ->

View File

@ -846,7 +846,7 @@ get_in_pending_subscriptions(Ls, User, Server)
JID = exmpp_jid:make_jid(User, Server),
US = {exmpp_jid:lnode(JID), exmpp_jid:ldomain(JID)},
case mnesia:dirty_index_read(roster, US, #roster.us) of
Result when list(Result) ->
Result when is_list(Result) ->
Ls ++ lists:map(
fun(R) ->
Message = R#roster.askmessage,

View File

@ -652,7 +652,7 @@ get_and_del_spool_msg_t(LServer, Username) ->
[Result] = case ejabberd_odbc:sql_query(
LServer,
["EXECUTE dbo.get_and_del_spool_msg '", Username, "'"]) of
Rs when list(Rs) ->
Rs when is_list(Rs) ->
lists:filter(fun({selected, _Header, _Row}) ->
true;
({updated, _N}) ->

View File

@ -663,7 +663,7 @@ limit_options([], Limits) ->
Limits;
%% Maximum number of messages allowed in the process message queue
limit_options([{max_queue,N}|Options], Limits)
when integer(N) ->
when is_integer(N) ->
NewLimits = Limits#limits{max_queue=N},
limit_options(Options, NewLimits);
limit_options([_|Options], Limits) ->

View File

@ -58,7 +58,7 @@ element_to_string(El) ->
[$<, Name, attrs_to_list(Attrs), $/, $>]
end;
%% We do not crypt CDATA binary, but we enclose it in XML CDATA
{xmlcdata, CData} when binary(CData) ->
{xmlcdata, CData} when is_binary(CData) ->
?ESCAPE_BINARY(CData);
%% We crypt list and possibly binaries if full XML usage is
%% disabled unsupported (implies a conversion to list).