anchor.diff:           get_port_server_config/3,
            get_port_server_param/3,
            get_port_server_param/4,
  -         find_param/2]).
  +         set_port_server_config/3,
  +         set_port_server_param/4,
  +         set_port_server_param/5,
  +         find_param/2,
  +         set_param/3]).
   
   %% gen_server callbacks
   -export([init/1,
  
positive.code:         Tuple -> Tuple
      end.
  
  get_port_server_param(Config, PortServerName, ParameterName) ->
      get_port_server_param(Config, PortServerName, ParameterName, node()).
  
  get_port_server_param(Config, PortServerName, ParameterName, Node) ->
      StartArgs =
          case ns_port_server:get_port_server_config(Config,
                                                     PortServerName,
                                                     Node) of
              undefined -> [];
              {PortServerName, _Path, S}       -> S;
              {PortServerName, _Path, S, _Env} -> S
          end,
      ns_port_server:find_param(ParameterName, StartArgs).
  
  find_param(_, [])              -> false;
  find_param(_, [_])             -> false;
  find_param(X, [X, Val | _])    -> {value, Val};
  find_param(X, [_, Val | Rest]) -> find_param(X, [Val | Rest]).
  
  % ----------------------------------------------
  
  
negative.code: 
  find_param_test() ->
      ?assertEqual({value, "11212"},
                   find_param("-p", ["-E", "foo",
                                     "-p", "11212"])),
      ?assertEqual({value, "11212"},
                   find_param("-p", ["-p", "11212",
                                     "-E", "foo"])),
      ?assertEqual({value, "11212"},
                   find_param("-p", ["-p", "11212"])),
      ?assertEqual(false,
                   find_param("-p", ["-p"])),
      ok.
  
  set_param_test() ->
      ?assertEqual(["-E", "foo", "-p", "11212"],
                   set_param("-p", ["-E", "foo"],
                             "11212")),
      ?assertEqual(["-p", "11212"],
                   set_param("-p", [],
                             "11212")),
      ?assertEqual(["-p", "11212", "-E", "foo"],
                   set_param("-p", ["-p", "11211",
                                    "-E", "foo"],
                             "11212")),
      ?assertEqual(["-a", "hello", "-p", "11212", "-E", "foo"],
                   set_param("-p", ["-a", "hello",
                                    "-p", "11211",
                                    "-E", "foo"],
                             "11212")),
      ok.
  