Begin cleanup. Rewrote lastread stuff

This commit is contained in:
mysticbbs 2012-09-26 16:49:06 -04:00
parent 3790e66463
commit 987ec8a430
1 changed files with 608 additions and 642 deletions

View File

@ -1,7 +1,7 @@
{$I M_OPS.PAS}
Unit BBS_MsgBase_Squish;
{$I M_OPS.PAS}
Interface
Uses
@ -318,15 +318,16 @@ Destructor TMsgBaseSquish.Done;
Begin
If SqInfo^.SqdOpened Then SqdClose;
If SqInfo^.SqiOpened Then SqiClose;
If SqInfo^.SqIAlloc > 0 Then
If SqIdx <> Nil Then
FreeMem(SqIdx, SqInfo^.SqiAlloc * SizeOf(SqIdxType));
FreeMem (SqIdx, SqInfo^.SqiAlloc * SizeOf(SqIdxType));
Dispose(FreeArray);
Dispose(SqInfo);
Dispose (FreeArray);
Dispose (SqInfo);
End;
Procedure TMsgBaseSquish.SetMsgPath(FN: String);
Procedure TMsgBaseSquish.SetMsgPath (FN: String);
Begin
SqInfo^.FN := FExpand(FN);
@ -379,8 +380,8 @@ End;
Function TMsgBaseSquish.SqiOpen: Boolean;
Begin
If Not SqInfo^.SqiOpened Then Begin
Assign(SqInfo^.SqiFile, SqInfo^.FN + '.sqi');
// FileMode := 66; {fmReadWrite + fmDenyNone;}
Assign (SqInfo^.SqiFile, SqInfo^.FN + '.sqi');
If Not ioReset(SqInfo^.SqiFile, SizeOf(SqIdxType), fmReadWrite + fmDenyNone) Then
SqiOpen := False
Else Begin
@ -389,7 +390,7 @@ Begin
End;
End Else
SqiOpen := True;
End;
End;
Procedure TMsgBaseSquish.CloseMsgBase;
Begin
@ -399,7 +400,7 @@ Begin
FileMode := fmRWDN; { shouldn't be needed... }
End;
Function TMsgBaseSquish.CreateMsgBase(MaxMsg: Word; MaxDays: Word): Boolean;
Function TMsgBaseSquish.CreateMsgBase (MaxMsg: Word; MaxDays: Word): Boolean;
Begin
If Not SqInfo^.SqdOpened Then Begin
FillChar(SqInfo^.SqBase, SizeOf(SqInfo^.SqBase), 0);
@ -667,28 +668,29 @@ End;
Procedure TMsgBaseSquish.LoadFree;
Var
i : Word;
Count : Word;
TmpFrame : SqFrameHdrType;
TmpPos : LongInt;
Begin
For i := 1 to MaxFree Do Begin
FreeArray^[i].FreePos := 0;
FreeArray^[i].FreeSize := 0;
For Count := 1 to MaxFree Do Begin
FreeArray^[Count].FreePos := 0;
FreeArray^[Count].FreeSize := 0;
End;
SqInfo^.FreeLoaded := True;
i := 0;
Count := 0;
TmpPos := SqInfo^.SqBase.FirstFree;
While ((TmpPos <> 0) and (i < MaxFree)) Do Begin
ReadVarFrame(TmpFrame, TmpPos);
Inc(i);
FreeArray^[i].FreeSize := TmpFrame.FrameLength;
FreeArray^[i].FreePos := TmpPos;
While ((TmpPos <> 0) and (Count < MaxFree)) Do Begin
ReadVarFrame (TmpFrame, TmpPos);
Inc (Count);
FreeArray^[Count].FreeSize := TmpFrame.FrameLength;
FreeArray^[Count].FreePos := TmpPos;
TmpPos := TmpFrame.NextFrame;
End;
SqInfo^.HighestFree := i;
SqInfo^.HighestFree := Count;
End;
Procedure TMsgBaseSquish.FindFrame (Var FL: LongInt; Var FramePos: LongInt);
@ -750,36 +752,46 @@ Begin
End;
End;
Procedure TMsgBaseSquish.KillMsg(MsgNum: LongInt);
Procedure TMsgBaseSquish.KillMsg (MsgNum: LongInt);
Var
i: Word;
KillPos: LongInt;
IndexPos: LongInt;
KillFrame: SqFrameHdrType;
TmpFrame: SqFrameHdrType;
CurrMove: LongInt;
AlreadyLocked: Boolean;
FreeCtr: Word;
i : Word;
KillPos : LongInt;
IndexPos : LongInt;
KillFrame : SqFrameHdrType;
TmpFrame : SqFrameHdrType;
CurrMove : LongInt;
AlreadyLocked : Boolean;
FreeCtr : Word;
Begin
AlreadyLocked := SqInfo^.Locked;
If Not AlreadyLocked Then
If LockMsgBase Then;
If SqIdx = Nil Then
SqInfo^.Error := 999
Else Begin
i := 1;
While ((i <= SqInfo^.SqBase.NumMsg) and (MsgNum <> SqIdx^[i].UMsgId)) Do
Inc(i);
If MsgNum = SqIdx^[i].UMsgId Then Begin
IndexPos := i;
KillPos := SqIdx^[i].Ofs;
ReadVarFrame(KillFrame, KillPos);
ReadVarFrame (KillFrame, KillPos);
If KillFrame.PrevFrame = 0 Then
SqInfo^.SqBase.BeginFrame := KillFrame.NextFrame;
If KillFrame.NextFrame = 0 Then
SqInfo^.SqBase.LastFrame := KillFrame.PrevFrame;
KillFrame.FrameType := sqFrameFree;
UnLinkFrame(KillFrame);
UnLinkFrame (KillFrame);
If ((SqInfo^.SqBase.FirstFree = 0) or (SqInfo^.SqBase.LastFree = 0)) Then Begin
SqInfo^.SqBase.FirstFree := KillPos;
SqInfo^.SqBase.LastFree := KillPos;
@ -788,30 +800,43 @@ Begin
End Else Begin
KillFrame.NextFrame := 0;
KillFrame.PrevFrame := SqInfo^.SqBase.LastFree;
ReadVarFrame(TmpFrame, SqInfo^.SqBase.LastFree);
ReadVarFrame (TmpFrame, SqInfo^.SqBase.LastFree);
TmpFrame.NextFrame := KillPos;
WriteVarFrame(TmpFrame, SqInfo^.SqBase.LastFree);
SqInfo^.SqBase.LastFree := KillPos;
End;
WriteVarFrame(KillFrame, KillPos);
FreeCtr := 1;
While ((FreeCtr < MaxFree) and (FreeArray^[FreeCtr].FreePos <> 0)) Do
Inc(FreeCtr);
If FreeArray^[FreeCtr].FreePos = 0 Then Begin
FreeArray^[FreeCtr].FreePos := KillPos;
FreeArray^[FreeCtr].FreeSize := KillFrame.FrameLength;
End;
If FreeCtr > SqInfo^.HighestFree Then
SqInfo^.HighestFree := FreeCtr;
Dec(SqInfo^.SqBase.NumMsg);
Dec(SqInfo^.SqBase.HighMsg);
Dec (SqInfo^.SqBase.NumMsg);
Dec (SqInfo^.SqBase.HighMsg);
CurrMove := IndexPos;
While CurrMove <= SqInfo^.SqBase.NumMsg Do Begin
SqIdx^[CurrMove] := SqIdx^[CurrMove + 1];
Inc(CurrMove);
Inc (CurrMove);
End;
End;
End;
If Not AlreadyLocked Then
If UnlockMsgBase Then;
End;
@ -820,8 +845,10 @@ Procedure TMsgBaseSquish.ReadMsgHdr(FPos: LongInt); {Read msg hdr for frame at F
Var
NumRead: LongInt;
Begin
Seek(SqInfo^.SqdFile, FPos + SqFSize);
Seek (SqInfo^.SqdFile, FPos + SqFSize);
SqInfo^.Error := IoResult;
If SqInfo^.Error = 0 Then Begin
If Not ioBlockRead(SqInfo^.SqdFile, SqInfo^.MsgHdr, SizeOf(SqMsgHdrType), NumRead) Then
SqInfo^.Error := ioCode;
@ -832,8 +859,10 @@ Procedure TMsgBaseSquish.WriteMsgHdr(FPos: LongInt); {Read msg hdr for frame at
Var
Res : LongInt;
Begin
Seek(SqInfo^.SqdFile, FPos + SqFSize);
Seek (SqInfo^.SqdFile, FPos + SqFSize);
SqInfo^.Error := IoResult;
If SqInfo^.Error = 0 Then Begin
If Not ioBlockWrite(SqInfo^.SqdFile, SqInfo^.MsgHdr, SizeOf(SqMsgHdrType), Res) Then
SqInfo^.Error := ioCode;
@ -844,8 +873,10 @@ Procedure TMsgBaseSquish.WriteText(FPos: LongInt); {Write text buffer for frame
Var
Res : LongInt;
Begin
Seek(SqInfo^.SqdFile, FPos + SqFSize + SqMSize);
Seek (SqInfo^.SqdFile, FPos + SqFSize + SqMSize);
SqInfo^.Error := IoResult;
If SqInfo^.Error = 0 Then Begin
If Not ioBlockWrite(SqInfo^.SqdFile, SqInfo^.MsgChars, SqInfo^.TxtCtr, Res) Then
SqInfo^.Error := ioCode;
@ -865,14 +896,18 @@ End;
Procedure TMsgBaseSquish.ReadText(FPos: LongInt);
Begin
Seek(SqInfo^.SqdFile, FPos + SqFSize + SqMSize);
SqInfo^.Error := IoResult;
If SqInfo^.Error = 0 Then Begin
If SqInfo^.Frame.MsgLength > SqTxtBufferSize Then
BlockRead(SqInfo^.SqdFile, SqInfo^.MsgChars, SqTxtBufferSize)
Else
BlockRead(SqInfo^.SqdFile, SqInfo^.MsgChars, SqInfo^.Frame.MsgLength);
SqInfo^.Error := IoResult;
End;
SqInfo^.TxtCtr := 1 + SqInfo^.Frame.ControlLength;
SqInfo^.MsgDone := False;
LastSoft := False;
@ -883,29 +918,27 @@ Begin
SqInfo^.TxtCtr := 0;
End;
Procedure TMsgBaseSquish.DoString (Str: String); {Add string to message text}
Procedure TMsgBaseSquish.DoString (Str: String);
Var
i: Word;
Count : Word;
Begin
i := 1;
While i <= Length(Str) Do Begin
DoChar(Str[i]);
Inc(i);
End;
For Count := 1 to Length(Str) Do
DoChar(Str[Count]);
End;
Procedure TMsgBaseSquish.DoChar (Ch: Char); {Add character to message text}
Begin
If SqInfo^.TxtCtr < SqTxtBufferSize Then Begin
Inc(SqInfo^.TxtCtr);
Inc (SqInfo^.TxtCtr);
SqInfo^.MsgChars[SqInfo^.TxtCtr] := Ch;
End;
End;
Procedure TMsgBaseSquish.DoStringLn(Str: String); {Add string and newline to msg text}
Begin
DoString(Str);
DoChar(#13);
DoString (Str);
DoChar (#13);
End;
Procedure TMsgBaseSquish.KillExcess;
@ -940,35 +973,49 @@ Var
AlreadyLocked : Boolean;
Begin
DoChar(#0);
TmpDT.Year := strS2I(Copy(SqInfo^.StrDate,7,2));
If TmpDT.Year > 79 Then
Inc(TmpDT.Year, 1900)
Inc (TmpDT.Year, 1900)
Else
Inc(TmpDT.Year, 2000);
Inc (TmpDT.Year, 2000);
TmpDT.Month := strS2I(Copy(SqInfo^.StrDate,1,2));
TmpDT.Day := strS2I(Copy(SqInfo^.StrDate,4,2));
TmpDt.Hour := strS2I(Copy(SqInfo^.StrTime,1,2));
TmpDt.Min := strS2I(Copy(SqInfo^.StrTime, 4,2));
TmpDt.Sec := 0;
TmpStr := FormattedDate(TmpDT, 'DD NNN YY ') + Copy(SqInfo^.StrTime, 1, 5) + ':00';
PackTime(TmpDT, TmpDate);
PackTime (TmpDT, TmpDate);
SqInfo^.MsgHdr.DateWritten := (TmpDate shr 16) + ((TmpDate and $ffff) shl 16);
TmpDate := CurDateDos;
SqInfo^.MsgHdr.DateArrived := (TmpDate shr 16) + ((TmpDate and $ffff) shl 16);
Str2AZ(TmpStr, 20, SqInfo^.MsgHdr.AZDate);
AlreadyLocked := SqInfo^.Locked;
If Not AlreadyLocked Then
If LockMsgBase Then;
If SqInfo^.Locked Then Begin
MsgSize := SqInfo^.TxtCtr + SqMSize;
FrameSize := MsgSize;
FindFrame(FrameSize, FramePos);
FindFrame (FrameSize, FramePos);
If SqInfo^.SqBase.LastFrame <> 0 Then Begin
ReadVarFrame(TmpFrame, SqInfo^.SqBase.LastFrame);
ReadVarFrame (TmpFrame, SqInfo^.SqBase.LastFrame);
TmpFrame.NextFrame := FramePos;
WriteVarFrame(TmpFrame, SqInfo^.SqBase.LastFrame);
TmpFrame.PrevFrame := SqInfo^.SqBase.LastFrame;
End Else Begin
SqInfo^.SqBase.BeginFrame := FramePos;
@ -997,11 +1044,11 @@ Begin
SqInfo^.Error := 999;
WriteMsg := 999;
End Else Begin
WriteVarFrame(TmpFrame, FramePos);
WriteMsgHdr(FramePos);
WriteText(FramePos);
WriteVarFrame (TmpFrame, FramePos);
WriteMsgHdr (FramePos);
WriteText (FramePos);
Inc(SqInfo^.SqBase.NumMsg);
Inc (SqInfo^.SqBase.NumMsg);
SqIdx^[SqInfo^.SqBase.NumMsg].Ofs := FramePos;
SqIdx^[SqInfo^.SqBase.NumMsg].UMsgId := SqInfo^.SqBase.UID;
@ -1017,81 +1064,32 @@ Begin
WriteMsg := 0;
End;
If Not AlreadyLocked Then
If UnLockMsgBase Then;
End Else
WriteMsg := 5;
End;
(*
Function TMsgBaseSquish.GetString (MaxLen : Word) : String;
Var
StartSoft : Boolean;
Str : String;
Ch : Char;
WLen : Byte;
WPos : Word;
Begin
StartSoft := LastSoft;
LastSoft := True;
WLen := 0;
WPos := 0;
Str := '';
While (Length(Str) < MaxLen) and (not SqInfo^.MsgDone) Do Begin
Ch := GetChar;
Case Ch of
#00,
#13 : Begin
LastSoft := True;
Break;
End;
#10,
#141: ;
#32 : If (Str <> '') or (Not StartSoft) Then Begin
Str := Str + Ch;
WLen := Length(Str);
WPos := SqInfo^.TxtCtr;
End Else
StartSoft := False;
Else
Str := Str + Ch;
End;
End;
If (Not (Ch in [#00, #13])) and (Not SqInfo^.MsgDone) Then
If WLen = 0 Then
Dec(SqInfo^.TxtCtr)
Else Begin
Str[0] := Chr(WLen);
SqInfo^.TxtCtr := WPos;
End;
GetString := Str;
End;
*)
Function TMsgBaseSquish.GetString(MaxLen: Word): String;
Function TMsgBaseSquish.GetString (MaxLen: Word): String;
Var
WPos : Word;
WLen : Byte;
StrDone : Boolean;
// TxtOver : Boolean;
StartSoft : Boolean;
CurrLen : Word;
// PPos : Word;
TmpCh : Char;
Begin
StrDone := False;
CurrLen := 0;
// PPos := SqInfo^.TxtCtr;
WPos := 0;
WLen := 0;
StartSoft := LastSoft;
LastSoft := True;
{ TmpCh := GetChar;}
While ((Not StrDone) And (CurrLen < MaxLen) And (Not SqInfo^.MsgDone)) Do Begin
TmpCh := GetChar;
Case TmpCh of
#00,
#13 : Begin
@ -1102,7 +1100,7 @@ Begin
#141: ;
#32 : Begin
If ((CurrLen <> 0) or (Not StartSoft)) Then Begin
Inc(CurrLen);
Inc (CurrLen);
WLen := CurrLen;
GetString[CurrLen] := TmpCh;
WPos := SqInfo^.TxtCtr;
@ -1113,7 +1111,6 @@ Begin
Inc(CurrLen);
GetString[CurrLen] := TmpCh;
End;
{ If Not StrDone Then TmpCh := GetChar;}
End;
If StrDone Then Begin
@ -1137,13 +1134,6 @@ Begin
EOM := (SqInfo^.TxtCtr >= SqInfo^.Frame.MsgLength) or (SqInfo^.MsgChars[SqInfo^.TxtCtr] = #0);
End;
(*
Function TMsgBaseSquish.WasWrap: Boolean;
Begin
WasWrap := LastSoft;
End;
*)
Function TMsgBaseSquish.GetChar: Char;
Begin
If (SqInfo^.TxtCtr >= SqInfo^.Frame.MsgLength) or (SqInfo^.MsgChars[SqInfo^.TxtCtr] = #0) Then Begin
@ -1151,11 +1141,11 @@ Begin
SqInfo^.MsgDone := True;
End Else Begin
GetChar := SqInfo^.MsgChars[SqInfo^.TxtCtr];
Inc(SqInfo^.TxtCtr);
End;
End;
Function TMsgBaseSquish.GetHighWater: LongInt; {Get high water umsgid}
Begin
GetHighWater := LongInt(SqInfo^.SqBase.HighWater);
@ -1173,14 +1163,19 @@ Begin
If SqInfo^.SqiAlloc > 0 Then
If SqIdx <> Nil Then
FreeMem(SqIdx, SqInfo^.SqiAlloc * SizeOf(SqIdxType));
SqInfo^.SqiAlloc := FileSize(SqInfo^.SqiFile) + 100;
If SqInfo^.SqiAlloc > SqIdxArraySize Then
SqInfo^.SqiAlloc := SqIdxArraySize ;
GetMem(SqIdx, SqInfo^.SqiAlloc * SizeOf(SqIdxType));
SqInfo^.SqiAlloc := SqIdxArraySize;
GetMem (SqIdx, SqInfo^.SqiAlloc * SizeOf(SqIdxType));
If SqIdx = nil Then
SqInfo^.Error := 999
Else Begin
Seek(SqInfo^.SqiFile, 0);
If IoResult = 0 Then Begin
If Not ioBlockRead(SqInfo^.SqiFile, SqIdx^, SqInfo^.SqiAlloc, NumRead) Then
SqInfo^.Error := ioCode;
@ -1196,8 +1191,9 @@ Begin
If SqIdx = nil Then
SqInfo^.Error := 999
Else Begin
Seek(SqInfo^.SqiFile, 0);
Truncate(SqInfo^.SqiFile);
Seek (SqInfo^.SqiFile, 0);
Truncate (SqInfo^.SqiFile);
If IoResult = 0 Then Begin
If Not ioBlockWrite(SqInfo^.SqiFile, SqIdx^, SqInfo^.SqBase.NumMsg, Res) Then
SqInfo^.Error := ioCode;
@ -1209,30 +1205,32 @@ End;
Procedure TMsgBaseSquish.SeekFirst(MsgNum: LongInt);
Begin
SqInfo^.CurrIdx := 1;
ReadIdx;
While ((SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg) and
(MsgNum > LongInt(SqIdx^[SqInfo^.CurrIdx].UMsgId))) Do
While ((SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg) and (MsgNum > LongInt(SqIdx^[SqInfo^.CurrIdx].UMsgId))) Do
SeekNext;
End;
Function TMsgBaseSquish.IdxHighest: LongInt;
Var
i: Word;
Tmp: LongInt;
i : Word;
Tmp : LongInt;
Begin
Tmp := 0;
i := 1;
While i <= SqInfo^.SqBase.NumMsg Do Begin
If SqIdx^[i].UMsgId > Tmp Then Tmp := SqIdx^[i].UMsgId;
Inc(i);
End;
IdxHighest := Tmp;
End;
Function TMsgBaseSquish.GetMsgNum: LongInt;
Begin
If ((SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg) and
(SqInfo^.CurrIdx > 0)) Then
If ((SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg) and (SqInfo^.CurrIdx > 0)) Then
GetMsgNum := LongInt(SqIdx^[SqInfo^.CurrIdx].UMsgId)
Else
GetMsgNum := -1;
@ -1244,33 +1242,33 @@ Begin
End;
Procedure TMsgBaseSquish.SeekPrior;
Begin
Begin
If SqInfo^.CurrIdx > 1 Then
Dec(SqInfo^.CurrIdx)
Else
SqInfo^.CurrIdx := 0;
End;
End;
Function TMsgBaseSquish.SeekFound: Boolean;
Begin
Begin
SeekFound := GetMsgNum >= 0;
End;
End;
Function TMsgBaseSquish.GetIdxFramePos: LongInt;
Begin
Begin
If SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg Then
GetIdxFramePos := SqIdx^[SqInfo^.CurrIdx].Ofs
Else
GetIdxFramePos := -1;
End;
End;
Function TMsgBaseSquish.GetIdxHash: LongInt;
Begin
Begin
If SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg Then
GetIdxHash := SqIdx^[SqInfo^.CurrIdx].Hash
Else
GetIdxHash := 0;
End;
End;
Function TMsgBaseSquish.IsLocal: Boolean; {Is current msg local}
Begin
@ -1297,21 +1295,6 @@ Begin
IsFAttach := ((SqInfo^.MsgHdr.Attr and SqMsgFile) <> 0);
End;
//Function TMsgBaseSquish.IsReqRct: Boolean; {Is current msg request receipt}
//Begin
// IsReqRct := ((SqInfo^.MsgHdr.Attr and SqMsgRRQ) <> 0);
//End;
//Function TMsgBaseSquish.IsReqAud: Boolean; {Is current msg request audit}
//Begin
// IsReqAud := ((SqInfo^.MsgHdr.Attr and SqMsgArq) <> 0);
//End;
//Function TMsgBaseSquish.IsRetRct: Boolean; {Is current msg a return receipt}
//Begin
// IsRetRct := ((SqInfo^.MsgHdr.Attr and SqMsgCpt) <> 0);
//End;
Function TMsgBaseSquish.IsFileReq: Boolean; {Is current msg a file request}
Begin
IsFileReq := ((SqInfo^.MsgHdr.Attr and SqMsgFreq) <> 0);
@ -1434,13 +1417,12 @@ Procedure TMsgBaseSquish.MsgStartUp;
Begin
SqInfo^.CurrentFramePos := GetIdxFramePos;
SqInfo^.CurrentUID := SqIdx^[SqInfo^.CurrIdx].UMsgId;
ReadFrame(SqInfo^.CurrentFramePos);
ReadMsgHdr(SqInfo^.CurrentFramePos);
ReadFrame (SqInfo^.CurrentFramePos);
ReadMsgHdr (SqInfo^.CurrentFramePos);
End;
Procedure TMsgBaseSquish.MsgTxtStartUp;
//Var
// CFrame: LongInt;
Begin
ReadText(SqInfo^.CurrentFramePos);
End;
@ -1449,11 +1431,6 @@ Procedure TMsgBaseSquish.SetMailType(MT: MsgMailType);
Begin
End;
//Function TMsgBaseSquish.GetSubArea: Word;
//Begin
// GetSubArea := 0;
//End;
Procedure TMsgBaseSquish.ReWriteHdr;
Var
AlreadyLocked : Boolean;
@ -1464,8 +1441,8 @@ Begin
If Not AlreadyLocked Then
If LockMsgBase Then;
WriteFrame(SqInfo^.CurrentFramePos);
WriteMsgHdr(SqInfo^.CurrentFramePos);
WriteFrame (SqInfo^.CurrentFramePos);
WriteMsgHdr (SqInfo^.CurrentFramePos);
i := 1;
@ -1498,33 +1475,18 @@ Begin
NumberOfMsgs := 0;
End;
Function TMsgBaseSquish.GetLastRead(UNum: LongInt): LongInt;
Var
LRec: LongInt;
Function TMsgBaseSquish.GetLastRead (UNum: LongInt) : LongInt;
Begin
If ((UNum + 1) * SizeOf(LRec)) > GetFileSize(SqInfo^.FN + '.sql') Then
GetLastRead := 0
Else Begin
If LoadFilePos(SqInfo^.FN + '.sql', LRec, SizeOf(LRec), UNum * SizeOf(LRec)) = 0 Then
GetLastRead := LRec
Else
GetLastRead := 0;
End;
If LoadFilePos(SqInfo^.FN + '.sql', Result, 4, UNum * 4) <> 0 Then
Result := 0;
End;
Procedure TMsgBaseSquish.SetLastRead(UNum: LongInt; LR: LongInt);
Var
LRec : LongInt;
Status : Word;
Procedure TMsgBaseSquish.SetLastRead (UNum: LongInt; LR: LongInt);
Begin
Status := 0;
If ((UNum + 1) * SizeOf(LRec)) > GetFileSize(SqInfo^.FN + '.sql') Then Begin
Status := ExtendFile(SqInfo^.FN + '.sql', (UNum + 1) * SizeOf(LRec));
End;
LRec := LR;
If Status = 0 Then
Status := SaveFilePos(SqInfo^.FN + '.sql', LRec, SizeOf(LRec),
UNum * SizeOf(LRec));
If ((UNum + 1) * SizeOf(LR)) > GetFileSize(SqInfo^.FN + '.sql') Then
ExtendFile (SqInfo^.FN + '.sql', (UNum + 1) * SizeOf(LR));
SaveFilePos (SqInfo^.FN + '.sql', LR, SizeOf(LR), UNum * SizeOf(LR));
End;
Function TMsgBaseSquish.GetMsgLoc: LongInt;
@ -1537,14 +1499,17 @@ Begin
SeekFirst(ML);
End;
Procedure TMsgBaseSquish.YoursFirst(Name: String; Handle: String);
Procedure TMsgBaseSquish.YoursFirst (Name: String; Handle: String);
Begin
SqInfo^.CurrIdx := 0;
ReadIdx;
SqInfo^.SName := strUpper(Name);
SqInfo^.SHandle := strUpper(Handle);
SqInfo^.HName := SqHashName(Name);
SqInfo^.HHandle := SqHashName(Handle);
YoursNext;
End;
@ -1553,19 +1518,20 @@ Var
WasFound: Boolean;
Begin
WasFound := False;
Inc(SqInfo^.CurrIdx);
Inc (SqInfo^.CurrIdx);
While ((SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg) and (Not WasFound)) Do Begin
While ((SqIdx^[SqInfo^.CurrIdx].Hash <> SqInfo^.HName) And
(SqIdx^[SqInfo^.CurrIdx].Hash <> SqInfo^.HHandle) And
(SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg)) Do
While ((SqIdx^[SqInfo^.CurrIdx].Hash <> SqInfo^.HName) And (SqIdx^[SqInfo^.CurrIdx].Hash <> SqInfo^.HHandle) And (SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg)) Do
Inc(SqInfo^.CurrIdx);
If SqInfo^.CurrIdx <= SqInfo^.SqBase.NumMsg Then Begin
MsgStartUp;
If ((Not IsRcvd) and
((strUpper(GetTo) = SqInfo^.SName) or (strUpper(GetTo) = SqInfo^.SHandle))) Then
If ((Not IsRcvd) and ((strUpper(GetTo) = SqInfo^.SName) or (strUpper(GetTo) = SqInfo^.SHandle))) Then
WasFound := True
Else
Inc(SqInfo^.CurrIdx);
Inc (SqInfo^.CurrIdx);
End;
End;
End;
@ -1605,7 +1571,7 @@ Begin
WriteMsg;
*)
rewritehdr;
ReWriteHdr;
End;
End.