• 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

Revisionde950dc09aa1c962cdd0812d2892b80bb6959a83 (tree)
Time2020-12-12 06:32:56
Authortomo3136 <tomo3136@loca...>
Commitertomo3136

Log Message

TTSet構造体補正マクロを別ファイルに分離

Change Summary

Incremental Difference

--- a/TTXReconnect.vcxproj
+++ b/TTXReconnect.vcxproj
@@ -83,6 +83,10 @@
8383 </ItemDefinitionGroup>
8484 <ItemGroup>
8585 <ClCompile Include="ttxreconnect.c" />
86+ <ClCompile Include="ttxversion.c" />
87+ </ItemGroup>
88+ <ItemGroup>
89+ <ClInclude Include="ttxversion.h" />
8690 </ItemGroup>
8791 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
8892 <ImportGroup Label="ExtensionTargets">
--- a/TTXReconnect.vcxproj.filters
+++ b/TTXReconnect.vcxproj.filters
@@ -18,5 +18,13 @@
1818 <ClCompile Include="ttxreconnect.c">
1919 <Filter>ソース ファイル</Filter>
2020 </ClCompile>
21+ <ClCompile Include="ttxversion.c">
22+ <Filter>ソース ファイル</Filter>
23+ </ClCompile>
24+ </ItemGroup>
25+ <ItemGroup>
26+ <ClInclude Include="ttxversion.h">
27+ <Filter>ヘッダー ファイル</Filter>
28+ </ClInclude>
2129 </ItemGroup>
2230 </Project>
\ No newline at end of file
--- a/ttxreconnect.c
+++ b/ttxreconnect.c
@@ -13,36 +13,15 @@
1313
1414 #include "compat_w95.h"
1515
16-//#define V40105
16+//#define _TTX_VERSION_SUPPORT
1717
18-#ifdef V40105
19-#if ((TT_VERSION_MAJOR * 10000 + TT_VERSION_MINOR) < 40105)
20-#error "not support build version"
18+#ifdef _TTX_VERSION_SUPPORT
19+#include "ttxversion.h"
20+#else
21+#define TTXInitVersion()
22+#define TS(a, b) (a->b)
2123 #endif
2224
23-static WORD tt_version = 0;
24-
25-/* common */
26-#define TT_VER(ver, rev) (ver * 10000 + rev)
27-#define TT_POS_P(pts, ref, nm) ((void *)&(pts->ref) <= (void *)&(pts->nm))
28-
29-#define TT_OLD_P(ver, rev) (tt_version < TT_VER(ver, rev))
30-#define TT_OFFSET(ver, rev, ref, v, pts, nm) \
31- ((TT_OLD_P(ver, rev) && TT_POS_P(pts, ref, nm)) ? (v) : 0)
32-
33-/* ttset addjust */
34-#define TS_ADJ(pts, nm) ( \
35- TT_OFFSET(4, 105, UseNormalBGColor, 4, pts, nm))
36-
37-/* comvar addjust */
38-#define CV_ADJ(pts, pcv, nm) ( \
39- TT_OFFSET(4, 105, xxx, 0, pcv, nm))
40-
41-/* wrapper */
42-#define TS(pts, nm) (((PTTSet)((char *)pts - (TS_ADJ(pts, nm))))->nm)
43-#define CV(pcv, nm) (((PComVar)((char *)pcv - (CV_ADJ(pcv, nm))))->nm)
44-#endif /* V40105 */
45-
4625 #define ORDER 6030
4726
4827 #define INISECTION "TTXReconnect"
@@ -82,6 +61,7 @@ static void PASCAL TTXInit(PTTSet ts, PComVar cv)
8261 pvar->ConnectMsg = FALSE;
8362 pvar->Reconnect = FALSE;
8463 pvar->ReconnectWait = 0;
64+ TTXInitVersion();
8565 }
8666
8767 // static void PASCAL TTXGetUIHooks(TTXUIHooks *hooks)
@@ -173,11 +153,7 @@ static void PASCAL TTXOpenFile(TTXFileHooks *hooks)
173153 Sleep(pvar->ReconnectWait);
174154 }
175155 }
176-#ifdef V40105
177156 else if (TS(pvar->ts, AutoComPortReconnect))
178-#else
179- else if (pvar->ts->AutoComPortReconnect)
180-#endif
181157 {
182158 Sleep(pvar->ReconnectWait);
183159 }
@@ -254,49 +230,6 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
254230
255231 ///////////////////////////////////////////////////////////////
256232
257-#ifdef V40105
258-//same function with ttset::RunningVersion
259-static WORD TTRunningVersion()
260-{
261-#pragma comment(lib, "version.lib")
262- char szPath[MAX_PATH];
263- DWORD dwSize;
264- DWORD dwHandle;
265- LPVOID lpBuf;
266- UINT uLen;
267- VS_FIXEDFILEINFO *pFileInfo;
268- int major, minor;
269-
270- GetModuleFileName(NULL, szPath, sizeof(szPath) - 1);
271-
272- dwSize = GetFileVersionInfoSize(szPath, &dwHandle);
273- if (dwSize == 0)
274- {
275- return 0;
276- }
277-
278- lpBuf = malloc(dwSize);
279- if (!GetFileVersionInfo(szPath, dwHandle, dwSize, lpBuf))
280- {
281- free(lpBuf);
282- return 0;
283- }
284-
285- if (!VerQueryValue(lpBuf, "\\", (LPVOID *)&pFileInfo, &uLen))
286- {
287- free(lpBuf);
288- return 0;
289- }
290-
291- major = HIWORD(pFileInfo->dwFileVersionMS);
292- minor = LOWORD(pFileInfo->dwFileVersionMS);
293-
294- free(lpBuf);
295-
296- return major * 10000 + minor;
297-}
298-#endif /* V40105 */
299-
300233 static TTXExports Exports = {
301234 /* This must contain the size of the structure. See below for its usage. */
302235 sizeof(TTXExports),
@@ -351,9 +284,6 @@ BOOL WINAPI DllMain(HANDLE hInstance,
351284 DoCover_IsDebuggerPresent();
352285 hInst = hInstance;
353286 pvar = &InstVar;
354-#ifdef V40105
355- tt_version = TTRunningVersion();
356-#endif /* V40105 */
357287 break;
358288 case DLL_PROCESS_DETACH:
359289 /* do process cleanup */
--- /dev/null
+++ b/ttxversion.c
@@ -0,0 +1,60 @@
1+/*
2+ * TTX version support
3+ * (C) 2020 tomo3136
4+ */
5+
6+#include <windows.h>
7+
8+#include <stdlib.h>
9+#include <stdio.h>
10+#include <string.h>
11+
12+#include "ttxversion.h"
13+
14+WORD tt_version = 0;
15+
16+//same function with ttset::RunningVersion
17+static WORD TTRunningVersion()
18+{
19+#pragma comment(lib, "version.lib")
20+ char szPath[MAX_PATH];
21+ DWORD dwSize;
22+ DWORD dwHandle;
23+ LPVOID lpBuf;
24+ UINT uLen;
25+ VS_FIXEDFILEINFO *pFileInfo;
26+ int major, minor;
27+
28+ GetModuleFileName(NULL, szPath, sizeof(szPath) - 1);
29+
30+ dwSize = GetFileVersionInfoSize(szPath, &dwHandle);
31+ if (dwSize == 0)
32+ {
33+ return 0;
34+ }
35+
36+ lpBuf = malloc(dwSize);
37+ if (!GetFileVersionInfo(szPath, dwHandle, dwSize, lpBuf))
38+ {
39+ free(lpBuf);
40+ return 0;
41+ }
42+
43+ if (!VerQueryValue(lpBuf, "\\", (LPVOID *)&pFileInfo, &uLen))
44+ {
45+ free(lpBuf);
46+ return 0;
47+ }
48+
49+ major = HIWORD(pFileInfo->dwFileVersionMS);
50+ minor = LOWORD(pFileInfo->dwFileVersionMS);
51+
52+ free(lpBuf);
53+
54+ return major * 10000 + minor;
55+}
56+
57+void TTXInitVersion()
58+{
59+ tt_version = TTRunningVersion();
60+}
--- /dev/null
+++ b/ttxversion.h
@@ -0,0 +1,38 @@
1+/*
2+ * TTX version support
3+ * (C) 2020 tomo3136
4+ */
5+
6+#include "tt-version.h"
7+
8+#if ((TT_VERSION_MAJOR * 10000 + TT_VERSION_MINOR) < 40105)
9+#error "not support build version"
10+#endif
11+
12+/* old version PTTSet structure support */
13+/* build test: 4.105 */
14+/* running test: 4.105, 4.104, 4.98, 4.96, 4.80 */
15+
16+#define TT_ADJ(pts, nm, ver, rev, ref, v) \
17+ (((tt_version < (ver * 10000 + rev)) && \
18+ ((void *)&(pts->ref) <= (void *)&(pts->nm))) \
19+ ? (-v) \
20+ : 0)
21+
22+#define TS(pts, nm) \
23+ (((PTTSet)((char *)(pts) + \
24+ TT_ADJ((pts), nm, 4, 105, UseNormalBGColor, 4))) \
25+ ->nm)
26+
27+#ifdef __cplusplus
28+extern "C"
29+{
30+#endif
31+
32+ extern WORD tt_version;
33+
34+ void TTXInitVersion();
35+
36+#ifdef __cplusplus
37+}
38+#endif