Skip to content

Commit ad9898f

Browse files
author
Marcello Ceschia
committed
-add rebar2 support, based on processone#16
-support R18 api
1 parent 3d17ff4 commit ad9898f

28 files changed

Lines changed: 437 additions & 94 deletions

EPLICENSE

100644100755
File mode changed.

README

100644100755
File mode changed.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env escript
2+
%% -*- erlang -*-
3+
4+
main([ Known_ATTRS_Src ]) ->
5+
io:format("% Generated by ~p~n", [filename:basename(escript:script_name())]),
6+
Attributes = lists:usort(read_attrs(Known_ATTRS_Src)),
7+
io:format("-define(XMPP_KNOWN_ATTRS,~n"
8+
" ~p).~n~n",
9+
[ [ binary_to_atom(ATTR, utf8)
10+
|| ATTR <- Attributes ] ]).
11+
12+
read_attrs(Known_ATTRS_Src) ->
13+
{ok, File} = file:open(Known_ATTRS_Src, [read, binary]),
14+
read_attrs(File, io:get_line(File, ""), []).
15+
16+
read_attrs(File, eof, Acc) ->
17+
file:close(File),
18+
lists:reverse(Acc);
19+
read_attrs(File, << $#, _/binary >>, Acc) ->
20+
read_attrs(File, io:get_line(File, ""), Acc);
21+
read_attrs(File, << $\n >>, Acc) ->
22+
read_attrs(File, io:get_line(File, ""), Acc);
23+
read_attrs(File, ATTR_bin, Acc) when is_binary(ATTR_bin) ->
24+
Len = byte_size(ATTR_bin) - 1,
25+
<< ATTR:Len/binary, _/binary >> = ATTR_bin,
26+
read_attrs(File, io:get_line(File, ""),
27+
[ATTR | Acc]).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env escript
2+
%% -*- erlang -*-
3+
4+
main([ Known_ELEMS_Src ]) ->
5+
io:format("% Generated by ~p~n", [filename:basename(escript:script_name())]),
6+
Elements = lists:usort(read_elems(Known_ELEMS_Src)),
7+
io:format("-define(XMPP_KNOWN_ELEMS,~n"
8+
" ~p).~n~n",
9+
[ [ binary_to_atom(EL, utf8)
10+
|| EL <- Elements ] ]),
11+
timer:sleep(10).
12+
13+
read_elems(Known_ELEMS_Src) ->
14+
{ok, File} = file:open(Known_ELEMS_Src, [read, binary]),
15+
read_elems(File, io:get_line(File, ""), []).
16+
17+
read_elems(File, eof, Acc) ->
18+
file:close(File),
19+
lists:reverse(Acc);
20+
read_elems(File, << $#, _/binary >>, Acc) ->
21+
read_elems(File, io:get_line(File, ""), Acc);
22+
read_elems(File, << $\n >>, Acc) ->
23+
read_elems(File, io:get_line(File, ""), Acc);
24+
read_elems(File, EL_bin, Acc) when is_binary(EL_bin) ->
25+
Len = byte_size(EL_bin) - 1,
26+
<< EL:Len/binary, _/binary >> = EL_bin,
27+
read_elems(File, io:get_line(File, ""),
28+
[EL | Acc]).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env escript
2+
%% -*- erlang -*-
3+
4+
main([ Known_NSS_Src ]) ->
5+
io:format("% Generated by ~p~n", [filename:basename(escript:script_name())]),
6+
Namespaces = lists:usort(read_nss(Known_NSS_Src)),
7+
io:format("-define(XMPP_KNOWN_NSS,~n"
8+
" ~p).~n~n",
9+
[ [ binary_to_atom(NS, utf8)
10+
|| NS <- Namespaces ] ]),
11+
timer:sleep(10).
12+
13+
read_nss(Known_NSS_Src) ->
14+
{ok, File} = file:open(Known_NSS_Src, [read, binary]),
15+
read_nss(File, io:get_line(File, ""), []).
16+
17+
read_nss(File, eof, Acc) ->
18+
file:close(File),
19+
lists:reverse(Acc);
20+
read_nss(File, << $#, _/binary >>, Acc) ->
21+
read_nss(File, io:get_line(File, ""), Acc);
22+
read_nss(File, << $\n >>, Acc) ->
23+
read_nss(File, io:get_line(File, ""), Acc);
24+
read_nss(File, NS_bin, Acc) when is_binary(NS_bin) ->
25+
Len = byte_size(NS_bin) - 1,
26+
<< NS:Len/binary, _/binary >> = NS_bin,
27+
read_nss(File, io:get_line(File, ""),
28+
[NS | Acc]).

include/internal/occi-schemas.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# --------------------------------------------------------------------
2+
XEP: TBD1
3+
NAME: OCCI Schema
4+
URL: http://redmine.ogf.org/projects/occi-wg/repository/revisions/xml-data-format/raw/schemas/occi.xsd
5+
6+
# --------------------------------------------------------------------
7+
XEP: TBD2
8+
NAME: XMLSchema schema
9+
URL: http://www.w3.org/2001/XMLSchema.xsd

rebar.config

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
% -*- mode: erlang -*-
2+
{erl_opts, [debug_info,
3+
{d, 'HAVE_EXPAT', true},
4+
{d, 'HAVE_LIBXML2', true}
5+
]}.
6+
7+
%{require_otp_vsn, "R18.*"}.
8+
9+
{clean_files, ["src/exmpp_known_attrs.erl",
10+
"src/exmpp_known_elems.erl",
11+
"src/exmpp_known_nss.erl",
12+
"include/internal/exmpp_known_attrs.hrl",
13+
"include/internal/exmpp_known_elems.hrl",
14+
"include/internal/exmpp_known_nss.hrl"]}.
15+
16+
{pre_hooks, [
17+
{compile, "make -C include/internal/"},
18+
{compile, "make -C src/"}
19+
]}.
20+
21+
{port_specs, [
22+
% Stringprep port driver
23+
{"linux", "priv/lib/exmpp_stringprep.so",
24+
["c_src/exmpp_driver.c", "c_src/stringprep_uni_data.c",
25+
"c_src/stringprep_uni_norm.c", "c_src/exmpp_stringprep.c"],
26+
[{env,
27+
[{"LDFLAGS", "$LDFLAGS $ERL_LDFLAGS"}]}
28+
]},
29+
% Expat port driver
30+
{"linux", "priv/lib/exmpp_xml_expat.so",
31+
["c_src/exmpp_driver.c", "c_src/exmpp_xml.c", "c_src/exmpp_xml_expat.c"],
32+
[{env,
33+
[{"LDFLAGS", "$LDFLAGS -lexpat"}]}
34+
]},
35+
{"linux", "priv/lib/exmpp_xml_expat_legacy.so",
36+
["c_src/exmpp_driver.c", "c_src/exmpp_xml.c",
37+
"c_src/exmpp_xml_expat_legacy.c"],
38+
[{env,
39+
[{"LDFLAGS", "$LDFLAGS -lexpat"}]}
40+
]},
41+
% LibXML2 port drivers
42+
{"linux", "priv/lib/exmpp_xml_libxml2.so",
43+
["c_src/exmpp_driver.c", "c_src/exmpp_xml.c", "c_src/exmpp_xml_libxml2.c"],
44+
[{env,
45+
[{"CFLAGS", "$CFLAGS -I/usr/include/libxml2"},
46+
{"LDFLAGS", "$LDFLAGS -lxml2"}]}
47+
]},
48+
% OpenSSL TLS port driver
49+
{"linux", "priv/lib/exmpp_tls_openssl.so",
50+
["c_src/exmpp_driver.c", "c_src/exmpp_tls.c", "c_src/exmpp_tls_openssl.c"],
51+
[{env,
52+
[{"LDFLAGS", "$LDFLAGS -lssl"}]}
53+
]},
54+
% Zlib compression port driver
55+
{"linux", "priv/lib/exmpp_compress_zlib.so",
56+
["c_src/exmpp_driver.c", "c_src/exmpp_compress_zlib.c"],
57+
[{env,
58+
[{"LDFLAGS", "$LDFLAGS -lz"}]}
59+
]}
60+
]}.

src/client/exmpp_client_legacy_auth.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ is_success(IQ) when ?IS_IQ(IQ) ->
365365
digest(ID, Passwd) ->
366366
Token = ID ++ Passwd,
367367
crypto:start(),
368-
binary_to_list(crypto:sha(Token)).
368+
binary_to_list(crypto:hash(sha, Token)).
369369

370370
%% @spec (Plain) -> Hex
371371
%% Plain = string()

src/core/exmpp_caps.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,6 @@ identities(_) ->
218218
-spec(hash_caps/1 :: (string()) -> hash()).
219219

220220
hash_caps(String) when is_list(String)->
221-
base64:encode(crypto:sha(unicode:characters_to_list(String)));
221+
base64:encode(crypto:hash(sha, unicode:characters_to_list(String)));
222222
hash_caps(_) ->
223223
throw({exmpp_caps, hash_caps, 'String : string()'}).

src/core/exmpp_iq.erl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,24 +348,24 @@ iq_to_xmlel2(#iq{type = Type, id = ID, lang = Lang, payload = Payload,
348348
%% IQ standard attributes.
349349
%% --------------------------------------------------------------------
350350

351-
%% @spec (El) -> bool()
351+
%% @spec (El) -> boolean()
352352
%% El = exmpp_xml:xmlel()
353353
%% @doc Tell if `El' is an IQ.
354354
%%
355355
%% You should probably use the `IS_IQ(El)' guard expression.
356356

357-
-spec(is_iq/1 :: (#xmlel{}) -> bool()).
357+
-spec(is_iq/1 :: (#xmlel{}) -> boolean()).
358358

359359
is_iq(IQ) when ?IS_IQ(IQ) -> true;
360360
is_iq(_El) -> false.
361361

362-
%% @spec (El) -> bool()
362+
%% @spec (El) -> boolean()
363363
%% El = iq()
364364
%% @doc Tell if `El' is an IQ record.
365365
%%
366366
%% You should probably use the `IS_IQ_RECORD(El)' guard expression.
367367

368-
-spec(is_iq_record/1 :: (#iq{}) -> bool()).
368+
-spec(is_iq_record/1 :: (#iq{}) -> boolean()).
369369

370370
is_iq_record(IQ) when ?IS_IQ_RECORD(IQ) -> true;
371371
is_iq_record(_El) -> false.
@@ -408,11 +408,11 @@ get_kind(IQ) when ?IS_IQ(IQ) ->
408408
get_kind(#iq{kind = Kind}) ->
409409
Kind.
410410

411-
%% @spec (IQ) -> bool()
411+
%% @spec (IQ) -> boolean()
412412
%% IQ = exmpp_xml:xmlel() | iq()
413413
%% @doc Tell if the IQ is a request.
414414

415-
-spec(is_request/1 :: (#xmlel{} | #iq{}) -> bool()).
415+
-spec(is_request/1 :: (#xmlel{} | #iq{}) -> boolean()).
416416

417417
is_request(IQ) when ?IS_IQ(IQ) ->
418418
case get_kind(IQ) of
@@ -422,11 +422,11 @@ is_request(IQ) when ?IS_IQ(IQ) ->
422422
is_request(#iq{kind = Kind}) ->
423423
Kind == request.
424424

425-
%% @spec (IQ) -> bool()
425+
%% @spec (IQ) -> boolean()
426426
%% IQ = exmpp_xml:xmlel() | iq()
427427
%% @doc Tell if the IQ is a response.
428428

429-
-spec(is_response/1 :: (#xmlel{} | #iq{}) -> bool()).
429+
-spec(is_response/1 :: (#xmlel{} | #iq{}) -> boolean()).
430430

431431
is_response(IQ) when ?IS_IQ(IQ) ->
432432
case get_kind(IQ) of
@@ -436,11 +436,11 @@ is_response(IQ) when ?IS_IQ(IQ) ->
436436
is_response(#iq{kind = Kind}) ->
437437
Kind == response.
438438

439-
%% @spec (IQ) -> bool()
439+
%% @spec (IQ) -> boolean()
440440
%% IQ = exmpp_xml:xmlel() | iq()
441441
%% @doc Tell if the IQ is a result (response of type `result').
442442

443-
-spec(is_result/1 :: (#xmlel{} | #iq{}) -> bool()).
443+
-spec(is_result/1 :: (#xmlel{} | #iq{}) -> boolean()).
444444

445445
is_result(IQ) when ?IS_IQ(IQ) ->
446446
case get_type(IQ) of
@@ -450,11 +450,11 @@ is_result(IQ) when ?IS_IQ(IQ) ->
450450
is_result(#iq{type = Type}) ->
451451
Type == 'result'.
452452

453-
%% @spec (IQ) -> bool()
453+
%% @spec (IQ) -> boolean()
454454
%% IQ = exmpp_xml:xmlel() | iq()
455455
%% @doc Tell if the IQ is an error (response of type `error').
456456

457-
-spec(is_error/1 :: (#xmlel{} | #iq{}) -> bool()).
457+
-spec(is_error/1 :: (#xmlel{} | #iq{}) -> boolean()).
458458

459459
is_error(IQ) when ?IS_IQ(IQ) ->
460460
case get_type(IQ) of

0 commit comments

Comments
 (0)