aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rt_ber_bin_v2.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-07-22 15:54:40 +0200
committerLukas Larsson <[email protected]>2011-08-01 16:38:50 +0200
commite03878664047f86735797c30e9ba1b5917cd9f27 (patch)
tree0ae814e5a543927c71b4b7f0c569cc41f874c6d6 /lib/asn1/src/asn1rt_ber_bin_v2.erl
parent3a9a3d224b5c6c05eb0a77c70bee8f5fdee3b8f4 (diff)
downloadotp-e03878664047f86735797c30e9ba1b5917cd9f27.tar.gz
otp-e03878664047f86735797c30e9ba1b5917cd9f27.tar.bz2
otp-e03878664047f86735797c30e9ba1b5917cd9f27.zip
Update decode_open_type to use nifs if configured to do so
Diffstat (limited to 'lib/asn1/src/asn1rt_ber_bin_v2.erl')
-rw-r--r--lib/asn1/src/asn1rt_ber_bin_v2.erl22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl
index 832c055389..2df289e2b8 100644
--- a/lib/asn1/src/asn1rt_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl
@@ -49,7 +49,8 @@
decode_tag_and_length/1]).
-export([encode_open_type/1,encode_open_type/2,
- decode_open_type/2,decode_open_type_as_binary/2]).
+ decode_open_type/2,decode_open_type/3,
+ decode_open_type_as_binary/2]).
-export([decode_primitive_incomplete/2,decode_selective/2]).
@@ -158,6 +159,9 @@ encode_tlv_list([],Acc) ->
Bin=list_to_binary(lists:reverse(Acc)),
{Bin,size(Bin)}.
+decode(B) ->
+ decode(B, erlang).
+
%% asn1-1.7
decode(B, nif) ->
case application:get_env(asn1, nif_loadable) of
@@ -177,8 +181,10 @@ decode(B, nif) ->
end,
decode(B, nif)
end;
-decode(B,erlang) ->
- decode(B).
+decode(B,erlang) when is_binary(B) ->
+ decode_primitive(B);
+decode(Tlv,erlang) ->
+ {Tlv,<<>>}.
handle_error([],_)->
exit({error,{asn1,{"memory allocation problem"}}});
@@ -207,12 +213,6 @@ error_pos([B|Bs]) ->
BS = 8 * length(Bs),
B bsl BS + error_pos(Bs).
-decode(Bin) when is_binary(Bin) ->
- decode_primitive(Bin);
-decode(Tlv) -> % assume it is a tlv
- {Tlv,<<>>}.
-
-
decode_primitive(Bin) ->
{Form,TagNo,V,Rest} = decode_tag_and_length(Bin),
case Form of
@@ -770,9 +770,11 @@ encode_open_type(Val,Tag) ->
%% Value = binary with decoded data (which must be decoded again as some type)
%%
decode_open_type(Tlv, TagIn) ->
+ decode_open_type(Tlv, TagIn, erlang).
+decode_open_type(Tlv, TagIn, Method) ->
case match_tags(Tlv,TagIn) of
Bin when is_binary(Bin) ->
- {InnerTlv,_} = decode(Bin),
+ {InnerTlv,_} = decode(Bin,Method),
InnerTlv;
TlvBytes -> TlvBytes
end.