unit PKSTutils;

interface
uses sysutils, Contnrs;

Type
  TPKSTQueue = class(TObjectQueue)
  published
    property List;
  end;

function SlashSep(const Path, S: String): String;
function ResolveHost(host:string): string;
function SameHost(hostA, hostB:string): Boolean;
procedure SafeFreeAndNil(var obj);

implementation
uses
  IdStack;

function SlashSep(const Path, S: String): String;
begin
  if AnsiLastChar(Path)^ <> '\' then
    Result := Path + '\' + S
  else
    Result := Path + S;
end;

function ResolveHost(host:string): string;
begin
  Result := '';
  try
//    if pos('.', host)=0 then
//      host := host+'.meibu.com';
    Result := GStack.ResolveHost(host);
  except
    Result := '';
  end;
end;

function SameHost(hostA, hostB:string): Boolean;
begin
  Result := false;
  hostA := ResolveHost(hostA);
  hostB := ResolveHost(hostB);
  Result := (hostA<>'') and (hostB<>'') and (hostA=hostB);
end;

procedure SafeFreeAndNil(var obj);
var
  Temp: TObject;
begin
  Temp := TObject(Obj);
  if Assigned(Temp) then
    FreeAndNil(Temp);
end;

end.
