library TslcBdePriv;

uses
	Windows,
    SysUtils,
	TclTk,
    Tslc,
  TraceBde,
  uTslcBde,
  TslcMsg,
  LicLoad,
  TslcLice in 'TslcLice.pas';


function Tslcbde_Init(AInterp: pTcl_Interp): integer; cdecl;
begin
    try
		TBDEMod.GetThreadServer(GetCurrentThreadId).ServeInterp(AInterp);
        result := TCL_OK;
	except
		Tcl_SetResult(AInterp, pChar(Exception(ExceptObject).Message), TTclFreeProc(TCL_VOLATILE));
		result := TCL_ERROR;
    end;
end;

function Tslcbde_SafeInit(AInterp: pTcl_Interp): integer; cdecl;
begin
	result := Tslcbde_Init(AInterp);
end;

function MyTslcMessageHandler(msg: pChar; kind: integer; data: integer): integer; cdecl;
begin
end;

{$R Tslc_lic.res}

procedure DoLoadLic(licBuf: pChar; licLen: integer; clientData: pointer; var flags: TTslcLicLoadFlags);
begin
	LoadLicense( licBuf, licLen, 'TSLC_LIC', ltResource );
end;

exports
    Tslcbde_Init, Tslcbde_SafeInit;

begin
	TslcRegisterMessageHandler(MyTslcMessageHandler,0);
	TslcAddLicLoadProc(DoLoadLic, nil);

end.


