anchor.diff:              {reply, {ok,Term1,Term2,Term3}, S#state{handle = Handle}};
           {error, Reason, Handle} ->
               {reply, {error,Reason}, S#state{handle = Handle}}
  -    end;
  -handle_call(Request, From, State) ->
  -    io:format("~p [~p:handle_call] req=~p,~p~n", [self(),?MODULE,Request,From]),
  -    {reply, {error,badarg}, State}.
  -
  -handle_cast(stop, State) ->
  -    {stop, normal, State};
  -handle_cast(Request, State) ->
  -    io:format("~p [~p:handle_cast] req=~p~n", [self(),?MODULE,Request]),
  -    {noreply, State}.
  -
  -handle_info({'EXIT',_Pid,Reason}, State) ->
  -    {stop, Reason, State};
  -handle_info(Info, State) ->
  -    io:format("~p [~p:handle_info] info=~p~n", [self(),?MODULE,Info]),
  -    {noreply, State}.
  -
  -%% == private: state ==
  -
  -cleanup(#state{handle=H}=S)
  -  when undefined =/= H ->
  -    _ = myer_protocol:close(H),
  -    cleanup(S#state{handle = undefined, auth = false});
  -cleanup(#state{}) ->
  -    %%io:format("~p [~p:cleanup]~n",[self(),?MODULE]),
  -    flush().
  -
  -setup([]) ->
  -    %%io:format("~p [~p:setup]~n",[self(),?MODULE]),
  -    process_flag(trap_exit, true),
  -    {ok, #state{}}.
  -
  -setup(Args, #state{handle=undefined}=S) ->
  -    L = [
  -         proplists:get_value(address, Args, "localhost"),
  -         proplists:get_value(port, Args, 3306),
  -         proplists:get_value(default_character_set, Args, ?CHARSET_utf8_general_ci),
  -         proplists:get_value(compress, Args, false),
  -         proplists:get_value(max_allowed_packet, Args, 4194304),
  -         timer:seconds(proplists:get_value(timeout, Args, 10))
  -        ],
  -    case apply(myer_protocol, connect, [L]) of
  -        {ok, Handle} ->
  -            setup(Args, S#state{handle = Handle, auth = false});
  -        {error, Reason} ->
  -            {error, Reason, S};
  -        {error, Reason, Handle} ->
  -            {error, Reason, S#state{handle = Handle}}
  -    end;
  -setup(Args, #state{handle=H,auth=false}=S) ->
  -    L = [
  -         proplists:get_value(user, Args, <<"root">>),
  -         proplists:get_value(password, Args, <<"">>),
  -         proplists:get_value(database, Args, <<"">>)
  -        ],
  -    case apply(myer_protocol, auth, [H|L]) of
  -        {ok, _Result, Handle} ->
  -            setup(Args, S#state{handle = Handle, auth = true});
  -        {error, Reason, Handle} ->
  -            {error, Reason, S#state{handle = Handle}}
  -    end;
  -setup(_Args, #state{}=S) ->
  -    {ok, S}.
  -
  -%% == private ==
  -
  -flush() ->
  -    receive _ -> flush() after 0 -> ok end.
  -
  -validate({address=K,Value}, List) -> % inet:ip_address()|inet:hostname()
  +    end.
  +
  +
  +validate({address=K,Value}, List) -> % inet:ip_address()|inet:hostname(), TODO
       T = if is_atom(Value)                    -> {K, Value};
              is_list(Value), 0 < length(Value) -> {K, Value};
              is_binary(Value), 0 < size(Value) -> {K, binary_to_list(Value)};
              true -> throw({badarg,K})
           end,
       [T|List];
  -validate({port=K,Value}, List) -> % inet:port_number()
  +validate({port=K,Value}, List) -> % inet:port_number(), TODO
       T = if is_integer(Value)                 -> {K, Value};
              true -> throw({badarg,K})
           end,
  
positive.code: -include("internal.hrl").
  
  %% -- public --
  -export([start_link/1, start_link/2, stop/1]).
  -export([call/2, cast/2]).
  
  %% -- behaviour: gen_server --
  -behaviour(gen_server).
  
negative.code: code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  handle_call({Func,Args}, _From, State)
    when is_atom(Func), is_list(Args)->
      ready(Func, Args, State).
  
  handle_cast(_Request, State) ->
      {stop, enotsup, State}.
  
  handle_info(timeout, State) ->
      initialized(State);
  handle_info({tcp_closed,Socket}, #state{handle=H}=S)
    when Socket =:= ?SOCKET(H) ->
      {stop, tcp_closed, S};
  handle_info({'EXIT',_Pid,Reason}, State) ->
      {stop, Reason, State}.
  
  %% == private ==
  
  cleanup(#state{handle=H}=S)
    when undefined =/= H ->
      _ = myer_protocol:close(H),
      cleanup(S#state{handle = undefined});
  cleanup(#state{}) ->
      baseline:flush().
  
  setup(Args) ->
      process_flag(trap_exit, true),
      loaded(Args, #state{}).
  
  
  loaded(Args, #state{}=S) ->
      {ok, S#state{args = Args}, 0}.
  
  
  initialized(#state{args=A,handle=undefined}=S) ->
      L = [
           proplists:get_value(address, A, "localhost"),
           proplists:get_value(port, A, 3306),
           proplists:get_value(default_character_set, A, ?CHARSET_utf8_general_ci),
           proplists:get_value(compress, A, false),
           proplists:get_value(max_allowed_packet, A, 4194304),
           timer:seconds(proplists:get_value(timeout, A, 10))
          ],
      case apply(myer_protocol, connect, [L]) of
          {ok, Handle} ->
              connected(S#state{handle = Handle});
          {error, Reason} ->
              {error, Reason, S};
          {error, Reason, Handle} ->
              {error, Reason, S#state{handle = Handle}}
      end.
  
  connected(#state{args=A,handle=H}=S) ->
      L = [
           proplists:get_value(user, A, <<"root">>),
           proplists:get_value(password, A, <<"">>),
           proplists:get_value(database, A, <<"">>)
          ],
      case apply(myer_protocol, auth, [H|L]) of
          {ok, _Result, Handle} ->
              authorized(S#state{handle = Handle});
          {error, Reason, Handle} ->
              {error, Reason, S#state{handle = Handle}}
      end.
  
  authorized(#state{}=S) ->
      {noreply, S}.
  
  
  ready(Func, Args, #state{handle=H}=S) ->
      case apply(myer_protocol, Func, [H|Args]) of
          {ok, Handle} ->
              {reply, ok, S#state{handle = Handle}};
  