• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

COM ポート遅延再接続プラグイン for Tera Term


Commit MetaInfo

Revision81ae4026692859a5d761272b58b258d560e428fe (tree)
Time2020-11-23 16:37:52
Authortomo3136 <tomo3136@loca...>
Commitertomo3136

Log Message

ttset構造体で無理やり対応

Change Summary

Incremental Difference

--- a/ttxreconnect.c
+++ b/ttxreconnect.c
@@ -13,6 +13,32 @@
1313
1414 #include "compat_w95.h"
1515
16+#if ((TT_VERSION_MAJOR * 10000 + TT_VERSION_MINOR) < 40105)
17+#error "not support build version"
18+#endif
19+
20+static WORD tt_version = 0;
21+
22+/* common */
23+#define TT_VER(ver, rev) (ver * 10000 + rev)
24+#define TT_POS_P(pts, ref, nm) ((void *)&(pts->ref) <= (void *)&(pts->nm))
25+
26+#define TT_OLD_P(ver, rev) (tt_version < TT_VER(ver, rev))
27+#define TT_OFFSET(ver, rev, ref, v, pts, nm) \
28+ ((TT_OLD_P(ver, rev) && TT_POS_P(pts, ref, nm)) ? (v) : 0)
29+
30+/* ttset addjust */
31+#define TS_ADJ(pts, nm) ( \
32+ TT_OFFSET(4, 105, UseNormalBGColor, 4, pts, nm))
33+
34+/* comvar addjust */
35+#define CV_ADJ(pts, pcv, nm) ( \
36+ TT_OFFSET(4, 105, xxx, 0, pcv, nm))
37+
38+/* wrapper */
39+#define TS(pts, nm) (((PTTSet)((char *)pts - (TS_ADJ(pts, nm))))->nm)
40+#define CV(pcv, nm) (((PComVar)((char *)pcv - (CV_ADJ(pcv, nm))))->nm)
41+
1642 #define ORDER 6030
1743
1844 #define INISECTION "TTXReconnect"
@@ -34,7 +60,6 @@ typedef struct
3460 BOOL ConnectMsg;
3561 BOOL Reconnect;
3662 UINT ReconnectWait;
37- WORD AutoComPortReconnect;
3863
3964 } TInstVar;
4065
@@ -66,8 +91,6 @@ static void PASCAL TTXReadIniFile(PCHAR fn, PTTSet ts)
6691 (pvar->origReadIniFile)(fn, ts);
6792 GetPrivateProfileString(INISECTION, "ReconnectWait", "", buf, sizeof(buf), fn);
6893 pvar->ReconnectWait = atoi(buf);
69- GetPrivateProfileString("Tera Term", "AutoComPortReconnect", "", buf, sizeof(buf), fn);
70- pvar->AutoComPortReconnect = (_strcmpi(buf, "on") == 0) ? TRUE : FALSE;
7194 }
7295
7396 static void PASCAL TTXGetSetupHooks(TTXSetupHooks *hooks)
@@ -146,7 +169,7 @@ static void PASCAL TTXOpenFile(TTXFileHooks *hooks)
146169 Sleep(pvar->ReconnectWait);
147170 }
148171 }
149- else if (pvar->AutoComPortReconnect)
172+ else if (TS(pvar->ts, AutoComPortReconnect))
150173 {
151174 Sleep(pvar->ReconnectWait);
152175 }
@@ -223,6 +246,47 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
223246
224247 ///////////////////////////////////////////////////////////////
225248
249+//same function with ttset::RunningVersion
250+static WORD TTRunningVersion()
251+{
252+#pragma comment(lib, "version.lib")
253+ char szPath[MAX_PATH];
254+ DWORD dwSize;
255+ DWORD dwHandle;
256+ LPVOID lpBuf;
257+ UINT uLen;
258+ VS_FIXEDFILEINFO *pFileInfo;
259+ int major, minor;
260+
261+ GetModuleFileName(NULL, szPath, sizeof(szPath) - 1);
262+
263+ dwSize = GetFileVersionInfoSize(szPath, &dwHandle);
264+ if (dwSize == 0)
265+ {
266+ return 0;
267+ }
268+
269+ lpBuf = malloc(dwSize);
270+ if (!GetFileVersionInfo(szPath, dwHandle, dwSize, lpBuf))
271+ {
272+ free(lpBuf);
273+ return 0;
274+ }
275+
276+ if (!VerQueryValue(lpBuf, "\\", (LPVOID *)&pFileInfo, &uLen))
277+ {
278+ free(lpBuf);
279+ return 0;
280+ }
281+
282+ major = HIWORD(pFileInfo->dwFileVersionMS);
283+ minor = LOWORD(pFileInfo->dwFileVersionMS);
284+
285+ free(lpBuf);
286+
287+ return major * 10000 + minor;
288+}
289+
226290 static TTXExports Exports = {
227291 /* This must contain the size of the structure. See below for its usage. */
228292 sizeof(TTXExports),
@@ -277,6 +341,7 @@ BOOL WINAPI DllMain(HANDLE hInstance,
277341 DoCover_IsDebuggerPresent();
278342 hInst = hInstance;
279343 pvar = &InstVar;
344+ tt_version = TTRunningVersion();
280345 break;
281346 case DLL_PROCESS_DETACH:
282347 /* do process cleanup */