Revision: 8977 https://osdn.net/projects/ttssh2/scm/svn/commits/8977 Author: zmatsuo Date: 2020-11-02 00:30:05 +0900 (Mon, 02 Nov 2020) Log Message: ----------- zmodem.c のみで使用する構造体を移動 - ttftypes.h から zmodem.c へ移動 Modified Paths: -------------- branches/proto_unicode/teraterm/common/ttftypes.h branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp branches/proto_unicode/teraterm/ttpfile/kermit.h branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp branches/proto_unicode/teraterm/ttpfile/zmodem.c branches/proto_unicode/teraterm/ttpfile/zmodem.h -------------- next part -------------- Modified: branches/proto_unicode/teraterm/common/ttftypes.h =================================================================== --- branches/proto_unicode/teraterm/common/ttftypes.h 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/common/ttftypes.h 2020-11-01 15:30:05 UTC (rev 8977) @@ -216,6 +216,7 @@ #endif +#if 0 /* ZMODEM */ typedef struct { BYTE RxHdr[4], TxHdr[4]; @@ -262,6 +263,7 @@ #define Z_PktGetHexEOL 6 #define Z_PktGetData 7 #define Z_PktGetCRC 8 +#endif /* B Plus */ typedef struct { Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:30:05 UTC (rev 8977) @@ -66,6 +66,7 @@ #include "kermit.h" #include "xmodem.h" #include "ymodem.h" +#include "zmodem.h" #if 0 #define FS_BRACKET_NONE 0 @@ -762,7 +763,9 @@ vsize = 0; break; case PROTO_ZM: - vsize = sizeof(TZVar); +// vsize = sizeof(TZVar); + ZCreate(fv); + vsize = 0; break; case PROTO_BP: vsize = sizeof(TBPVar); @@ -810,8 +813,12 @@ _ProtoSetOpt(fv, YMODEM_OPT, Opt1); break; case PROTO_ZM: +#if 0 ((PZVar)ProtoVar)->BinFlag = (Opt1 & 1) != 0; ((PZVar)ProtoVar)->ZMode = Mode; +#endif + _ProtoSetOpt(fv, ZMODEM_MODE, Mode); + _ProtoSetOpt(fv, ZMODEM_BINFLAG, (Opt1 & 1) != 0); break; case PROTO_BP: ((PBPVar)ProtoVar)->BPMode = Mode; Modified: branches/proto_unicode/teraterm/ttpfile/kermit.h =================================================================== --- branches/proto_unicode/teraterm/ttpfile/kermit.h 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/ttpfile/kermit.h 2020-11-01 15:30:05 UTC (rev 8977) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2017 TeraTerm Project + * (C) 2007-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/ttpfile/ttfile_proto.cpp 2020-11-01 15:30:05 UTC (rev 8977) @@ -66,7 +66,7 @@ fv->Init(fv,cv,ts); break; case PROTO_ZM: - ZInit(fv,(PZVar)pv,cv,ts); + fv->Init(fv,cv,ts); break; case PROTO_BP: BPInit(fv,(PBPVar)pv,cv,ts); @@ -93,7 +93,7 @@ Ok = fv->Parse(fv, cv); break; case PROTO_ZM: - Ok = ZParse(fv,(PZVar)pv,cv); + Ok = fv->Parse(fv, cv); break; case PROTO_BP: Ok = BPParse(fv,(PBPVar)pv,cv); @@ -125,7 +125,7 @@ fv->TimeOutProc(fv,cv); break; case PROTO_ZM: - ZTimeOutProc(fv,(PZVar)pv,cv); + fv->TimeOutProc(fv, cv); break; case PROTO_BP: BPTimeOutProc(fv,(PBPVar)pv,cv); @@ -149,7 +149,7 @@ fv->Cancel(fv,cv); break; case PROTO_ZM: - ZCancel((PZVar)pv); + fv->Cancel(fv, cv); break; case PROTO_BP: if (((PBPVar)pv)->BPState != BP_Failure) { Modified: branches/proto_unicode/teraterm/ttpfile/zmodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:30:05 UTC (rev 8977) @@ -60,6 +60,55 @@ #include "ttlib.h" #include "win16api.h" +#include "zmodem.h" + +/* ZMODEM */ +typedef struct { + BYTE RxHdr[4], TxHdr[4]; + BYTE RxType, TERM; + BYTE PktIn[1032], PktOut[1032]; + int PktInPtr, PktOutPtr; + int PktInCount, PktOutCount; + int PktInLen; + BOOL BinFlag; + BOOL Sending; + int ZMode, ZState, ZPktState; + int MaxDataLen, TimeOut, CanCount; + BOOL CtlEsc, CRC32, HexLo, Quoted, CRRecv; + WORD CRC; + LONG CRC3, Pos, LastPos, WinSize; + BYTE LastSent; + int TOutInit; + int TOutFin; +} TZVar; +typedef TZVar far *PZVar; + +#define Z_RecvInit 1 +#define Z_RecvInit2 2 +#define Z_RecvData 3 +#define Z_RecvFIN 4 +#define Z_SendInit 5 +#define Z_SendInitHdr 6 +#define Z_SendInitDat 7 +#define Z_SendFileHdr 8 +#define Z_SendFileDat 9 +#define Z_SendDataHdr 10 +#define Z_SendDataDat 11 +#define Z_SendDataDat2 12 +#define Z_SendEOF 13 +#define Z_SendFIN 14 +#define Z_Cancel 15 +#define Z_End 16 + +#define Z_PktGetPAD 1 +#define Z_PktGetDLE 2 +#define Z_PktHdrFrm 3 +#define Z_PktGetBin 4 +#define Z_PktGetHex 5 +#define Z_PktGetHexEOL 6 +#define Z_PktGetData 7 +#define Z_PktGetCRC 8 + #define ZPAD '*' #define ZDLE 0x18 #define ZDLEE 0x58 @@ -643,10 +692,11 @@ add_sendbuf("%s: ", __FUNCTION__); } -void ZInit(PFileVarProto fv, PZVar zv, PComVar cv, PTTSet ts) { +void ZInit(PFileVarProto fv, PComVar cv, PTTSet ts) { int Max; char uimsg[MAX_UIMSG]; const char *UILanguageFile = ts->UILanguageFile; + PZVar zv = fv->data; zv->CtlEsc = ((ts->FTFlag & FT_ZESCCTL) != 0); zv->MaxDataLen = ts->ZmodemDataLen; @@ -760,8 +810,9 @@ } } -void ZTimeOutProc(PFileVarProto fv, PZVar zv, PComVar cv) +void ZTimeOutProc(PFileVarProto fv, PComVar cv) { + PZVar zv = fv->data; switch (zv->ZState) { case Z_RecvInit: ZSendRInit(fv, zv); @@ -1172,8 +1223,9 @@ } } -BOOL ZParse(PFileVarProto fv, PZVar zv, PComVar cv) +BOOL ZParse(PFileVarProto fv, PComVar cv) { + PZVar zv = fv->data; BYTE b; int c; @@ -1420,7 +1472,46 @@ return TRUE; } -void ZCancel(PZVar zv) +void ZCancel(PFileVarProto fv, PComVar cv) { + PZVar zv = fv->data; + (void)cv; ZSendCancel(zv); } + +static int SetOptV(PFileVarProto fv, int request, va_list ap) +{ + PZVar zv = fv->data; + switch(request) { + case ZMODEM_MODE: { + int Mode = va_arg(ap, int); + zv->ZMode = Mode; + return 0; + } + case ZMODEM_BINFLAG: { + BOOL BinFlag = va_arg(ap, BOOL); + zv->BinFlag = BinFlag; + return 0; + } + } + return -1; +} + +BOOL ZCreate(PFileVarProto fv) +{ + PZVar zv; + zv = malloc(sizeof(TZVar)); + if (zv == NULL) { + return FALSE; + } + memset(zv, 0, sizeof(*zv)); + fv->data = zv; + + fv->Init = ZInit; + fv->Parse = ZParse; + fv->TimeOutProc = ZTimeOutProc; + fv->Cancel = ZCancel; + fv->SetOptV = SetOptV; + + return TRUE; +} Modified: branches/proto_unicode/teraterm/ttpfile/zmodem.h =================================================================== --- branches/proto_unicode/teraterm/ttpfile/zmodem.h 2020-11-01 15:29:51 UTC (rev 8976) +++ branches/proto_unicode/teraterm/ttpfile/zmodem.h 2020-11-01 15:30:05 UTC (rev 8977) @@ -33,11 +33,19 @@ extern "C" { #endif +enum { + ZMODEM_MODE, + ZMODEM_BINFLAG, +}; + /* prototypes */ -void ZInit(PFileVarProto fv, PZVar zv, PComVar cv, PTTSet ts); -void ZTimeOutProc(PFileVarProto fv, PZVar zv, PComVar cv); -BOOL ZParse(PFileVarProto fv, PZVar zv, PComVar cv); -void ZCancel(PZVar zv); +BOOL ZCreate(PFileVarProto fv); +#if 0 +void ZInit(PFileVarProto fv, PComVar cv, PTTSet ts); +void ZTimeOutProc(PFileVarProto fv, PComVar cv); +BOOL ZParse(PFileVarProto fv, PComVar cv); +void ZCancel(PFileVarProto fv, PComVar cv); +#endif #ifdef __cplusplus }