./ct_report/coverage/XmppAddr.COVER.html

1 %% Generated by the Erlang ASN.1 BER compiler. Version: 5.3
2 %% Purpose: Encoding and decoding of the types in XmppAddr.
3
4 -module('XmppAddr').
5 -moduledoc false.
6 -compile(nowarn_unused_vars).
7 -dialyzer(no_improper_lists).
8 -dialyzer(no_match).
9 -include("XmppAddr.hrl").
10 -asn1_info([{vsn,'5.3'},
11 {module,'XmppAddr'},
12 {options,[{i,"/home/circleci/project/asngen"},
13 noobj,ber,
14 {outdir,"/home/circleci/project/asngen"},
15 {i,"."},
16 {i,"/home/circleci/project/asn1"}]}]).
17
18 -export([encoding_rule/0,maps/0,bit_string_format/0,
19 legacy_erlang_types/0]).
20 -export(['dialyzer-suppressions'/1]).
21 -export([
22 enc_XmppAddr/2
23 ]).
24
25 -export([
26 dec_XmppAddr/2
27 ]).
28
29 -export([
30 'id-on-xmppAddr'/0
31 ]).
32
33 -export([info/0]).
34
35 -export([encode/2,decode/2]).
36
37
:-(
encoding_rule() -> ber.
38
39
:-(
maps() -> false.
40
41
:-(
bit_string_format() -> bitstring.
42
43
:-(
legacy_erlang_types() -> false.
44
45 encode(Type, Data) ->
46
:-(
try iolist_to_binary(element(1, encode_disp(Type, Data))) of
47 Bytes ->
48
:-(
{ok,Bytes}
49 catch
50 Class:Exception:Stk when Class =:= error; Class =:= exit ->
51
:-(
case Exception of
52 {error,{asn1,Reason}} ->
53
:-(
{error,{asn1,{Reason,Stk}}};
54 Reason ->
55
:-(
{error,{asn1,{Reason,Stk}}}
56 end
57 end.
58
59
60 decode(Type, Data) ->
61
:-(
try
62
:-(
Result = decode_disp(Type, element(1, ber_decode_nif(Data))),
63
:-(
{ok,Result}
64 catch
65 Class:Exception:Stk when Class =:= error; Class =:= exit ->
66
:-(
case Exception of
67 {error,{asn1,Reason}} ->
68
:-(
{error,{asn1,{Reason,Stk}}};
69 Reason ->
70
:-(
{error,{asn1,{Reason,Stk}}}
71 end
72 end.
73
74
:-(
encode_disp('XmppAddr', Data) -> enc_XmppAddr(Data);
75
:-(
encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
76
77
:-(
decode_disp('XmppAddr', Data) -> dec_XmppAddr(Data);
78
:-(
decode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
79
80 info() ->
81
:-(
case ?MODULE:module_info(attributes) of
82 Attributes when is_list(Attributes) ->
83
:-(
case lists:keyfind(asn1_info, 1, Attributes) of
84 {_,Info} when is_list(Info) ->
85
:-(
Info;
86 _ ->
87
:-(
[]
88 end;
89 _ ->
90
:-(
[]
91 end.
92
93
94 %%================================
95 %% XmppAddr
96 %%================================
97 enc_XmppAddr(Val) ->
98
:-(
enc_XmppAddr(Val, [<<12>>]).
99
100 enc_XmppAddr(Val, TagIn) ->
101
:-(
encode_UTF8_string(Val, TagIn).
102
103
104 dec_XmppAddr(Tlv) ->
105
:-(
dec_XmppAddr(Tlv, [12]).
106
107 dec_XmppAddr(Tlv, TagIn) ->
108
:-(
decode_UTF8_string(Tlv, TagIn).
109
110 'id-on-xmppAddr'() ->
111
:-(
{1,3,6,1,5,5,7,8,5}.
112
113
114 %%%
115 %%% Run-time functions.
116 %%%
117
118 'dialyzer-suppressions'(Arg) ->
119
:-(
ok.
120
121 ber_decode_nif(B) ->
122
:-(
asn1rt_nif:decode_ber_tlv(B).
123
124 collect_parts(TlvList) ->
125
:-(
collect_parts(TlvList, []).
126
127 collect_parts([{_, L} | Rest], Acc) when is_list(L) ->
128
:-(
collect_parts(Rest, [collect_parts(L) | Acc]);
129 collect_parts([{3, <<Unused,Bits/binary>>} | Rest], _Acc) ->
130
:-(
collect_parts_bit(Rest, [Bits], Unused);
131 collect_parts([{_T, V} | Rest], Acc) ->
132
:-(
collect_parts(Rest, [V | Acc]);
133 collect_parts([], Acc) ->
134
:-(
list_to_binary(lists:reverse(Acc)).
135
136 collect_parts_bit([{3, <<Unused,Bits/binary>>} | Rest], Acc, Uacc) ->
137
:-(
collect_parts_bit(Rest, [Bits | Acc], Unused + Uacc);
138 collect_parts_bit([], Acc, Uacc) ->
139
:-(
list_to_binary([Uacc | lists:reverse(Acc)]).
140
141 decode_UTF8_string(Tlv, TagsIn) ->
142
:-(
Val = match_tags(Tlv, TagsIn),
143
:-(
case Val of
144 [_ | _] = PartList ->
145
:-(
collect_parts(PartList);
146 Bin ->
147
:-(
Bin
148 end.
149
150 encode_UTF8_string(UTF8String, TagIn) when is_binary(UTF8String) ->
151
:-(
encode_tags(TagIn, UTF8String, byte_size(UTF8String));
152 encode_UTF8_string(UTF8String, TagIn) ->
153
:-(
encode_tags(TagIn, UTF8String, length(UTF8String)).
154
155 encode_length(L) when L =< 127 ->
156
:-(
{[L], 1};
157 encode_length(L) ->
158
:-(
Oct = minimum_octets(L),
159
:-(
Len = length(Oct),
160
:-(
if
161 Len =< 126 ->
162
:-(
{[128 bor Len | Oct], Len + 1};
163 true ->
164
:-(
exit({error, {asn1, too_long_length_oct, Len}})
165 end.
166
167 encode_tags([Tag | Trest], BytesSoFar, LenSoFar) ->
168
:-(
{Bytes2, L2} = encode_length(LenSoFar),
169
:-(
encode_tags(Trest,
170 [Tag, Bytes2 | BytesSoFar],
171 LenSoFar + byte_size(Tag) + L2);
172 encode_tags([], BytesSoFar, LenSoFar) ->
173
:-(
{BytesSoFar, LenSoFar}.
174
175 match_tags({T, V}, [T]) ->
176
:-(
V;
177 match_tags({T, V}, [T | Tt]) ->
178
:-(
match_tags(V, Tt);
179 match_tags([{T, V}], [T | Tt]) ->
180
:-(
match_tags(V, Tt);
181 match_tags([{T, _V} | _] = Vlist, [T]) ->
182
:-(
Vlist;
183 match_tags(Tlv, []) ->
184
:-(
Tlv;
185 match_tags({Tag, _V} = Tlv, [T | _Tt]) ->
186
:-(
exit({error, {asn1, {wrong_tag, {{expected, T}, {got, Tag, Tlv}}}}}).
187
188 minimum_octets(0, Acc) ->
189
:-(
Acc;
190 minimum_octets(Val, Acc) ->
191
:-(
minimum_octets(Val bsr 8, [Val band 255 | Acc]).
192
193 minimum_octets(Val) ->
194
:-(
minimum_octets(Val, []).
Line Hits Source