Revision: 8979 https://osdn.net/projects/ttssh2/scm/svn/commits/8979 Author: zmatsuo Date: 2020-11-02 00:30:42 +0900 (Mon, 02 Nov 2020) Log Message: ----------- Quickvan.c のみで使用する構造体を移動 - ttftypes.h から Quickvan.c へ移動 Modified Paths: -------------- branches/proto_unicode/teraterm/common/ttftypes.h branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp branches/proto_unicode/teraterm/ttpfile/quickvan.c branches/proto_unicode/teraterm/ttpfile/quickvan.h branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp -------------- next part -------------- Modified: branches/proto_unicode/teraterm/common/ttftypes.h =================================================================== --- branches/proto_unicode/teraterm/common/ttftypes.h 2020-11-01 15:30:20 UTC (rev 8978) +++ branches/proto_unicode/teraterm/common/ttftypes.h 2020-11-01 15:30:42 UTC (rev 8979) @@ -319,6 +319,7 @@ #endif +#if 0 /* Quick-VAN */ typedef struct { BYTE PktIn[142], PktOut[142]; @@ -363,3 +364,5 @@ #define QVpktSTX 5 #define QVpktCR 6 + +#endif Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:30:20 UTC (rev 8978) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:30:42 UTC (rev 8979) @@ -68,6 +68,7 @@ #include "ymodem.h" #include "zmodem.h" #include "bplus.h" +#include "quickvan.h" #if 0 #define FS_BRACKET_NONE 0 @@ -774,7 +775,9 @@ vsize = 0; break; case PROTO_QV: - vsize = sizeof(TQVVar); +// vsize = sizeof(TQVVar); + QVCreate(fv); + vsize = 0; break; default: vsize = 0; @@ -830,7 +833,10 @@ _ProtoSetOpt(fv, BPLUS_MODE, Mode); break; case PROTO_QV: +#if 0 ((PQVVar)ProtoVar)->QVMode = Mode; +#endif + _ProtoSetOpt(fv, QUICKVAN_MODE, Mode); break; } @@ -861,9 +867,12 @@ PtDlg = NULL; ::KillTimer(FileVar->HMainWin,IdProtoTimer); - if ((ProtoId==PROTO_QV) && - (((PQVVar)ProtoVar)->QVMode==IdQVSend)) - CommTextOut(&cv,"\015",1); + { // Quick-VAN special code + //if ((ProtoId==PROTO_QV) && + // (((PQVVar)ProtoVar)->QVMode==IdQVSend)) + if (FileVar->OpId == OpQVSend) + CommTextOut(&cv,"\015",1); + } if (FileVar->LogFlag) CloseHandle(FileVar->LogFile); FileVar->LogFile = 0; Modified: branches/proto_unicode/teraterm/ttpfile/quickvan.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:30:20 UTC (rev 8978) +++ branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:30:42 UTC (rev 8979) @@ -44,6 +44,53 @@ #include "ttcommon.h" #include "win16api.h" +#include "quickvan.h" + +/* Quick-VAN */ +typedef struct { + BYTE PktIn[142], PktOut[142]; + int PktInCount, PktInPtr; + int PktOutCount, PktOutPtr, PktOutLen; + WORD Ver, WinSize; + WORD QVMode, QVState, PktState; + WORD AValue; + WORD SeqNum; + WORD FileNum; + int RetryCount; + BOOL CanFlag; + WORD Year,Month,Day,Hour,Min,Sec; + WORD SeqSent, WinEnd, FileEnd; + BOOL EnqFlag; + BYTE CheckSum; +} TQVVar; +typedef TQVVar far *PQVVar; + + /* Quick-VAN states */ +#define QV_RecvInit1 1 +#define QV_RecvInit2 2 +#define QV_RecvData 3 +#define QV_RecvDataRetry 4 +#define QV_RecvNext 5 +#define QV_RecvEOT 6 +#define QV_Cancel 7 +#define QV_Close 8 + +#define QV_SendInit1 11 +#define QV_SendInit2 12 +#define QV_SendInit3 13 +#define QV_SendData 14 +#define QV_SendDataRetry 15 +#define QV_SendNext 16 +#define QV_SendEnd 17 + +#define QVpktSOH 1 +#define QVpktBLK 2 +#define QVpktBLK2 3 +#define QVpktDATA 4 + +#define QVpktSTX 5 +#define QVpktCR 6 + #define TimeOutCAN 1 #define TimeOutCANSend 2 #define TimeOutRecv 20 @@ -114,10 +161,10 @@ qv->QVState = QV_Close; } -void QVInit - (PFileVarProto fv, PQVVar qv, PComVar cv, PTTSet ts) +void QVInit(PFileVarProto fv, PComVar cv, PTTSet ts) { char uimsg[MAX_UIMSG]; + PQVVar qv = fv->data; UILanguageFile = ts->UILanguageFile; qv->WinSize = ts->QVWinSize; @@ -166,9 +213,10 @@ } } -void QVCancel(PFileVarProto fv, PQVVar qv, PComVar cv) +void QVCancel(PFileVarProto fv, PComVar cv) { BYTE b; + PQVVar qv = fv->data; if ((qv->QVState==QV_Close) || (qv->QVState==QV_RecvEOT) || @@ -198,7 +246,7 @@ qv->RetryCount--; if (qv->RetryCount<=0) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return TRUE; } else @@ -263,8 +311,9 @@ qv->QVState = QV_RecvNext; } -void QVTimeOutProc(PFileVarProto fv, PQVVar qv, PComVar cv) +void QVTimeOutProc(PFileVarProto fv, PComVar cv) { + PQVVar qv = fv->data; if ((qv->QVState==QV_Cancel) || (qv->QVState==QV_RecvEOT)) { @@ -274,7 +323,7 @@ if (qv->QVMode==IdQVSend) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } @@ -696,7 +745,7 @@ break; } if (! Ok) - QVCancel(fv,qv,cv); + QVCancel(fv,cv); } else { /* VDAT block */ if ((qv->QVState != QV_RecvData) && @@ -804,7 +853,7 @@ qv->FileEnd++; } else { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } @@ -813,7 +862,7 @@ fv->FileOpen = fv->FileHandle != INVALID_HANDLE_VALUE; if (! fv->FileOpen) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } /* file no. */ @@ -943,7 +992,7 @@ } if (! Ok) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } @@ -964,7 +1013,7 @@ b = qv->PktIn[i]; if ((b<0x30) || (b>0x39)) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } qv->SeqNum = qv->SeqNum * 10 + (WORD)(b - 0x30); @@ -972,7 +1021,7 @@ if (qv->SeqNum >= qv->FileEnd) { - QVCancel(fv,qv,cv); + QVCancel(fv,cv); return; } @@ -1061,7 +1110,7 @@ QVSendVFILE(fv,qv,cv); } else - QVCancel(fv,qv,cv); + QVCancel(fv,cv); } BOOL QVSendPacket(PFileVarProto fv, PQVVar qv, PComVar cv) @@ -1243,3 +1292,47 @@ return TRUE; } + +BOOL QVParse(PFileVarProto fv, PComVar cv) +{ + PQVVar qv = fv->data; + switch (qv->QVMode) { + case IdQVReceive: + return QVReadPacket(fv,qv,cv); + case IdQVSend: + return QVSendPacket(fv,qv,cv); + default: + return FALSE; + } +} + +static int SetOptV(PFileVarProto fv, int request, va_list ap) +{ + PQVVar qv = fv->data; + switch(request) { + case QUICKVAN_MODE: { + int Mode = va_arg(ap, int); + qv->QVMode = Mode; + return 0; + } + } + return -1; +} + +BOOL QVCreate(PFileVarProto fv) +{ + PQVVar qv = malloc(sizeof(*qv)); + if (qv == NULL) { + return FALSE; + } + memset(qv, 0, sizeof(*qv)); + fv->data = qv; + + fv->Init = QVInit; + fv->Parse = QVParse; + fv->TimeOutProc = QVTimeOutProc; + fv->Cancel = QVCancel; + fv->SetOptV = SetOptV; + + return TRUE; +} Modified: branches/proto_unicode/teraterm/ttpfile/quickvan.h =================================================================== --- branches/proto_unicode/teraterm/ttpfile/quickvan.h 2020-11-01 15:30:20 UTC (rev 8978) +++ branches/proto_unicode/teraterm/ttpfile/quickvan.h 2020-11-01 15:30:42 UTC (rev 8979) @@ -33,12 +33,20 @@ extern "C" { #endif +enum { + QUICKVAN_MODE, +}; + /* prototypes */ -void QVInit(PFileVarProto fv, PQVVar qv, PComVar cv, PTTSet ts); -void QVCancel(PFileVarProto fv, PQVVar qv, PComVar cv); -void QVTimeOutProc(PFileVarProto fv, PQVVar qv, PComVar cv); -BOOL QVReadPacket(PFileVarProto fv, PQVVar qv, PComVar cv); -BOOL QVSendPacket(PFileVarProto fv, PQVVar qv, PComVar cv); +BOOL QVCreate(PFileVarProto fv); +#if 0 +void QVInit(PFileVarProto fv, PComVar cv, PTTSet ts); +void QVCancel(PFileVarProto fv, PComVar cv); +void QVTimeOutProc(PFileVarProto fv, PComVar cv); +BOOL QVParse(PFileVarProto fv, PComVar cv); +#endif +//BOOL QVReadPacket(PFileVarProto fv, PQVVar qv, PComVar cv); +//BOOL QVSendPacket(PFileVarProto fv, PQVVar qv, PComVar cv); #ifdef __cplusplus } Modified: branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp 2020-11-01 15:30:20 UTC (rev 8978) +++ branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp 2020-11-01 15:30:42 UTC (rev 8979) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2005-2019 TeraTerm Project + * (C) 2005-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ fv->Init(fv,cv,ts); break; case PROTO_QV: - QVInit(fv,(PQVVar)pv,cv,ts); + fv->Init(fv,cv,ts); break; } } @@ -99,14 +99,7 @@ Ok = fv->Parse(fv, cv); break; case PROTO_QV: - switch (((PQVVar)pv)->QVMode) { - case IdQVReceive: - Ok = QVReadPacket(fv,(PQVVar)pv,cv); - break; - case IdQVSend: - Ok = QVSendPacket(fv,(PQVVar)pv,cv); - break; - } + Ok = fv->Parse(fv,cv); break; } return Ok; @@ -131,7 +124,7 @@ fv->TimeOutProc(fv, cv); break; case PROTO_QV: - QVTimeOutProc(fv,(PQVVar)pv,cv); + fv->TimeOutProc(fv,cv); break; } } @@ -155,7 +148,7 @@ fv->Cancel(fv, cv); break; case PROTO_QV: - QVCancel(fv,(PQVVar)pv,cv); + fv->Cancel(fv,cv); break; } return TRUE;