diff options
author | Björn Gustavsson <[email protected]> | 2012-11-26 11:53:23 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-11-26 11:53:23 +0100 |
commit | 1204bb9dc739a80557fb1fa6e35cc113bf943823 (patch) | |
tree | c7f9030962b5d78e01dbd4137e915eb61e55f26f /lib/asn1/src/asn1rt_ber_bin_v2.erl | |
parent | b4db457fdf813de7046056a0cf71ec104af8b871 (diff) | |
parent | 66ae461376c17806b25b8165d8ff86782fbacfa6 (diff) | |
download | otp-1204bb9dc739a80557fb1fa6e35cc113bf943823.tar.gz otp-1204bb9dc739a80557fb1fa6e35cc113bf943823.tar.bz2 otp-1204bb9dc739a80557fb1fa6e35cc113bf943823.zip |
Merge branch 'bjorn/asn1/clean-up-backends/OTP-10410'
* bjorn/asn1/clean-up-backends/OTP-10410:
Simplify the code for the generated info/0 function
Don't try to work around a non-loadable NIF library
Fix BER encoding when multiple levels of typedefs are used
Update megaco documentation
Update documentation for the asn1 application
Fix other applications
Fix use of asn1 in megaco
Remove the unused asn1ct_gen_ber module
Remove the unused asn1ct_constructed_ber module
Remove the unused asn1ct_per_bin module
Remove unused functions in asn1rt_ber_bin
Remove obsolete back-ends and simplify the options
Make the specialized decodes work with the 'nif' option
Remove support for the obsolete {Typename,Value} tuple notation
Remove tests for the obsolete {TypeName,Value} notation
Remove the obsolete and deprecated 'keyed_list' option
Diffstat (limited to 'lib/asn1/src/asn1rt_ber_bin_v2.erl')
-rw-r--r-- | lib/asn1/src/asn1rt_ber_bin_v2.erl | 53 |
1 files changed, 5 insertions, 48 deletions
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl index 9ff5017c68..92ca11cf89 100644 --- a/lib/asn1/src/asn1rt_ber_bin_v2.erl +++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl @@ -22,8 +22,7 @@ %% encoding / decoding of BER -export([decode/1, decode/2, match_tags/2, encode/1, encode/2]). --export([fixoptionals/2, cindex/3, - list_to_record/2, +-export([fixoptionals/2, encode_tag_val/1, encode_tags/3, skip_ExtensionAdditions/2]). @@ -54,8 +53,6 @@ decode_open_type_as_binary/3]). -export([decode_primitive_incomplete/2,decode_selective/2]). - --export([is_nif_loadable/0]). % the encoding of class of tag bits 8 and 7 -define(UNIVERSAL, 0). @@ -135,12 +132,7 @@ encode(Tlv,_) when is_binary(Tlv) -> encode([Tlv],Method) -> encode(Tlv,Method); encode(Tlv, nif) -> - case is_nif_loadable() of - true -> - asn1rt_nif:encode_ber_tlv(Tlv); - false -> - encode_erl(Tlv) - end; + asn1rt_nif:encode_ber_tlv(Tlv); encode(Tlv, _) -> encode_erl(Tlv). @@ -178,36 +170,15 @@ decode(B) -> %% asn1-1.7 decode(B, nif) -> - case is_nif_loadable() of - true -> - case asn1rt_nif:decode_ber_tlv(B) of - {error, Reason} -> handle_error(Reason, B); - Else -> Else - end; - false -> - decode(B) + case asn1rt_nif:decode_ber_tlv(B) of + {error, Reason} -> handle_error(Reason, B); + Else -> Else end; decode(B,erlang) when is_binary(B) -> decode_primitive(B); decode(Tlv,erlang) -> {Tlv,<<>>}. -%% Have to check this since asn1 is not guaranteed to be available -is_nif_loadable() -> - case application:get_env(asn1, nif_loadable) of - {ok,R} -> - R; - undefined -> - case catch code:load_file(asn1rt_nif) of - {module, asn1rt_nif} -> - application:set_env(asn1, nif_loadable, true), - true; - _Else -> - application:set_env(asn1, nif_loadable, false), - false - end - end. - handle_error([],_)-> exit({error,{asn1,{"memory allocation problem"}}}); handle_error({$1,_},L) -> % error in nif @@ -612,13 +583,6 @@ match_tags(Tlv, []) -> Tlv; match_tags(Tlv = {Tag,_V},[T|_Tt]) -> exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}). - - -cindex(Ix,Val,Cname) -> - case element(Ix,Val) of - {Cname,Val2} -> Val2; - X -> X - end. %%% %% skips components that do not match a tag in Tags @@ -642,13 +606,6 @@ skip_ExtensionAdditions(TLV=[{Tag,_}|Rest],Tags) -> %%=============================================================================== %%=============================================================================== -% converts a list to a record if necessary -list_to_record(Name,List) when is_list(List) -> - list_to_tuple([Name|List]); -list_to_record(_Name,Tuple) when is_tuple(Tuple) -> - Tuple. - - fixoptionals(OptList,Val) when is_list(Val) -> fixoptionals(OptList,Val,1,[],[]). |