anchor.diff:  			{error, Reason}
   	end.
   
  --spec radius_acct_file(FileName) -> Result
  -	when
  -		FileName :: string(),
  -		Result :: ok | {error, Reason :: term()}.
  -%% @doc Write all logged accounting records to a file.
  -%%
  -radius_acct_file(FileName) when is_list(FileName) ->
  -	case file:open(FileName, [write]) of
  -	{ok, IODevice} ->
  -	file_chunk(?RADACCT, IODevice, start);
  -		{error, Reason} ->
  -			error_logger:error_report([file:format_error(Reason),
  -					{module, ?MODULE}, {log, ?RADACCT}, {error, Reason}]),
  -			{error, Reason}
  -	end.
  -
   -spec radius_auth_open() -> Result
   	when
   		Result :: ok | {error, Reason :: term()}.
  
positive.code: -copyright('Copyright (c) 2016-2017 SigScale Global Inc.').
  
  %% export the ocs_log public API
  -export([radius_acct_open/0, radius_acct_log/4, radius_acct_file/1,
  		radius_acct_close/0]).
  -export([radius_auth_open/0, radius_auth_log/5, radius_auth_file/1,
  		radius_auth_close/0]).
  
  %% export the ocs_log private API
  -export([]).
  
negative.code: 			{error, Reason}
  	end.
  
  -spec ipdr_log(File, Start, End) -> Result
  	when
  		File :: file:filename(),
  		Start :: pos_integer(),
  		End :: pos_integer(),
  		Result :: ok | {error, Reason},
  		Reason :: term().
  %% @doc Log accounting records within range to new IPDR disk log.
  ipdr_log(File, Start, End) when is_list(File),
  		is_integer(Start), is_integer(End) ->
  	case disk_log:open([{name, File}, {file, File}]) of
  		{ok, IpdrLog} ->
  			ipdr_log1(IpdrLog, Start, End,
  					start_binary_tree(?RADACCT, Start, End));
  		{error, Reason} ->
  			error_logger:error_report([disk_log:format_error(Reason),
  					{module, ?MODULE}, {file, File}, {error, Reason}]),
  			{error, Reason}
  	end.
  %% @hidden
  ipdr_log1(IpdrLog, _Start, _End, eof) ->
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log1(IpdrLog, Start, End, Cont) ->
  	ipdr_log2(IpdrLog, Start, End, disk_log:chunk(?RADACCT, Cont)).
  %% @hidden
  ipdr_log2(IpdrLog, _Start, _End, eof) ->
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log2(IpdrLog, _Start, _End, {error, Reason}) ->
  	error_logger:error_report([disk_log:format_error(Reason),
  			{module, ?MODULE}, {log, ?RADACCT}, {error, Reason}]),
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log2(IpdrLog, Start, End, {Cont, Accts}) ->
  	Fstart = fun(R) when element(1, R) < Start ->
  				true;
  			(_) ->
  				false
  	end,
  	case lists:dropwhile(Fstart, Accts) of
  		[] ->
  			ipdr_log2(IpdrLog, Start, End, disk_log:chunk(?RADACCT, Cont));
  		Accts1 ->
  			ipdr_log3(IpdrLog, Start, End, {Cont, Accts1})
  	end.
  %% @hidden
  ipdr_log3(IpdrLog, _Start, _End, eof) ->
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log3(IpdrLog, _Start, _End, {error, Reason}) ->
  	error_logger:error_report([disk_log:format_error(Reason),
  			{module, ?MODULE}, {log, ?RADACCT}, {error, Reason}]),
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log3(IpdrLog, Start, End, {Cont, Accts}) ->
  	Fend = fun(R) when element(1, R) < End ->
  				true;
  			(_) ->
  				false
  	end,
  	ipdr_log4(IpdrLog, Start, End, {Cont, Accts}, lists:takewhile(Fend, Accts)).
  %% @hidden
  ipdr_log4(IpdrLog, _Start, _End, {_Cont, _Accts}, []) ->
  	ipdr_log5(IpdrLog, disk_log:close(IpdrLog));
  ipdr_log4(IpdrLog, Start, End, {Cont, Accts}, Filtered) ->
  	case disk_log:log_terms(IpdrLog, Filtered) of
  		ok ->
  			case Filtered of
  				Accts ->
  					ipdr_log3(IpdrLog, Start, End, disk_log:chunk(?RADACCT, Cont));
  				_ ->
  					ipdr_log5(IpdrLog, disk_log:close(IpdrLog))
  			end;
  		{error, Reason} ->
  			error_logger:error_report([disk_log:format_error(Reason),
  					{module, ?MODULE}, {log, IpdrLog}, {error, Reason}]),
  			ipdr_log5(IpdrLog, disk_log:close(IpdrLog))
  	end.
  %% @hidden
  ipdr_log5(_IpdrLog, ok) ->
  	ok;
  ipdr_log5(IpdrLog, {error, Reason}) ->
  	error_logger:error_report([disk_log:format_error(Reason),
  			{module, ?MODULE}, {log, IpdrLog}, {error, Reason}]),
  	{error, Reason}.
  
  -spec dump_file(Log, FileName) -> Result
  	when
  		Log :: disk_log:log(),
  		FileName :: file:filename(),
  		Result :: ok | {error, Reason :: term()}.
  %% @doc Write all logged records to a file.
  %%
  dump_file(Log, FileName) when is_list(FileName) ->
  	case file:open(FileName, [write]) of
  		{ok, IoDevice} ->
  			file_chunk(Log, IoDevice, start);
  		{error, Reason} ->
  			error_logger:error_report([file:format_error(Reason),
  					{module, ?MODULE}, {log, Log}, {error, Reason}]),
  			{error, Reason}
  	end.
  
  