Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion c_src/exmpp_tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ exmpp_tls_openssl_control(ErlDrvData drv_data, unsigned int command,
case COMMAND_GET_PEER_CERTIFICATE:
/* Get the peer certificate. */
cert = SSL_get_peer_certificate(edd->ssl);
if (cert == NULL || (rlen = i2d_X509(cert, NULL)) < 0) {
rlen = i2d_X509(cert, NULL);
if (cert == NULL || i2d_X509(cert, NULL) < 0) {
to_send = exmpp_new_xbuf();
if (to_send == NULL)
return (-1);
Expand Down
18 changes: 9 additions & 9 deletions src/core/exmpp_caps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
%% Hash = hash()
%% @doc Generate a hash from a Caps record.

-spec(make/1 :: (ecaps() | identity() | [identity()]) -> hash()).
-spec( make (ecaps() | identity() | [identity()]) -> hash()).

make(#identity{} = Identity) ->
make(Identity, []);
Expand All @@ -77,7 +77,7 @@ make(_) ->
%% @doc Generate a hash from an identity record or from a list of records
%% and a list of namespaces .

-spec(make/2 :: (identity() | [identity()], [ns()]) -> hash()).
-spec(make(identity() | [identity()], [ns()]) -> hash()).

make(_, Features) when not is_list(Features) ->
throw({exmpp_caps, make, 'Features : [ns()]'});
Expand All @@ -103,7 +103,7 @@ make(Identities, Features) ->
%% @doc Generate a hash from an identity record or from a list of identity records,
%% a list of namespaces, and a form or a list of forms .

-spec(make/3 :: (identity() | [identity()], [ns()], form() | [form()]) -> hash()).
-spec(make(identity() | [identity()], [ns()], form() | [form()]) -> hash()).

make(_, Features, _) when not is_list(Features) ->
throw({exmpp_caps, make, 'Features : [ns()]'});
Expand Down Expand Up @@ -135,7 +135,7 @@ make(Identities, Features, Forms) ->
%% Forms = form() | [form()]
%% String = string()

-spec(forms/1 :: (form() | [form()]) -> string()).
-spec(forms(form() | [form()]) -> string()).

forms(#form{type = Type, fields = Fields}) ->
Type ++ "<" ++ fields(Fields);
Expand All @@ -151,7 +151,7 @@ forms(_) ->
%% Fields = field() | [field()]
%% String = string()

-spec(fields/1 :: (field() | [field()]) -> string()).
-spec(fields(field() | [field()]) -> string()).

fields(#field{var = Var, values = Values}) ->
Var ++ "<" ++ values(Values);
Expand All @@ -167,7 +167,7 @@ fields(_) ->
%% Values = [value()]
%% String = string()

-spec(values/1 :: ([value()]) -> string()).
-spec(values([value()]) -> string()).

values(Values) when is_list(Values) ->
lists:foldl(
Expand All @@ -187,7 +187,7 @@ values(_) ->
%% Features = [ns()]
%% String = string()

-spec(features/1 :: ([ns()]) -> string()).
-spec(features([ns()]) -> string()).

features(Features) when is_list(Features) ->
values(Features);
Expand All @@ -199,7 +199,7 @@ features(_) ->
%% Identities = identity() | [identity()]
%% String = string()

-spec(identities/1 :: (identity() | [identity()]) -> string()).
-spec(identities(identity() | [identity()]) -> string()).

identities(#identity{category = Category, type = Type, lang = Lang, name = Name}) ->
Category ++ "/" ++ Type ++ "/" ++ Lang ++ "/" ++ Name ++ "<";
Expand All @@ -215,7 +215,7 @@ identities(_) ->
%% String = string()
%% Hash = hash()

-spec(hash_caps/1 :: (string()) -> hash()).
-spec(hash_caps (string()) -> hash()).

hash_caps(String) when is_list(String)->
base64:encode(crypto:sha(unicode:characters_to_list(String)));
Expand Down
30 changes: 14 additions & 16 deletions src/core/exmpp_internals.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
%% Dirs = [string()]
%% @doc Return a list of directories to search port drivers in.

-spec(driver_dirs/0 :: () -> [string()]).
-spec(driver_dirs() -> [string()]).

driver_dirs() ->
Mod_Path = case code:is_loaded(?MODULE) of
Expand Down Expand Up @@ -85,7 +85,7 @@ driver_dirs() ->
%% @throws {port_driver, load, Reason, Driver_Name}
%% @doc Load the port driver `Driver_Name'.

-spec(load_driver/1 :: (atom()) -> ok).
-spec(load_driver(atom()) -> ok).

load_driver(Driver_Name) ->
Dirs = driver_dirs(),
Expand All @@ -99,7 +99,7 @@ load_driver(Driver_Name) ->
%%
%% The driver is search in `Dirs'.

-spec(load_driver/2 :: (atom(), [string()]) -> ok).
-spec(load_driver(atom(), [string()]) -> ok).

load_driver(Driver_Name, Dirs) ->
load_driver1(Driver_Name, Dirs, undefined).
Expand All @@ -121,7 +121,7 @@ load_driver1(Driver_Name, [], Reason) ->
%% Driver_Name = atom()
%% @doc Unload the port driver `Driver_Name'.

-spec(unload_driver/1 :: (atom()) -> ok).
-spec(unload_driver(atom()) -> ok).

unload_driver(Driver_Name) ->
erl_ddll:unload_driver(Driver_Name),
Expand All @@ -133,7 +133,7 @@ unload_driver(Driver_Name) ->
%% @throws {port_driver, open, {posix, Posix_Code}, Driver_Name}
%% @doc Spawn a new port driver instance.

-spec(open_port/1 :: (atom()) -> port()).
-spec(open_port(atom()) -> port()).

open_port(Driver_Name) ->
try
Expand All @@ -149,7 +149,7 @@ open_port(Driver_Name) ->
%%
%% `Port' was obtained with {@link open_port/1}.

-spec(close_port/1 :: (port()) -> true).
-spec(close_port(port()) -> true).

close_port(Port) ->
erlang:port_close(Port).
Expand All @@ -168,8 +168,7 @@ close_port(Port) ->
%% @doc Wrapper to abstract the `recv' function of multiple communication
%% modules.

-spec(gen_recv/2 ::
({atom(), any()}, integer() | infinity) -> {ok, binary()} | {error, any()}).
-spec(gen_recv({atom(), any()}, integer() | infinity) -> {ok, binary()} | {error, any()}).

gen_recv({gen_tcp, Socket}, Timeout) ->
gen_tcp:recv(Socket, 0, Timeout);
Expand All @@ -185,7 +184,7 @@ gen_recv({Mod, Socket}, Timeout) ->
%% @doc Wrapper to abstract the `send' function of multiple communication
%% modules.

-spec(gen_send/2 :: ({atom(), any()}, binary()) -> ok | {error, any()}).
-spec(gen_send({atom(), any()}, binary()) -> ok | {error, any()}).

gen_send({Mod, Socket}, Packet) ->
Mod:send(Socket, Packet).
Expand All @@ -199,7 +198,7 @@ gen_send({Mod, Socket}, Packet) ->
%% @doc Wrapper to abstract the `getopts' function of multiple communication
%% modules.

-spec(gen_getopts/2 :: ({atom(), any()}, list()) -> list() | {error, any()}).
-spec(gen_getopts({atom(), any()}, list()) -> list() | {error, any()}).

gen_getopts({gen_tcp, Socket}, Options) ->
inet:getopts(Socket, Options);
Expand All @@ -214,7 +213,7 @@ gen_getopts({Mod, Socket}, Options) ->
%% @doc Wrapper to abstract the `setopts' function of multiple communication
%% modules.

-spec(gen_setopts/2 :: ({atom(), any()}, list()) -> ok | {error, any()}).
-spec(gen_setopts({atom(), any()}, list()) -> ok | {error, any()}).

gen_setopts({gen_tcp, Socket}, Options) ->
inet:setopts(Socket, Options);
Expand All @@ -230,7 +229,7 @@ gen_setopts({Mod, Socket}, Options) ->
%% @doc Wrapper to abstract the `peername' function of multiple communication
%% modules.

-spec(gen_peername/1 :: ({atom(), any()}) -> {ok, any()} | {error, any()}).
-spec(gen_peername({atom(), any()}) -> {ok, any()} | {error, any()}).

gen_peername({gen_tcp, Socket}) ->
inet:peername(Socket);
Expand All @@ -246,7 +245,7 @@ gen_peername({Mod, Socket}) ->
%% @doc Wrapper to abstract the `sockname' function of multiple communication
%% modules.

-spec(gen_sockname/1 :: ({atom(), any()}) -> {ok, any()} | {error, any()}).
-spec(gen_sockname({atom(), any()}) -> {ok, any()} | {error, any()}).

gen_sockname({gen_tcp, Socket}) ->
inet:sockname(Socket);
Expand All @@ -262,8 +261,7 @@ gen_sockname({Mod, Socket}) ->
%% @doc Wrapper to abstract the `controlling_process' function of
%% multiple communication modules.

-spec(gen_controlling_process/2 ::
({atom(), any()}, pid()) -> ok | {error, any()}).
-spec(gen_controlling_process({atom(), any()}, pid()) -> ok | {error, any()}).

gen_controlling_process({Mod, Socket}, Pid) ->
Mod:controlling_process(Socket, Pid).
Expand All @@ -275,7 +273,7 @@ gen_controlling_process({Mod, Socket}, Pid) ->
%% @doc Wrapper to abstract the `close' function of multiple communication
%% modules.

-spec(gen_close/1 :: ({atom(), any()}) -> ok | {error, any()}).
-spec(gen_close({atom(), any()}) -> ok | {error, any()}).

gen_close({Mod, Socket}) ->
Mod:close(Socket).
Loading