./ct_report/coverage/XmppAddr.COVER.html

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