diff --git a/mdl/m_datetime.pas b/mdl/m_datetime.pas index e7d4674..99fecf0 100644 --- a/mdl/m_datetime.pas +++ b/mdl/m_datetime.pas @@ -364,12 +364,12 @@ Begin YearStr := strI2S(DT.Year); Result := strReplace(Result, 'YYYY', YearStr); Result := strReplace(Result, 'YY', Copy(YearStr, 3, 2)); - Result := strReplace(Result, 'MM', strZero(DT.Month)) + - strReplace(Result, 'DD', strZero(DT.Day)) + - strReplace(Result, 'HH', strZero(DT.Hour)) + - strReplace(Result, 'II', strZero(DT.Min)) + - strReplace(Result, 'SS', strZero(DT.Sec)) + - strReplace(Result, 'NNN', MonthString[DT.Month]); + Result := strReplace(Result, 'MM', strZero(DT.Month)); + Result := strReplace(Result, 'DD', strZero(DT.Day)); + Result := strReplace(Result, 'HH', strZero(DT.Hour)); + Result := strReplace(Result, 'II', strZero(DT.Min)); + Result := strReplace(Result, 'SS', strZero(DT.Sec)); + Result := strReplace(Result, 'NNN', MonthString[DT.Month]); End; End. diff --git a/mdl/m_prot_base.pas b/mdl/m_prot_base.pas index de922a2..773114d 100644 --- a/mdl/m_prot_base.pas +++ b/mdl/m_prot_base.pas @@ -396,7 +396,7 @@ End; procedure AbstractProtocol.PrepareReceivePart; {-Parent-level inits for derived protocols} begin - GotOneFile := False; + GotOneFile := False; ProtocolStatus := ecOk; end; @@ -412,13 +412,14 @@ End; State : ProtocolStateType; begin PrepareReceivePart; - if ProtocolStatus <> ecOk then - Exit; + + if ProtocolStatus <> ecOk then exit; + repeat State := ProtocolReceivePart; aport.bufflush; - until State = psFinished; + until (State = psFinished) or not aport.connected; end; procedure AbstractProtocol.apResetStatus; diff --git a/mdl/m_prot_zmodem.pas b/mdl/m_prot_zmodem.pas index 612071f..375a7bc 100644 --- a/mdl/m_prot_zmodem.pas +++ b/mdl/m_prot_zmodem.pas @@ -704,7 +704,7 @@ Hex: begin ProtocolStatus := ecNoHeader; - while APort.DataWaiting do begin + while aport.connected and APort.DataWaiting do begin {Only get the next char if we don't know the header type yet} case HeaderState of hsNone, hsGotZPad, hsGotZDle : @@ -1095,7 +1095,7 @@ Begin StatusTimer := TimerSet(StatusInterval); - APort.PurgeInputdata(0); + APort.PurgeInputData(0); HeaderType := ZrInit; ZmodemState := rzRqstFile; @@ -1131,7 +1131,7 @@ Begin rzWaitFile, rzStartData, rzWaitEof : Begin - If Not APort.DataWaiting Then + If Not APort.DataWaiting {And APort.Connected} Then APort.WaitForData(1000); If APort.DataWaiting Then Begin @@ -1202,9 +1202,11 @@ Begin ZmodemState := rzError; end else if TimerUp(ReplyTimer) then begin Inc(BlockErrors); + if BlockErrors < HandshakeRetry then begin PutHexHeader(ZNak); - ReplyTimer := TimerSet(HandshakeWait); + + ReplyTimer := TimerSet(HandshakeWait); ZmodemState := rzWaitFile; HeaderState := hsNone; end else @@ -1362,9 +1364,12 @@ Begin end; else begin {Fatal error opening file} SaveStatus := ProtocolStatus; + CancelTransfer; + ProtocolStatus := SaveStatus; - ZModemState := rzError; + ZModemState := rzError; + goto ExitPoint; end; end; @@ -1681,7 +1686,7 @@ Begin end; ExitPoint: - {Set function result} + case ZmodemState of rzRqstFile, rzSendInit, @@ -2485,7 +2490,7 @@ Begin If ConvertToLower Then PacketStr := strLower(PacketStr); - PacketStr := PacketStr + #0 + strI2S(SrcFileLen); + PacketStr := PacketStr + #0 + strI2S(SrcFileLen) + #0; PacketLen := Length(PacketStr); Move(PacketStr[1], DataBlock^, PacketLen); diff --git a/mdl/m_protocol_queue.pas b/mdl/m_protocol_queue.pas index 6f10593..cf2d816 100644 --- a/mdl/m_protocol_queue.pas +++ b/mdl/m_protocol_queue.pas @@ -34,7 +34,7 @@ Type Constructor Create; Destructor Destroy; Override; - Function Add (fPath, fName, fNew: String) : Boolean; + Function Add (CheckValid: Boolean; fPath, fName, fNew: String) : Boolean; Procedure Delete (Idx: Word); Procedure Clear; Function Next : Boolean; @@ -56,7 +56,7 @@ Begin Clear; End; -Function TProtocolQueue.Add (fPath, fName, fNew: String) : Boolean; +Function TProtocolQueue.Add (CheckValid: Boolean; fPath, fName, fNew: String) : Boolean; Var F : File; Begin @@ -87,14 +87,14 @@ Begin Inc (QFSize, QData[QSize]^.FileSize); Close(F); - End Else Begin + End Else + If CheckValid Then Begin Dispose (QData[QSize]); Dec (QSize); Exit; - - // QData[QSize]^.Status := QueueNoFile; - End; + End Else + QData[QSize]^.Status := QueueNoFile; Result := True; End; diff --git a/mdl/m_protocol_zmodem.pas b/mdl/m_protocol_zmodem.pas index df9545c..5150507 100644 --- a/mdl/m_protocol_zmodem.pas +++ b/mdl/m_protocol_zmodem.pas @@ -1481,7 +1481,7 @@ Begin {$IFDEF ZDEBUG} ZLog('ZRecvFile -> File:' + FName); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZRecvFile -> Size:' + strI2S(FSize)); {$ENDIF} - Queue.Add(ReceivePath, FName, ''); + Queue.Add(False, ReceivePath, FName, ''); Queue.QData[Queue.QSize]^.FileSize := FSize; Queue.QData[Queue.QSize]^.Status := QueueIntransit;