dxftpservercore.pas
来自「Well known and usefull component for del」· PAS 代码 · 共 887 行 · 第 1/3 页
PAS
887 行
// 'TYPE', {TYPE<SP><type-code><CRLF>}
// 'STRU', {STRU<SP><structure-code><CRLF>}
// 'MODE', {MODE<SP><mode-code><CRLF>}
// 'RETR', {RETR<SP><pathname><CRLF>}
// 'STOR', {STOR<SP><pathname><CRLF>}
// 'STOU', {STOU<CRLF>}
// 'APPE', {APPE<SP><pathname><CRLF>}
// 'ALLO', {ALLO<SP><decimal-integer>[<SP>R<SP><decimal-integer>]<CRLF>}
// 'REST', {REST<SP><marker><CRLF>}
// 'RNFR', {RNFR<SP><pathname><CRLF>}
// 'RNTO', {RNTO<SP><pathname><CRLF>}
// 'ABOR', {ABOR<CRLF>}
// 'DELE', {DELE<SP><pathname><CRLF>}
// 'RMD', {RMD<SP><pathname><CRLF>}
// 'MKD', {MKD<SP><pathname><CRLF>}
// 'PWD', {PWD<CRLF>}
// 'LIST', {LIST[<SP><pathname>]<CRLF>}
// 'NLST', {NLST[<SP><pathname>]<CRLF>}
// 'SITE', {SITE<SP><string><CRLF>}
// 'SYST', {SYST<CRLF>}
// 'STAT', {STAT[<SP><pathname>]<CRLF>}
// 'HELP', {HELP[<SP><string>]<CRLF>}
// 'NOOP', {NOOP<CRLF>}
// 'XMKD', {same as MKD - RFC775}
// 'XRMD', {same as RMD - RFC775}
// 'XPWD', {same as PWD - RFC775}
// 'XCUP' {same as CDUP - RFC775}
// 'SIZE', {SIZE<SP><filename><CRLF>}
// Draft Extensions:
// 'MDTM', {MDTM<sp><pathname><CRLF>}
// return: 213<sp>YYYYMMDDHHNNSS<crlf>
// error: 550
// 'FEAT', {FEAT<CRLF>}
// return:211-
// MDTM<CRLF>
// SIZE<CRLF>
// REST STREAM<CRLF>
// 211 End.
///////////////////////////////////////////////////////////////////////////////
constructor TDXFTPServerCore.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
ServerPort:=21;
fGetLocalHostName:=DXString.GetComputerName;
end;
destructor TDXFTPServerCore.Destroy;
Var
PBasicEvent:PFTPBasicEvent;
PSimpleEvent:PFTPSimpleEvent;
PComplexEvent:PFTPComplexEvent;
PPassEvent:PFTPPassEvent;
begin
If Assigned(fEventArray) then Begin
While fEventArray.Count>0 do Begin
Case PFTPBasicEvent(fEventArray[0]).Tag of
1:Begin
PBasicEvent:=fEventArray[0];
Dispose(PBasicEvent);
End;
2:Begin
PSimpleEvent:=fEventArray[0];
Dispose(PSimpleEvent);
End;
3:Begin
PComplexEvent:=fEventArray[0];
Dispose(PComplexEvent);
End;
4:Begin
PPassEvent:=fEventArray[0];
Dispose(PPassEvent);
End;
End;
fEventArray.Delete(0);
End;
End;
inherited Destroy;
end;
///////////////////////////////////////////////////////////////////////////////
//ADDBASICEVENT:
// Allows you to dynamically assign a new command to the internal
// parser. This allows the servercore to support the 'pre-defined'
// OnCommand* events, plus you can add other commands dynamically
// at run-time in your application without requiring a source code
// modification to our components!
//
// To make support easier for us, we ask that you use the Add*Event
// procedures to expand our code, reducing code changes when an
// upgrade is released!
//
// See documentation for complete information on how this works.
//
// Example Usage: AddBasicEvent('CDROM',MySpecialEvent);
///////////////////////////////////////////////////////////////////////////////
Procedure TDXFTPServerCore.AddBasicEvent(Command:String;EventProc:FTPTBasicEvent);
Var
PBasicEvent:PFTPBasicEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PFTPBasicEvent(fEventArray[Loop]).Command=Command then Begin
PFTPBasicEvent(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;
///////////////////////////////////////////////////////////////////////////////
//ADDSIMPLEEVENT:
// Allows you to dynamically assign a new command to the internal
// parser. This allows the servercore to support the 'pre-defined'
// OnCommand* events, plus you can add other commands dynamically
// at run-time in your application without requiring a source code
// modification to our components!
//
// To make support easier for us, we ask that you use the Add*Event
// procedures to expand our code, reducing code changes when an
// upgrade is released!
//
// See documentation for complete information on how this works.
//
// Example Usage: AddSimpleEvent('IDlE',MySpecialIdleEvent);
///////////////////////////////////////////////////////////////////////////////
Procedure TDXFTPServerCore.AddSimpleEvent(Command:String;EventProc:FTPTSimpleEvent);
Var
PSimpleEvent:PFTPSimpleEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PFTPSimpleEvent(fEventArray[Loop]).Command=Command then Begin
PFTPSimpleEvent(fEventArray[Loop]).EventProcedure:=EventProc;
Exit;
End
Else Inc(Loop);
End;
New(PSimpleEvent);
PSimpleEvent.Tag:=2; // Denotes Event in fEventArray is a TBasicEvent!
PSimpleEvent.Command:=Command;
PSimpleEvent.EventProcedure:=EventProc;
fEventArray.Add(PSimpleEvent);
End;
///////////////////////////////////////////////////////////////////////////////
//ADDCOMPLEXEVENT:
// Allows you to dynamically assign a new command to the internal
// parser. This allows the servercore to support the 'pre-defined'
// OnCommand* events, plus you can add other commands dynamically
// at run-time in your application without requiring a source code
// modification to our components!
//
// To make support easier for us, we ask that you use the Add*Event
// procedures to expand our code, reducing code changes when an
// upgrade is released!
//
// See documentation for complete information on how this works.
//
// Example Usage: AddComplexEvent('ADDUSER',MySpecialAddUserEvent);
///////////////////////////////////////////////////////////////////////////////
Procedure TDXFTPServerCore.AddComplexEvent(Command:String;EventProc:FTPTComplexEvent);
Var
PComplexEvent:PFTPComplexEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PFTPComplexEvent(fEventArray[Loop]).Command=Command then Begin
PFTPComplexEvent(fEventArray[Loop]).EventProcedure:=EventProc;
Exit;
End
Else Inc(Loop);
End;
New(PComplexEvent);
PComplexEvent.Tag:=3; // Denotes Event in fEventArray is a TBasicEvent!
PComplexEvent.Command:=Command;
PComplexEvent.EventProcedure:=EventProc;
fEventArray.Add(PComplexEvent);
End;
///////////////////////////////////////////////////////////////////////////////
//ADDPASSEVENT:
// Allows you to dynamically assign a new command to the internal
// parser. This allows the servercore to support the 'pre-defined'
// OnCommand* events, plus you can add other commands dynamically
// at run-time in your application without requiring a source code
// modification to our components!
//
// To make support easier for us, we ask that you use the Add*Event
// procedures to expand our code, reducing code changes when an
// upgrade is released!
//
// See documentation for complete information on how this works.
//
// Example Usage: AddPassEvent('ADDUSER',MySpecialAddUserEvent);
///////////////////////////////////////////////////////////////////////////////
Procedure TDXFTPServerCore.AddPassEvent(Command:String;EventProc:FTPTPassEvent);
Var
PPassEvent:PFTPPassEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PFTPPassEvent(fEventArray[Loop]).Command=Command then Begin
PFTPPassEvent(fEventArray[Loop]).EventProcedure:=EventProc;
Exit;
End
Else Inc(Loop);
End;
New(PPassEvent);
PPassEvent.Tag:=4; // Denotes Event in fEventArray is a TBasicEvent!
PPassEvent.Command:=Command;
PPassEvent.EventProcedure:=EventProc;
fEventArray.Add(PPassEvent);
End;
Procedure TDXFTPServerCore.SetOnCommandUSER(value:FTPTBasicEvent);
Begin
fOnCommandUSER:=Value;
AddBasicEvent('USER',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandPASS(value:FTPTPassEvent);
Begin
fOnCommandPASS:=Value;
AddPassEvent('PASS',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandACCT(value:FTPTBasicEvent);
Begin
fOnCommandACCT:=Value;
AddBasicEvent('ACCT',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandCWD(value:FTPTBasicEvent);
Begin
fOnCommandCWD:=Value;
AddBasicEvent('CWD',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandCDUP(value:FTPTSimpleEvent);
Begin
fOnCommandCDUP:=Value;
AddSimpleEvent('CDUP',Value);
AddSimpleEvent('XCUP',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandSMNT(value:FTPTBasicEvent);
Begin
fOnCommandSMNT:=Value;
AddBasicEvent('SMNT',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandQUIT(value:FTPTSimpleEvent);
Begin
fOnCommandQUIT:=Value;
AddSimpleEvent('QUIT',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandREIN(value:FTPTSimpleEvent);
Begin
fOnCommandREIN:=Value;
AddSimpleEvent('REIN',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandPORT(value:FTPTBasicEvent);
Begin
fOnCommandPORT:=Value;
AddBasicEvent('PORT',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandPASV(value:FTPTSimpleEvent);
Begin
fOnCommandPASV:=Value;
AddSimpleEvent('PASV',Value);
End;
Procedure TDXFTPServerCore.SetOnCommandTYPE(value:FTPTBasicEvent);
Begin
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?