anchor.diff:      end.
   
   %%--------------------------------------------------------------------
  -%% Function: process_non_wildcard_contacts(LogTag, SipUser, Location,
  -%%                                         Header, PathVector)
  -%%           LogTag     = string(),
  -%%           SipUser    =
  -%%           Locations  = list() of contact record(), binding to add
  -%%                        for SipUser
  -%%           Header     = keylist record(), REGISTER request header
  -%%           PathVector = list() of string(), RFC3327 Path vector
  +%% Function: process_non_wildcard_contacts(RegReq, Contacts)
  +%%           RegReq    = reg_request record()
  +%%           Contacts  = list() of contact record()
   %% Descrip.: process a SIP Contact entry (thats not a wildcard)
   %%           and do the appropriate db add/rm/update, see:
   %%           RFC 3261 chapter 10.3 - Processing REGISTER Request -
  
positive.code: %% remove, add or update contact info in location (phone) database
  
  %% REGISTER request had no contact header
  process_updates(_LogTag, Request, SipUser, [], _AppName, DoGRUU, _PathParam) ->
      %% RFC 3261 chapter 10.3 - Processing REGISTER Request - step 8
      {ok, create_process_updates_response(SipUser, Request#request.header, DoGRUU)};
  
  process_updates(LogTag, Request, SipUser, Contacts, AppName, DoGRUU, PathParam) ->
      Header = Request#request.header,
      %% Processing REGISTER Request - step 6
      %% check for and process wildcard (request contact = *)
      case process_register_wildcard_isauth(LogTag, Header, SipUser, Contacts) of
  	none ->
  	    case process_updates_get_path_vector(Request, AppName, PathParam) of
  		PathVector when is_list(PathVector) ->
  		    %% Processing REGISTER Request - step 7
  		    %% No wildcard found, register/update/remove entries in Contacts.
  		    %% Process registration atomicly - change all or nothing in database.
  		    F = fun() ->
  				process_non_wildcard_contacts(LogTag, SipUser, Contacts, Header, PathVector)
  			end,
  		    case mnesia:transaction(F) of
  			{aborted, Reason} ->
  			    logger:log(error, "Location database: REGISTER request failed to add/update/remove one "
  				       "or more contacts for user ~p, failed due to: ~n~p", [SipUser, Reason]),
  			    %% Check if it was a siperror, otherwise return '500 Server Internal Error'
  			    case Reason of
  				{throw, {siperror, Status, Reason2}} ->
  
negative.code: %% determine expiration time for a specific contact. Use default
  %% value if contact/header supplies no expiration period.
  %% Returns : integer(), time in seconds
  get_register_expire(Expire) ->
      case Expire of
  	none ->
  	    %% no expire - use default
  	    3600;
  	Expire when is_integer(Expire) ->
  	    %% expire value supplied by request - we can choose to accept,
  	    %% change (shorten/increase expire period) or reject too short expire
  	    %% times with a 423 (Interval Too Brief) error.
  	    %% Currently implementation only limits the max expire period
  	    {ok, MaxRegisterTime} = yxa_config:get_env(max_register_time),
  
  	    lists:min([MaxRegisterTime, Expire])
      end.
  
  
  