COM ポート遅延再接続プラグイン for Tera Term
Revision | 81ae4026692859a5d761272b58b258d560e428fe (tree) |
---|---|
Time | 2020-11-23 16:37:52 |
Author | tomo3136 <tomo3136@loca...> |
Commiter | tomo3136 |
ttset構造体で無理やり対応
@@ -13,6 +13,32 @@ | ||
13 | 13 | |
14 | 14 | #include "compat_w95.h" |
15 | 15 | |
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 | + | |
16 | 42 | #define ORDER 6030 |
17 | 43 | |
18 | 44 | #define INISECTION "TTXReconnect" |
@@ -34,7 +60,6 @@ typedef struct | ||
34 | 60 | BOOL ConnectMsg; |
35 | 61 | BOOL Reconnect; |
36 | 62 | UINT ReconnectWait; |
37 | - WORD AutoComPortReconnect; | |
38 | 63 | |
39 | 64 | } TInstVar; |
40 | 65 |
@@ -66,8 +91,6 @@ static void PASCAL TTXReadIniFile(PCHAR fn, PTTSet ts) | ||
66 | 91 | (pvar->origReadIniFile)(fn, ts); |
67 | 92 | GetPrivateProfileString(INISECTION, "ReconnectWait", "", buf, sizeof(buf), fn); |
68 | 93 | pvar->ReconnectWait = atoi(buf); |
69 | - GetPrivateProfileString("Tera Term", "AutoComPortReconnect", "", buf, sizeof(buf), fn); | |
70 | - pvar->AutoComPortReconnect = (_strcmpi(buf, "on") == 0) ? TRUE : FALSE; | |
71 | 94 | } |
72 | 95 | |
73 | 96 | static void PASCAL TTXGetSetupHooks(TTXSetupHooks *hooks) |
@@ -146,7 +169,7 @@ static void PASCAL TTXOpenFile(TTXFileHooks *hooks) | ||
146 | 169 | Sleep(pvar->ReconnectWait); |
147 | 170 | } |
148 | 171 | } |
149 | - else if (pvar->AutoComPortReconnect) | |
172 | + else if (TS(pvar->ts, AutoComPortReconnect)) | |
150 | 173 | { |
151 | 174 | Sleep(pvar->ReconnectWait); |
152 | 175 | } |
@@ -223,6 +246,47 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) | ||
223 | 246 | |
224 | 247 | /////////////////////////////////////////////////////////////// |
225 | 248 | |
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 | + | |
226 | 290 | static TTXExports Exports = { |
227 | 291 | /* This must contain the size of the structure. See below for its usage. */ |
228 | 292 | sizeof(TTXExports), |
@@ -277,6 +341,7 @@ BOOL WINAPI DllMain(HANDLE hInstance, | ||
277 | 341 | DoCover_IsDebuggerPresent(); |
278 | 342 | hInst = hInstance; |
279 | 343 | pvar = &InstVar; |
344 | + tt_version = TTRunningVersion(); | |
280 | 345 | break; |
281 | 346 | case DLL_PROCESS_DETACH: |
282 | 347 | /* do process cleanup */ |