mysticbbs/mdl/m_io_base.pas

139 lines
2.8 KiB
ObjectPascal
Raw Normal View History

2012-08-11 11:56:23 -07:00
Unit m_io_Base;
{$I M_OPS.PAS}
Interface
Const
2013-09-25 19:39:14 -07:00
TIOBufferSize = 16 * 1024 - 1;
2012-08-11 11:56:23 -07:00
Type
TIOBuffer = Array[0..TIOBufferSize] of Char;
TIOBase = Class
FInBuf : TIOBuffer;
FInBufPos : LongInt;
FInBufEnd : LongInt;
FOutBuf : TIOBuffer;
FOutBufPos : LongInt;
2013-02-24 20:28:11 -08:00
Connected : Boolean;
2012-08-11 11:56:23 -07:00
Constructor Create; Virtual;
Destructor Destroy; Override;
2013-02-24 20:28:11 -08:00
Procedure PurgeInputData (DrainWait: LongInt);
2012-08-11 11:56:23 -07:00
Procedure PurgeOutputData;
Function DataWaiting : Boolean; Virtual;
Function WriteBuf (Var Buf; Len: LongInt) : LongInt; Virtual;
Function ReadBuf (Var Buf; Len: LongInt) : LongInt; Virtual;
Procedure BufWriteChar (Ch: Char); Virtual;
Procedure BufWriteStr (Str: String); Virtual;
Procedure BufFlush; Virtual;
Function WriteStr (Str: String) : LongInt; Virtual;
Function WriteLine (Str: String) : LongInt; Virtual;
Function ReadLine (Var Str: String) : LongInt; Virtual;
Function WaitForData (TimeOut: LongInt) : LongInt; Virtual;
Function PeekChar (Num: Byte) : Char; Virtual;
Function ReadChar : Char; Virtual;
End;
Implementation
2013-02-24 20:28:11 -08:00
Uses
m_DateTime;
2012-08-11 11:56:23 -07:00
Constructor TIOBase.Create;
Begin
Inherited Create;
FInBufPos := 0;
FInBufEnd := 0;
FOutBufPos := 0;
2013-02-24 20:28:11 -08:00
Connected := True;
2012-08-11 11:56:23 -07:00
End;
Destructor TIOBase.Destroy;
Begin
Inherited Destroy;
End;
Procedure TIOBase.PurgeOutputData;
Begin
FOutBufPos := 0;
End;
2013-02-24 20:28:11 -08:00
Procedure TIOBase.PurgeInputData (DrainWait: LongInt);
2012-09-22 14:39:15 -07:00
Var
Buf : Array[1..2048] of Char;
2012-08-11 11:56:23 -07:00
Begin
FInBufPos := 0;
FInBufEnd := 0;
2013-02-24 20:28:11 -08:00
If DrainWait > 0 Then Begin
DrainWait := TimerSet(DrainWait);
While DataWaiting And Not TimerUp(DrainWait) Do Begin
2012-09-22 14:39:15 -07:00
ReadBuf(Buf, SizeOf(Buf));
If FInBufEnd <= 0 Then Break;
End;
2013-02-24 20:28:11 -08:00
End;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.DataWaiting : Boolean;
Begin
Result := False;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.WriteBuf (Var Buf; Len: LongInt) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
Procedure TIOBase.BufFlush;
Begin
End;
Procedure TIOBase.BufWriteChar (Ch: Char);
Begin
End;
Procedure TIOBase.BufWriteStr (Str: String);
Begin
End;
Function TIOBase.ReadChar : Char;
Begin
2013-05-06 17:07:28 -07:00
Result := #0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.PeekChar (Num: Byte) : Char;
Begin
2013-05-06 17:07:28 -07:00
Result := #0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.ReadBuf (Var Buf; Len: LongInt) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.ReadLine (Var Str: String) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.WriteStr (Str: String) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.WriteLine (Str: String) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
Function TIOBase.WaitForData (TimeOut: LongInt) : LongInt;
Begin
2013-05-06 17:07:28 -07:00
Result := 0;
2012-08-11 11:56:23 -07:00
End;
End.