📄 dxdictionaryservercore.pas
字号:
unit DXDictionaryServerCore;
interface
///////////////////////////////////////////////////////////////////////////////
// Component: TDXDictionaryServerCore
// Author: G.E. Ozz Nixon Jr. (staff@bpdx.com)
// ========================================================================
// Source Owner: DX, Inc. 1995-2003
// Copyright: All code is the property of DX, Inc. Licensed for
// resell by Brain Patchwork DX (tm) and part of the
// DX (r) product lines, which are (c) 1999-2003
// DX, Inc. Source may not be distributed without
// written permission from both Brain Patchwork DX,
// and DX, Inc.
// License: (Reminder), None of this code can be added to other
// developer products without permission. This includes
// but not limited to DCU's, DCP's, DLL's, OCX's, or
// any other form of merging our technologies. All of
// your products released to a public consumer be it
// shareware, freeware, commercial, etc. must contain a
// license notification somewhere visible in the
// application.
// Example is Internet Explorer - Help->About screen
// shows the licensed code contained in the application.
// Code Version: (4th Generation Code)
// ========================================================================
// Description: implements the Dictionary lookup protocol
// ========================================================================
///////////////////////////////////////////////////////////////////////////////
uses
Classes,
DXServerCore;
{$I DXSock.def}
type
DictTBasicEvent = procedure(ClientThread: TDXClientThread) of object;
DictTOptionEvent = procedure(ClientThread: TDXClientThread; Command,Parm: string) of object;
DictTDefineEvent = procedure(ClientThread: TDXClientThread; Database,WordToFind:String) of object;
DictTMatchEvent = procedure(ClientThread: TDXClientThread; Database,Strategy,WordToFind:String) of object;
DictTShowEvent = procedure(ClientThread: TDXClientThread; Command:String) of object;
DictTAuthEvent = procedure(ClientThread: TDXClientThread; Username,authstring:String) of object;
DictTOtherEvent = procedure(ClientThread: TDXClientThread; Command: string; Parm: string; Handled: Boolean) of object;
TDXDictionaryServerCore = class(TDXServerCore)
private
fOnCommandAUTH: DictTAuthEvent;
fOnCommandCLIENT: DictTShowEvent;
fOnCommandDEFINE: DictTDefineEvent;
fOnCommandHELP: DictTBasicEvent;
fOnCommandMATCH: DictTMatchEvent;
fOnCommandOPTION: DictTOptionEvent;
fOnCommandQUIT: DictTBasicEvent;
fOnCommandSASLAUTH: DictTAuthEvent;
fOnCommandSHOW: DictTShowEvent;
fOnCommandSTAT: DictTBasicEvent;
fOnCommandOther: DictTOtherEvent;
protected
Procedure SetOnCommandAUTH(value:DictTAuthEvent);
Procedure SetOnCommandCLIENT(value:DictTShowEvent);
Procedure SetOnCommandDEFINE(value:DictTDefineEvent);
Procedure SetOnCommandHELP(value:DictTBasicEvent);
Procedure SetOnCommandMATCH(value:DictTMatchEvent);
Procedure SetOnCommandOPTION(value:DictTOptionEvent);
Procedure SetOnCommandQUIT(value:DictTBasicEvent);
Procedure SetOnCommandSASLAUTH(value:DictTAuthEvent);
Procedure SetOnCommandSHOW(value:DictTShowEvent);
Procedure SetOnCommandSTAT(value:DictTBasicEvent);
public
constructor Create(AOwner:TComponent); {$IFNDEF OBJECTS_ONLY} override; {$ENDIF}
destructor Destroy; override;
procedure ProcessSession(ClientThread: TDXClientThread);
Procedure AddBasicEvent(Command:String;EventProc:DictTBasicEvent);
Procedure AddDefineEvent(Command:String;EventProc:DictTDefineEvent);
Procedure AddMatchEvent(Command:String;EventProc:DictTMatchEvent);
Procedure AddShowEvent(Command:String;EventProc:DictTShowEvent);
Procedure AddAuthEvent(Command:String;EventProc:DictTAuthEvent);
Procedure AddOptionEvent(Command:String;EventProc:DictTOptionEvent);
published
property OnCommandAUTH: DictTAuthEvent read fOnCommandAuth
write SetOnCommandAuth;
property OnCommandCLIENT: DictTShowEvent read fOnCommandClient
write SetOnCommandClient;
property OnCommandDEFINE: DictTDefineEvent read fOnCommandDefine
write SetOnCommandDefine;
property OnCommandHELP: DictTBasicEvent read fOnCommandHelp
write SetOnCommandHelp;
property OnCommandMATCH: DictTMatchEvent read fOnCommandMatch
write SetOnCommandMatch;
property OnCommandOPTION: DictTOptionEvent read fOnCommandOption
write SetOnCommandOption;
property OnCommandQUIT: DictTBasicEvent read fOnCommandQuit
write SetOnCommandQuit;
property OnCommandSASLAUTH: DictTAuthEvent read fOnCommandSaslAuth
write SetOnCommandSaslAuth;
property OnCommandSHOW: DictTShowEvent read fOnCommandShow
write SetOnCommandShow;
property OnCommandSTAT: DictTBasicEvent read fOnCommandStat
write SetOnCommandStat;
property OnCommandOther: DictTOtherEvent read fOnCommandOther
write fOnCommandOther;
end;
implementation
Uses
DXSock,
DXString;
Type
PDICTBasicEvent=^TDICTBasicEvent;
TDICTBasicEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTBasicEvent;
End;
PDICTDefineEvent=^TDICTDefineEvent;
TDICTDefineEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTDefineEvent;
End;
PDICTMatchEvent=^TDICTMatchEvent;
TDICTMatchEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTMatchEvent;
End;
PDICTShowEvent=^TDICTShowEvent;
TDICTShowEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTShowEvent;
End;
PDICTAuthEvent=^TDICTAuthEvent;
TDICTAuthEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTAuthEvent;
End;
PDICTOptionEvent=^TDICTOptionEvent;
TDICTOptionEvent=record
Tag:Integer;
Command:String;
EventProcedure:DICTTOptionEvent;
End;
constructor TDXDictionaryServerCore.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
ServerPort:=2628;
end;
destructor TDXDictionaryServerCore.Destroy;
Var
PBasicEvent:PDictBasicEvent;
PDefineEvent:PDictDefineEvent;
PMatchEvent:PDictMatchEvent;
PShowEvent:PDictShowEvent;
PAuthEvent:PDictAuthEvent;
POptionEvent:PDictOptionEvent;
begin
If Assigned(fEventArray) then Begin
While fEventArray.Count>0 do Begin
Case PDictBasicEvent(fEventArray[0]).Tag of
1:Begin
PBasicEvent:=fEventArray[0];
Dispose(PBasicEvent);
End;
2:Begin
PDefineEvent:=fEventArray[0];
Dispose(PDefineEvent);
End;
3:Begin
PMatchEvent:=fEventArray[0];
Dispose(PMatchEvent);
End;
4:Begin
PShowEvent:=fEventArray[0];
Dispose(PShowEvent);
End;
5:Begin
PAuthEvent:=fEventArray[0];
Dispose(PAuthEvent);
End;
6:Begin
POptionEvent:=fEventArray[0];
Dispose(POptionEvent);
End;
End;
fEventArray.Delete(0);
End;
End;
inherited Destroy;
end;
Procedure TDXDictionaryServerCore.AddBasicEvent(Command:String;EventProc:DICTTBasicEvent);
Var
PBasicEvent:PDICTBasicEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PDICTBasicEvent(fEventArray[Loop]).Command=Command then Begin
PDICTBasicEvent(fEventArray[Loop]).EventProcedure:=EventProc;
Exit;
End
Else Inc(Loop);
End;
New(PBasicEvent);
PBasicEvent.Tag:=1; // Denotes Event in fEventArray is a TBasicEvent!
PBasicEvent.Command:=Command;
PBasicEvent.EventProcedure:=EventProc;
fEventArray.Add(PBasicEvent);
End;
Procedure TDXDictionaryServerCore.AddDefineEvent(Command:String;EventProc:DICTTDefineEvent);
Var
PDefineEvent:PDICTDefineEvent;
Loop:Integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -