anchor.diff: +%%%-------------------------------------------------------------------
  +%%% @doc
  +%%% Detailed Documentation: See section 3.6 of docs/aufgabe1_dokumentation.pdf
  +%%%
  +%%% This module receives incoming messages and validates them before it puts them
  +%%% into the DLQ. Invalid messages are hold back. A valid message is a message,
  +%%%  that is expected by the DLQ.Any other message is invalid.
  +%%% For Details about the error handling process see docs/aufgabe1_dokumentation.pdf
  +%%% section 3.6.3.
  +%%% @end
  +%%%-------------------------------------------------------------------
   -module(hbq).
   -export([start/0, start/1, hbq/3, apply_on_list/3, sort/1]).
   
  
positive.code:   werkzeug:logging(LogAtom, lists:concat(Message)),
    LogAtom.
  
  apply_on_list([H | T], X, Func) ->
    apply_on_list(T, lists:append(X, [Func(H)]), Func);
  apply_on_list([], X, _) -> X.
  
  sort(Messages) ->
    apply_on_list(lists:keysort(1, apply_on_list(Messages, [], fun list_to_tuple/1)), [], fun tuple_to_list/1).
  
  % inserts an error message into dlq
  insertErrorMessage(ErrorNNr, DLQ, Config) ->
    From = dlq:expectedNr(DLQ),
    ErrorMsg = "Fehlernachricht fuer Nachrichtennummern " ++ integer_to_list(From) ++ " bis " ++ integer_to_list(ErrorNNr),
    ErrorMessage = [ErrorNNr, ErrorMsg, erlang:now(), erlang:now()],
    dlq:push2DLQ(ErrorMessage, DLQ, Config).
  
  % handles inserting error message or doing nothing if everything is ok!
  handleFaultyHBQ([HBQMessage | HBQRest], [DLQMessages, DLQSize], Config) ->
    HBQLength = length([HBQMessage | HBQRest]),
    [NNr, _MSG, _TSclientin, _TShbqin] = HBQMessage,
  
negative.code:       {[HBQMessage | HBQRest], [DLQMessages, DLQSize]}
    end.
  
  %% push only valid messages into dlq, message is valid if it is expected
  pushToDLQ([NNr, Msg, TSclientout, TShbqin], DLQ, Logfile) ->
    ExpectedNNr = dlq:expectedNr(DLQ),
    if
  