[Ttssh2-commit] [7190] - FAR削除

scmno****@osdn***** scmno****@osdn*****
2018年 8月 26日 (日) 23:44:24 JST


Revision: 7190
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7190
Author:   zmatsuo
Date:     2018-08-26 23:44:23 +0900 (Sun, 26 Aug 2018)
Log Message:
-----------
- FAR削除
- PASCAL → WINAPI
- DLLExportを追加
- defファイル削除
- ReadOnlyのテーブル(mapファイル)などをconst化

Modified Paths:
--------------
    branches/cmake/mingw.toolchain.cmake
    branches/cmake/teraterm/CMakeLists.txt
    branches/cmake/teraterm/common/dlglib.c
    branches/cmake/teraterm/common/dlglib.h
    branches/cmake/teraterm/common/i18n.c
    branches/cmake/teraterm/common/i18n.h
    branches/cmake/teraterm/common/servicenames.h
    branches/cmake/teraterm/common/tektypes.h
    branches/cmake/teraterm/common/ttcommon.h
    branches/cmake/teraterm/common/ttftypes.h
    branches/cmake/teraterm/common/ttlib.c
    branches/cmake/teraterm/common/ttlib.h
    branches/cmake/teraterm/common/ttplugin.h
    branches/cmake/teraterm/keycode/keycode.c
    branches/cmake/teraterm/teraterm/CMakeLists.txt
    branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
    branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h
    branches/cmake/teraterm/teraterm/filesys.cpp
    branches/cmake/teraterm/teraterm/filesys.h
    branches/cmake/teraterm/teraterm/teklib.c
    branches/cmake/teraterm/teraterm/teklib.h
    branches/cmake/teraterm/teraterm/ttdialog.c
    branches/cmake/teraterm/teraterm/ttdialog.h
    branches/cmake/teraterm/teraterm/ttfileio.c
    branches/cmake/teraterm/teraterm/ttfileio.h
    branches/cmake/teraterm/teraterm/ttplug.c
    branches/cmake/teraterm/teraterm/ttplug.h
    branches/cmake/teraterm/teraterm/ttsetup.c
    branches/cmake/teraterm/teraterm/ttsetup.h
    branches/cmake/teraterm/teraterm/ttwinman.c
    branches/cmake/teraterm/teraterm/ttwsk.h
    branches/cmake/teraterm/teraterm/uni2sjis.map
    branches/cmake/teraterm/teraterm/uni_combining.map
    branches/cmake/teraterm/teraterm/unisym2decsp.map
    branches/cmake/teraterm/teraterm/vtterm.c
    branches/cmake/teraterm/ttpcmn/CMakeLists.txt
    branches/cmake/teraterm/ttpcmn/language.c
    branches/cmake/teraterm/ttpcmn/language.h
    branches/cmake/teraterm/ttpcmn/sjis2uni.map
    branches/cmake/teraterm/ttpcmn/ttcmn.c
    branches/cmake/teraterm/ttpdlg/CMakeLists.txt
    branches/cmake/teraterm/ttpdlg/ttdlg.c
    branches/cmake/teraterm/ttpfile/CMakeLists.txt
    branches/cmake/teraterm/ttpfile/ttfile.c
    branches/cmake/teraterm/ttpmacro/CMakeLists.txt
    branches/cmake/teraterm/ttpmacro/ttmenc.c
    branches/cmake/teraterm/ttpmacro/ttmparse.c
    branches/cmake/teraterm/ttpmacro/ttmparse.h
    branches/cmake/teraterm/ttpset/CMakeLists.txt
    branches/cmake/teraterm/ttpset/ttset.c
    branches/cmake/teraterm/ttptek/CMakeLists.txt
    branches/cmake/teraterm/ttptek/tekesc.c
    branches/cmake/teraterm/ttptek/tekesc.h
    branches/cmake/teraterm/ttptek/tttek.c
    branches/cmake/ttssh2/ttxssh/CMakeLists.txt
    branches/cmake/ttssh2/ttxssh/util.h

Added Paths:
-----------
    branches/cmake/teraterm/teraterm/ttutil.c
    branches/cmake/teraterm/teraterm/ttutil.h

Removed Paths:
-------------
    branches/cmake/teraterm/ttpcmn/ttpcmn.def
    branches/cmake/teraterm/ttpdlg/ttpdlg.def
    branches/cmake/teraterm/ttpfile/ttpfile.def
    branches/cmake/teraterm/ttpset/ttpset.def
    branches/cmake/teraterm/ttptek/ttptek.def

-------------- next part --------------
Modified: branches/cmake/mingw.toolchain.cmake
===================================================================
--- branches/cmake/mingw.toolchain.cmake	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/mingw.toolchain.cmake	2018-08-26 14:44:23 UTC (rev 7190)
@@ -23,9 +23,9 @@
   set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
 endif()
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -ffunction-sections -fdata-sections" CACHE STRING "")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -ffunction-sections -fdata-sections" CACHE STRING "")
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--gc-sections" CACHE STRING "")
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s -Wl,--gc-sections -Wl,--add-stdcall-alias -Wl,--enable-stdcall-fixup" CACHE STRING "")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -static-libgcc -static-libstdc++ -ffunction-sections -fdata-sections" CACHE STRING "")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -static-libgcc -static-libstdc++ -ffunction-sections -fdata-sections" CACHE STRING "")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections" CACHE STRING "")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++ -s -Wl,--gc-sections" CACHE STRING "")
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE PATH "toolchain file")

Modified: branches/cmake/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,12 +1,52 @@
 
 add_subdirectory(ttpcmn)
+set_target_properties(
+  ttpcmn
+  PROPERTIES FOLDER teraterm)
+
 add_subdirectory(ttpdlg)
+set_target_properties(
+  ttpdlg
+  PROPERTIES FOLDER teraterm)
+
 add_subdirectory(ttpfile)
+set_target_properties(
+  ttpfile
+  PROPERTIES FOLDER teraterm)
+
 add_subdirectory(ttpset)
-add_subdirectory(ttpmacro)
+set_target_properties(
+  ttpset
+  PROPERTIES FOLDER teraterm)
+
+if((${CMAKE_MAKE_PROGRAM} MATCHES "VCExpress.exe") OR MINGW)
+  message("pass ttpmacro compile")
+else()
+  # need MFC (VS2005Express does not include MFC)
+  add_subdirectory(ttpmacro)
+  set_target_properties(
+	ttpmacro
+	PROPERTIES FOLDER teraterm)
+endif()
+
 add_subdirectory(ttptek)
-add_subdirectory(teraterm)
+set_target_properties(
+  ttptek
+  PROPERTIES FOLDER teraterm)
+
+if((${CMAKE_MAKE_PROGRAM} MATCHES "VCExpress.exe") OR MINGW)
+  message("pass teraterm compile")
+else()
+  add_subdirectory(teraterm)
+  set_target_properties(
+	teraterm
+	PROPERTIES FOLDER teraterm)
+endif()
+
 add_subdirectory(keycode)
+set_target_properties(
+  keycode
+  PROPERTIES FOLDER teraterm)
 
 # ttpdlg内でconfig時 svnversion.h を生成
 #add_subdirectory(svnrev)

Modified: branches/cmake/teraterm/common/dlglib.c
===================================================================
--- branches/cmake/teraterm/common/dlglib.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/dlglib.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -176,7 +176,7 @@
 	SetDlgItemText(HDlg, id_Item, buff);
 }
 
-void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR **List, int nsel)
+void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR *List[], int nsel)
 {
 	int i;
 
@@ -376,7 +376,7 @@
 }
 
 HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
-                  const char *UILanguageFile, PCHAR key)
+				  const char *UILanguageFile, PCHAR key)
 {
 	HFONT hPrevFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
 	LOGFONT logfont;

Modified: branches/cmake/teraterm/common/dlglib.h
===================================================================
--- branches/cmake/teraterm/common/dlglib.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/dlglib.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -44,7 +44,7 @@
 void SetDlgNum(HWND HDlg, int id_Item, LONG Num);
 void SetDlgPercent(HWND HDlg, int id_Item, int id_Progress, LONG a, LONG b, int *prog);
 void SetDlgTime(HWND HDlg, int id_Item, DWORD elapsed, int bytes);
-void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR **List, int nsel);
+void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR *List[], int nsel);
 LONG GetCurSel(HWND HDlg, int Id_Item);
 void InitDlgProgress(HWND HDlg, int id_Progress, int *CurProgStat);
 void SetEditboxSubclass(HWND hDlg, int nID, BOOL ComboBox);

Modified: branches/cmake/teraterm/common/i18n.c
===================================================================
--- branches/cmake/teraterm/common/i18n.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/i18n.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -28,13 +28,13 @@
 
 #include "i18n.h"
 
-void GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile)
+DllExport void GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile)
 {
 	GetPrivateProfileString(section, key, def, buf, buf_len, iniFile);
 	RestoreNewLine(buf);
 }
 
-int GetI18nLogfont(const char *section, const char *key, PLOGFONT logfont, int ppi, const char *iniFile)
+DllExport int GetI18nLogfont(const char *section, const char *key, PLOGFONT logfont, int ppi, const char *iniFile)
 {
 	static char tmp[MAX_UIMSG];
 	static char font[LF_FACESIZE];

Modified: branches/cmake/teraterm/common/i18n.h
===================================================================
--- branches/cmake/teraterm/common/i18n.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/i18n.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -38,9 +38,22 @@
 extern "C" {
 #endif
 
-void GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
-int GetI18nLogfont(const char *section, const char *key, PLOGFONT logfont, int ppi, const char *iniFile);
+#if defined(TTPCMN_DLL)
+#if !defined(DllExport)
+#define DllExport __declspec(dllexport)
+#endif
+#elif defined(TTPCMN_IMPORT)
+#if !defined(DllExport)
+#define DllExport __declspec(dllimport)
+#endif
+#else
+#undef DllExport
+#define DllExport	// direct link
+#endif
 
+DllExport void GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
+DllExport int GetI18nLogfont(const char *section, const char *key, PLOGFONT logfont, int ppi, const char *iniFile);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/cmake/teraterm/common/servicenames.h
===================================================================
--- branches/cmake/teraterm/common/servicenames.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/servicenames.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -34,10 +34,23 @@
 extern "C" {
 #endif
 
+#if defined(TTPCMN_DLL)
+#if !defined(DllExport)
+#define DllExport __declspec(dllexport)
+#endif
+#elif defined(TTPCMN_IMPORT)
+#if !defined(DllExport)
+#define DllExport __declspec(dllimport)
+#endif
+#else
+#undef DllExport
+#define DllExport	// direct link
+#endif
+
 /* proto types */
-int WINAPI parse_port(char *str, char *buf, int bufsize);
-int WINAPI parse_port_from_buf(char *buf);
-const char * WINAPI service_name(int num);
+DllExport int WINAPI parse_port(char *str, char *buf, int bufsize);
+DllExport int WINAPI parse_port_from_buf(char *buf);
+DllExport const char * WINAPI service_name(int num);
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/common/tektypes.h
===================================================================
--- branches/cmake/teraterm/common/tektypes.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/tektypes.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -147,4 +147,4 @@
 
   BYTE HiY, Extra, LoY, HiX, LoX;   
 } TTEKVar;
-typedef TTEKVar far *PTEKVar;
+typedef TTEKVar *PTEKVar;

Modified: branches/cmake/teraterm/common/ttcommon.h
===================================================================
--- branches/cmake/teraterm/common/ttcommon.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/ttcommon.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -34,70 +34,79 @@
 extern "C" {
 #endif
 
-int WINAPI DetectComPorts(LPWORD ComPortTable, int ComPortMax, char **ComPortDesc);
-int WINAPI CheckComPort(WORD ComPort);
-void WINAPI CopyShmemToTTSet(PTTSet ts);
-void WINAPI CopyTTSetToShmem(PTTSet ts);
-BOOL WINAPI StartTeraTerm(PTTSet ts);
-void WINAPI RestartTeraTerm(HWND hwnd, PTTSet ts);
-void WINAPI ChangeDefaultSet(PTTSet ts, PKeyMap km);
-void WINAPI GetDefaultSet(PTTSet ts);
+#if defined(TTPCMN_DLL)
+#if !defined(DllExport)
+#define DllExport __declspec(dllexport)
+#endif
+#elif defined(TTPCMN_IMPORT)
+#if !defined(DllExport)
+#define DllExport __declspec(dllimport)
+#else
+#endif
+#else
+#undef DllExport
+#define DllExport	// direct link
+#endif
+
+DllExport int WINAPI DetectComPorts(LPWORD ComPortTable, int ComPortMax, char **ComPortDesc);
+DllExport int WINAPI CheckComPort(WORD ComPort);
+DllExport void WINAPI CopyShmemToTTSet(PTTSet ts);
+DllExport void WINAPI CopyTTSetToShmem(PTTSet ts);
+DllExport BOOL WINAPI StartTeraTerm(PTTSet ts);
+DllExport void WINAPI RestartTeraTerm(HWND hwnd, PTTSet ts);
+DllExport void WINAPI ChangeDefaultSet(PTTSet ts, PKeyMap km);
+DllExport void WINAPI GetDefaultSet(PTTSet ts);
 // void WINAPI LoadDefaultSet(PCHAR SetupFName);
-WORD WINAPI GetKeyCode(PKeyMap KeyMap, WORD Scan);
-void WINAPI GetKeyStr(HWND HWin, PKeyMap KeyMap, WORD KeyCode,
-                          BOOL AppliKeyMode, BOOL AppliCursorMode,
-                          BOOL Send8BitMode, PCHAR KeyStr,
-                          int destlen, LPINT Len, LPWORD Type);
+DllExport WORD WINAPI GetKeyCode(PKeyMap KeyMap, WORD Scan);
+DllExport void WINAPI GetKeyStr(HWND HWin, PKeyMap KeyMap, WORD KeyCode,
+								BOOL AppliKeyMode, BOOL AppliCursorMode,
+								BOOL Send8BitMode, PCHAR KeyStr,
+								int destlen, LPINT Len, LPWORD Type);
 
-void WINAPI SetCOMFlag(int com);
-void WINAPI ClearCOMFlag(int com);
-int WINAPI CheckCOMFlag(int com);
+DllExport void WINAPI SetCOMFlag(int com);
+DllExport void WINAPI ClearCOMFlag(int com);
+DllExport int WINAPI CheckCOMFlag(int com);
 
-int WINAPI RegWin(HWND HWinVT, HWND HWinTEK);
-void WINAPI UnregWin(HWND HWin);
-void WINAPI SetWinMenu(HMENU menu, PCHAR buf, int buflen, PCHAR langFile, int VTFlag);
-void WINAPI SetWinList(HWND HWin, HWND HDlg, int IList);
-void WINAPI SelectWin(int WinId);
-void WINAPI SelectNextWin(HWND HWin, int Next, BOOL SkipIconic);
-HWND WINAPI GetNthWin(int n);
-int WINAPI GetRegisteredWindowCount();
-void WINAPI ShowAllWin(int stat);
-void WINAPI ShowAllWinSidebySide(HWND);
-void WINAPI ShowAllWinStacked(HWND);
-void WINAPI ShowAllWinCascade(HWND);
-void WINAPI BroadcastClosingMessage(HWND myhwnd);
-void WINAPI UndoAllWin();
-void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile);
+DllExport int WINAPI RegWin(HWND HWinVT, HWND HWinTEK);
+DllExport void WINAPI UnregWin(HWND HWin);
+DllExport void WINAPI SetWinMenu(HMENU menu, PCHAR buf, int buflen, PCHAR langFile, int VTFlag);
+DllExport void WINAPI SetWinList(HWND HWin, HWND HDlg, int IList);
+DllExport void WINAPI SelectWin(int WinId);
+DllExport void WINAPI SelectNextWin(HWND HWin, int Next, BOOL SkipIconic);
+DllExport HWND WINAPI GetNthWin(int n);
+DllExport int WINAPI GetRegisteredWindowCount();
+DllExport void WINAPI ShowAllWin(int stat);
+DllExport void WINAPI ShowAllWinSidebySide(HWND);
+DllExport void WINAPI ShowAllWinStacked(HWND);
+DllExport void WINAPI ShowAllWinCascade(HWND);
+DllExport void WINAPI BroadcastClosingMessage(HWND myhwnd);
+DllExport void WINAPI UndoAllWin();
+DllExport void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile);
 
-int WINAPI CommReadRawByte(PComVar cv, LPBYTE b);
-int WINAPI CommRead1Byte(PComVar cv, LPBYTE b);
-void WINAPI CommInsert1Byte(PComVar cv, BYTE b);
-int WINAPI CommRawOut(PComVar cv, PCHAR B, int C);
-int WINAPI CommBinaryOut(PComVar cv, PCHAR B, int C);
-int WINAPI CommBinaryBuffOut(PComVar cv, PCHAR B, int C);
-int WINAPI CommTextOut(PComVar cv, PCHAR B, int C);
-int WINAPI CommBinaryEcho(PComVar cv, PCHAR B, int C);
-int WINAPI CommTextEcho(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommReadRawByte(PComVar cv, LPBYTE b);
+DllExport int WINAPI CommRead1Byte(PComVar cv, LPBYTE b);
+DllExport void WINAPI CommInsert1Byte(PComVar cv, BYTE b);
+DllExport int WINAPI CommRawOut(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommBinaryOut(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommBinaryBuffOut(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommTextOut(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommBinaryEcho(PComVar cv, PCHAR B, int C);
+DllExport int WINAPI CommTextEcho(PComVar cv, PCHAR B, int C);
 
-void WINAPI CreateNotifyIcon(PComVar cv);
-void WINAPI DeleteNotifyIcon(PComVar cv);
-void WINAPI NotifyMessage(PComVar cv, PCHAR message, PCHAR title, DWORD flag);
-void WINAPI ShowNotifyIcon(PComVar cv);
-void WINAPI HideNotifyIcon(PComVar cv);
-void WINAPI SetVerNotifyIcon(PComVar cv, unsigned int ver);
-void WINAPI SetCustomNotifyIcon(HICON icon);
-HICON WINAPI GetCustomNotifyIcon();
+DllExport void WINAPI CreateNotifyIcon(PComVar cv);
+DllExport void WINAPI DeleteNotifyIcon(PComVar cv);
+DllExport void WINAPI NotifyMessage(PComVar cv, PCHAR message, PCHAR title, DWORD flag);
+DllExport void WINAPI ShowNotifyIcon(PComVar cv);
+DllExport void WINAPI HideNotifyIcon(PComVar cv);
+DllExport void WINAPI SetVerNotifyIcon(PComVar cv, unsigned int ver);
+DllExport void WINAPI SetCustomNotifyIcon(HICON icon);
+DllExport HICON WINAPI GetCustomNotifyIcon();
 
 #define NotifyInfoMessage(cv, msg, title) NotifyMessage(cv, msg, title, 1)
 #define NotifyWarnMessage(cv, msg, title) NotifyMessage(cv, msg, title, 2)
 #define NotifyErrorMessage(cv, msg, title) NotifyMessage(cv, msg, title, 3)
 
-WORD WINAPI SJIS2JIS(WORD KCode);
-WORD WINAPI SJIS2EUC(WORD KCode);
-WORD WINAPI JIS2SJIS(WORD KCode);
-BYTE WINAPI RussConv(int cin, int cout, BYTE b);
-void WINAPI RussConvStr
-  (int cin, int cout, PCHAR Str, int count);
+#include "../ttpcmn/language.h"
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/common/ttftypes.h
===================================================================
--- branches/cmake/teraterm/common/ttftypes.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/ttftypes.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -144,7 +144,7 @@
   DWORD FileMtime;
   HANDLE LogThreadEvent;
 } TFileVar;
-typedef TFileVar far *PFileVar;
+typedef TFileVar *PFileVar;
 
 typedef struct {
 	int MAXL;
@@ -176,7 +176,7 @@
   int FileMode;
   LONGLONG FileSize;
 } TKmtVar;
-typedef TKmtVar far *PKmtVar;
+typedef TKmtVar *PKmtVar;
 
   /* Kermit states */
 #define WaitMark  0
@@ -218,7 +218,7 @@
   int TOutVLong;
   int CANCount;
 } TXVar;
-typedef TXVar far *PXVar;
+typedef TXVar *PXVar;
 
   /* XMODEM states */
 #define XpktSOH 1
@@ -254,7 +254,7 @@
   BYTE LastMessage;
   BOOL RecvFilesize;
 } TYVar;
-typedef TYVar far *PYVar;
+typedef TYVar *PYVar;
 
   /* YMODEM states */
 #define YpktSOH 0x01
@@ -287,7 +287,7 @@
   int TOutInit;
   int TOutFin;
 } TZVar;
-typedef TZVar far *PZVar;
+typedef TZVar *PZVar;
 
 #define Z_RecvInit 1
 #define Z_RecvInit2 2
@@ -346,7 +346,7 @@
   BOOL CtlEsc;
   BYTE Q[8];
 } TBPVar;
-typedef TBPVar far *PBPVar;
+typedef TBPVar *PBPVar;
 
   /* B Plus states */
 #define BP_Init      1
@@ -383,7 +383,7 @@
   BOOL EnqFlag;
   BYTE CheckSum;
 } TQVVar;
-typedef TQVVar far *PQVVar;
+typedef TQVVar *PQVVar;
 
   /* Quick-VAN states */
 #define QV_RecvInit1 1

Modified: branches/cmake/teraterm/common/ttlib.c
===================================================================
--- branches/cmake/teraterm/common/ttlib.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/ttlib.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -34,12 +34,12 @@
 #include <string.h>
 #include <time.h>
 #include <stdio.h>
-#include "tttypes.h"
 #include <shlobj.h>
 #include <ctype.h>
+#include <mbctype.h>	// for _ismbblead
 
-// for _ismbblead
-#include <mbctype.h>
+#include "tttypes.h"
+#include "ttlib.h"
 
 /* OS version with GetVersionEx(*1)
 
@@ -210,7 +210,7 @@
 	return len;
 }
 
-BOOL GetFileNamePos(PCHAR PathName, int far *DirLen, int far *FNPos)
+BOOL GetFileNamePos(PCHAR PathName, int *DirLen, int *FNPos)
 {
 	BYTE b;
 	LPTSTR Ptr, DirPtr, FNPtr, PtrOld;
@@ -825,7 +825,7 @@
 	return (i>=Nth);
 }
 
-void GetNthNum(PCHAR Source, int Nth, int far *Num)
+void GetNthNum(PCHAR Source, int Nth, int *Num)
 {
 	char T[15];
 
@@ -1605,7 +1605,7 @@
 	return strtime;
 }
 
-PCHAR PASCAL GetParam(PCHAR buff, int size, PCHAR param)
+PCHAR WINAPI GetParam(PCHAR buff, int size, PCHAR param)
 {
 	int i = 0;
 	BOOL quoted = FALSE;
@@ -1643,7 +1643,7 @@
 	return (param);
 }
 
-void PASCAL DequoteParam(PCHAR dest, int dest_len, PCHAR src)
+void WINAPI DequoteParam(PCHAR dest, int dest_len, PCHAR src)
 {
 	BOOL quoted = FALSE;
 	PCHAR dest_end = dest + dest_len - 1;
@@ -1666,7 +1666,7 @@
 	*dest = '\0';
 }
 
-void PASCAL DeleteComment(PCHAR dest, int dest_size, PCHAR src)
+void WINAPI DeleteComment(PCHAR dest, int dest_size, PCHAR src)
 {
 	BOOL quoted = FALSE;
 	PCHAR dest_end = dest + dest_size - 1;
@@ -1730,3 +1730,4 @@
 	OutputDebugString(buffer);
 }
 #endif
+

Modified: branches/cmake/teraterm/common/ttlib.h
===================================================================
--- branches/cmake/teraterm/common/ttlib.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/ttlib.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2006-2017 TeraTerm Project
+ * (C) 2006-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,9 +35,22 @@
 extern "C" {
 #endif
 
-BOOL GetFileNamePos(PCHAR PathName, int far *DirLen, int far *FNPos);
-BOOL ExtractFileName(PCHAR PathName, PCHAR FileName, int destlen);
-BOOL ExtractDirName(PCHAR PathName, PCHAR DirName);
+#if defined(TTPCMN_DLL)
+#if !defined(DllExport)
+#define DllExport __declspec(dllexport)
+#endif
+#elif defined(TTPCMN_IMPORT)
+#if !defined(DllExport)
+#define DllExport __declspec(dllimport)
+#endif
+#else
+#undef DllExport
+#define DllExport	// direct link
+#endif
+
+BOOL GetFileNamePos(PCHAR PathName, int *DirLen, int *FNPos);
+DllExport BOOL ExtractFileName(PCHAR PathName, PCHAR FileName, int destlen);
+DllExport BOOL ExtractDirName(PCHAR PathName, PCHAR DirName);
 void FitFileName(PCHAR FileName, int destlen, PCHAR DefExt);
 void AppendSlash(PCHAR Path, int destlen);
 void DeleteSlash(PCHAR Path);
@@ -55,7 +68,7 @@
 #endif
 int isInvalidFileNameChar(PCHAR FName);
 #define deleteInvalidFileNameChar(name) replaceInvalidFileNameChar(name, 0)
-void replaceInvalidFileNameChar(PCHAR FName, unsigned char c);
+DllExport void replaceInvalidFileNameChar(PCHAR FName, unsigned char c);
 int isInvalidStrftimeChar(PCHAR FName);
 void deleteInvalidStrftimeChar(PCHAR FName);
 void ParseStrftimeFileName(PCHAR FName, int destlen);
@@ -62,9 +75,9 @@
 void ConvFName(PCHAR HomeDir, PCHAR Temp, int templen, PCHAR DefExt, PCHAR FName, int destlen);
 void RestoreNewLine(PCHAR Text);
 BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest);
-void GetNthNum(PCHAR Source, int Nth, int far *Num);
+void GetNthNum(PCHAR Source, int Nth, int *Num);
 int GetNthNum2(PCHAR Source, int Nth, int defval);
-void GetDownloadFolder(char *dest, int destlen);
+DllExport void GetDownloadFolder(char *dest, int destlen);
 void WINAPI GetDefaultFName(char *home, char *file, char *dest, int destlen);
 void GetDefaultSetupFName(char *home, char *dest, int destlen);
 void GetUILanguageFile(char *buf, int buflen);
@@ -71,33 +84,33 @@
 void GetOnOffEntryInifile(char *entry, char *buf, int buflen);
 void get_lang_msg(const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
 int get_lang_font(PCHAR key, HWND dlg, PLOGFONT logfont, HFONT *font, const char *iniFile);
-BOOL doSelectFolder(HWND hWnd, char *path, int pathlen, char *def, char *msg);
-void OutputDebugPrintf(const char *fmt, ...);
-BOOL is_NT4();
+DllExport BOOL doSelectFolder(HWND hWnd, char *path, int pathlen, char *def, char *msg);
+DllExport void OutputDebugPrintf(const char *fmt, ...);
+DllExport BOOL is_NT4();
 int get_OPENFILENAME_SIZE();
-BOOL IsWindows95();
-BOOL IsWindowsMe();
-BOOL IsWindowsNT4();
-BOOL IsWindowsNTKernel();
-BOOL IsWindows2000();
-BOOL IsWindows2000OrLater();
-BOOL IsWindowsVistaOrLater();
-BOOL IsWindows7OrLater();
-BOOL HasMultiMonitorSupport();
-BOOL HasGetAdaptersAddresses();
-BOOL HasDnsQuery();
-BOOL HasBalloonTipSupport();
+DllExport BOOL IsWindows95();
+DllExport BOOL IsWindowsMe();
+DllExport BOOL IsWindowsNT4();
+DllExport BOOL IsWindowsNTKernel();
+DllExport BOOL IsWindows2000();
+DllExport BOOL IsWindows2000OrLater();
+DllExport BOOL IsWindowsVistaOrLater();
+DllExport BOOL IsWindows7OrLater();
+DllExport BOOL HasMultiMonitorSupport();
+DllExport BOOL HasGetAdaptersAddresses();
+DllExport BOOL HasDnsQuery();
+DllExport BOOL HasBalloonTipSupport();
 int KanjiCode2List(int lang, int kcode);
 int List2KanjiCode(int lang, int kcode);
 int KanjiCodeTranslate(int lang, int kcode);
-char *mctimelocal(char *format, BOOL utc_flag);
+DllExport char *mctimelocal(char *format, BOOL utc_flag);
 char *strelapsed(DWORD start_time);
 
-void b64encode(PCHAR dst, int dsize, PCHAR src, int len);
-int b64decode(PCHAR dst, int dsize, PCHAR src);
+DllExport void b64encode(PCHAR dst, int dsize, PCHAR src, int len);
+DllExport int b64decode(PCHAR dst, int dsize, PCHAR src);
 
-PCHAR WINAPI GetParam(PCHAR buff, int size, PCHAR param);
-void WINAPI DequoteParam(PCHAR dest, int dest_len, PCHAR src);
+DllExport PCHAR WINAPI GetParam(PCHAR buff, int size, PCHAR param);
+DllExport void WINAPI DequoteParam(PCHAR dest, int dest_len, PCHAR src);
 void WINAPI DeleteComment(PCHAR dest, int dest_size, PCHAR src);
 
 void split_buffer(char *buffer, int delimiter, char **head, char **body);

Modified: branches/cmake/teraterm/common/ttplugin.h
===================================================================
--- branches/cmake/teraterm/common/ttplugin.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/common/ttplugin.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -87,19 +87,19 @@
 typedef struct {
   int size;
   int loadOrder; /* smaller numbers get loaded first */
-  void (PASCAL * TTXInit)(PTTSet ts, PComVar cv); /* called first to last */
-  void (PASCAL * TTXGetUIHooks)(TTXUIHooks * UIHooks); /* called first to last */
-  void (PASCAL * TTXGetSetupHooks)(TTXSetupHooks * setupHooks); /* called first to last */
-  void (PASCAL * TTXOpenTCP)(TTXSockHooks * hooks); /* called first to last */
-  void (PASCAL * TTXCloseTCP)(TTXSockHooks * hooks); /* called last to first */
-  void (PASCAL * TTXSetWinSize)(int rows, int cols); /* called first to last */
-  void (PASCAL * TTXModifyMenu)(HMENU menu); /* called first to last */
-  void (PASCAL * TTXModifyPopupMenu)(HMENU menu); /* called first to last */
-  int (PASCAL * TTXProcessCommand)(HWND hWin, WORD cmd); /* returns TRUE if handled, called last to first */
-  void (PASCAL * TTXEnd)(void); /* called last to first */
-  void (PASCAL * TTXSetCommandLine)(PCHAR cmd, int cmdlen, PGetHNRec rec); /* called first to last */
-  void (PASCAL * TTXOpenFile)(TTXFileHooks * hooks); /* called first to last */
-  void (PASCAL * TTXCloseFile)(TTXFileHooks * hooks); /* called last to first */
+  void (WINAPI * TTXInit)(PTTSet ts, PComVar cv); /* called first to last */
+  void (WINAPI * TTXGetUIHooks)(TTXUIHooks * UIHooks); /* called first to last */
+  void (WINAPI * TTXGetSetupHooks)(TTXSetupHooks * setupHooks); /* called first to last */
+  void (WINAPI * TTXOpenTCP)(TTXSockHooks * hooks); /* called first to last */
+  void (WINAPI * TTXCloseTCP)(TTXSockHooks * hooks); /* called last to first */
+  void (WINAPI * TTXSetWinSize)(int rows, int cols); /* called first to last */
+  void (WINAPI * TTXModifyMenu)(HMENU menu); /* called first to last */
+  void (WINAPI * TTXModifyPopupMenu)(HMENU menu); /* called first to last */
+  int (WINAPI * TTXProcessCommand)(HWND hWin, WORD cmd); /* returns TRUE if handled, called last to first */
+  void (WINAPI * TTXEnd)(void); /* called last to first */
+  void (WINAPI * TTXSetCommandLine)(PCHAR cmd, int cmdlen, PGetHNRec rec); /* called first to last */
+  void (WINAPI * TTXOpenFile)(TTXFileHooks * hooks); /* called first to last */
+  void (WINAPI * TTXCloseFile)(TTXFileHooks * hooks); /* called last to first */
 } TTXExports;
 
 /* On entry, 'size' is set to the size of the structure and the rest of
@@ -108,6 +108,6 @@
    default behaviour, i.e. do nothing.
    This is all for binary compatibility across releases; if the record gets bigger,
    then the extra functions will be NULL for DLLs that don't understand them. */
-typedef BOOL (PASCAL * TTXBindProc)(WORD Version, TTXExports * exports);
+typedef BOOL (WINAPI * TTXBindProc)(WORD Version, TTXExports * exports);
 
 #endif

Modified: branches/cmake/teraterm/keycode/keycode.c
===================================================================
--- branches/cmake/teraterm/keycode/keycode.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/keycode/keycode.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -47,10 +47,10 @@
 static BOOL Short;
 static WORD Scan;
 
-int PASCAL WinMain(HINSTANCE hInstance,
-                   HINSTANCE hPrevInstance,
-                   LPSTR lpszCmdLine,
-                   int nCmdShow)
+int WINAPI WinMain(HINSTANCE hInstance,
+				   HINSTANCE hPrevInstance,
+				   LPSTR lpszCmdLine,
+				   int nCmdShow)
 {
 	typedef BOOL (WINAPI *pSetDllDir)(LPCSTR);
 	typedef BOOL (WINAPI *pSetDefDllDir)(DWORD);

Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -16,7 +16,7 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
   ../common/tt_res.h
   ../common/ttcommon.h
   ../common/ttddecmnd.h
@@ -25,7 +25,6 @@
   ../common/ttplugin.h
   ../common/tt-version.h
   ../common/teraterm.h
-  #
   ../common/ttlib.c
   ../common/ttlib.h
   ../common/dlglib.c
@@ -34,7 +33,15 @@
   ../common/dlglib_tmpl.cpp
   ../common/compat_win.cpp
   ../common/compat_win.h
-  #
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   addsetting.cpp
   addsetting.h
   tmfc.cpp
@@ -97,6 +104,9 @@
   winjump.h
   WSAAsyncGetAddrInfo.c
   WSAAsyncGetAddrInfo.h
+  ttutil.c
+  ttutil.h
+  ${COMMON_SRC}
   )
 
 include_directories(

Modified: branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
===================================================================
--- branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -38,7 +38,7 @@
 
 static unsigned __stdcall getaddrinfo_thread(void * p);
 
-HANDLE PASCAL WSAAsyncGetAddrInfo(HWND hWnd, unsigned int wMsg,
+HANDLE WINAPI WSAAsyncGetAddrInfo(HWND hWnd, unsigned int wMsg,
                            const char *hostname,
                            const char *portname,
                            struct addrinfo *hints,

Modified: branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h
===================================================================
--- branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -46,7 +46,7 @@
   HANDLE *lpHandle;
 };
 
-HANDLE PASCAL WSAAsyncGetAddrInfo(HWND hWnd,
+HANDLE WINAPI WSAAsyncGetAddrInfo(HWND hWnd,
 			   unsigned int wMsg,
 			   const char *hostname,
 			   const char *portname,

Modified: branches/cmake/teraterm/teraterm/filesys.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/filesys.cpp	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/filesys.cpp	2018-08-26 14:44:23 UTC (rev 7190)
@@ -46,6 +46,7 @@
 #include "helpid.h"
 #include "dlglib.h"
 #include "vtterm.h"
+#include "ttutil.h"
 
 #include "filesys.h"
 #include "ftlib.h"
@@ -103,21 +104,6 @@
 PTTFILESetUILanguageFile TTFILESetUILanguageFile;
 PTTFILESetFileSendFilter TTFILESetFileSendFilter;
 
-#define IdGetSetupFname  1
-#define IdGetTransFname  2
-#define IdGetMultiFname  3
-#define IdGetGetFname	 4
-#define IdSetFileVar	 5
-#define IdGetXFname	 6
-
-#define IdProtoInit	 7
-#define IdProtoParse	 8
-#define IdProtoTimeOutProc 9
-#define IdProtoCancel	 10
-
-#define IdTTFILESetUILanguageFile 11
-#define IdTTFILESetFileSendFilter 12
-
 /*
    Line Head flag for timestamping
    2007.05.24 Gentaro
@@ -134,105 +120,54 @@
 // \x92x\x89\x84\x8F\x91\x82\xAB\x8D\x9E\x82ݗp\x83X\x83\x8C\x83b\x83h\x82̃\x81\x83b\x83Z\x81[\x83W
 #define WM_DPC_LOGTHREAD_SEND (WM_APP + 1)
 
+static const GetProcAddressList ProcList[] = {
+	{ &GetSetupFname, "GetSetupFname", 12 },
+	{ &GetTransFname, "GetTransFname", 16 },
+	{ &GetMultiFname, "GetMultiFname", 16 },
+	{ &GetGetFname, "GetGetFname", 8 },
+	{ &SetFileVar, "SetFileVar", 4 },
+	{ &GetXFname, "GetXFname", 20 },
+	{ &ProtoInit, "ProtoInit", 20 },
+	{ &ProtoParse, "ProtoParse", 16 },
+	{ &ProtoTimeOutProc, "ProtoTimeOutProc", 16 },
+	{ &ProtoCancel, "ProtoCancel", 16 },
+	{ &TTFILESetUILanguageFile, "TTFILESetUILanguageFile", 4 },
+	{ &TTFILESetFileSendFilter, "TTFILESetFileSendFilter", 4 },
+};
+
 static void CloseFileSync(PFileVar ptr);
 
+static void FreeTTFILECommon()
+{
+	FreeLibrary(HTTFILE);
+	HTTFILE = NULL;
 
+	ClearProcAddressses(ProcList, _countof(ProcList));
+}
+
 BOOL LoadTTFILE()
 {
-	BOOL Err;
 
-	if (HTTFILE != NULL)
+	if (HTTFILE == NULL)
 	{
-		TTFILECount++;
-		return TRUE;
-	}
-	else
+		BOOL ret;
+
 		TTFILECount = 0;
 
-	HTTFILE = LoadHomeDLL("TTPFILE.DLL");
-	if (HTTFILE == NULL)
-		return FALSE;
+		HTTFILE = LoadHomeDLL("TTPFILE.DLL");
+		if (HTTFILE == NULL)
+			return FALSE;
 
-	Err = FALSE;
-
-	GetSetupFname = (PGetSetupFname)GetProcAddress(HTTFILE,
-	                                               MAKEINTRESOURCE(IdGetSetupFname));
-	if (GetSetupFname==NULL)
-		Err = TRUE;
-
-	GetTransFname = (PGetTransFname)GetProcAddress(HTTFILE,
-	                                               MAKEINTRESOURCE(IdGetTransFname));
-	if (GetTransFname==NULL)
-		Err = TRUE;
-
-	GetMultiFname = (PGetMultiFname)GetProcAddress(HTTFILE,
-	                                               MAKEINTRESOURCE(IdGetMultiFname));
-	if (GetMultiFname==NULL)
-		Err = TRUE;
-
-	GetGetFname = (PGetGetFname)GetProcAddress(HTTFILE,
-	                                           MAKEINTRESOURCE(IdGetGetFname));
-	if (GetGetFname==NULL)
-		Err = TRUE;
-
-	SetFileVar = (PSetFileVar)GetProcAddress(HTTFILE,
-	                                         MAKEINTRESOURCE(IdSetFileVar));
-	if (SetFileVar==NULL)
-		Err = TRUE;
-
-	GetXFname = (PGetXFname)GetProcAddress(HTTFILE,
-	                                       MAKEINTRESOURCE(IdGetXFname));
-	if (GetXFname==NULL)
-		Err = TRUE;
-
-	ProtoInit = (PProtoInit)GetProcAddress(HTTFILE,
-	                                       MAKEINTRESOURCE(IdProtoInit));
-	if (ProtoInit==NULL)
-		Err = TRUE;
-
-	ProtoParse = (PProtoParse)GetProcAddress(HTTFILE,
-	                                         MAKEINTRESOURCE(IdProtoParse));
-	if (ProtoParse==NULL)
-		Err = TRUE;
-
-	ProtoTimeOutProc = (PProtoTimeOutProc)GetProcAddress(HTTFILE,
-	                                                     MAKEINTRESOURCE(IdProtoTimeOutProc));
-	if (ProtoTimeOutProc==NULL)
-		Err = TRUE;
-
-	ProtoCancel = (PProtoCancel)GetProcAddress(HTTFILE,
-	                                           MAKEINTRESOURCE(IdProtoCancel));
-	if (ProtoCancel==NULL)
-		Err = TRUE;
-
-	TTFILESetUILanguageFile = (PTTFILESetUILanguageFile)GetProcAddress(HTTFILE,
-	                                                                   MAKEINTRESOURCE(IdTTFILESetUILanguageFile));
-	if (TTFILESetUILanguageFile==NULL) {
-		Err = TRUE;
-	}
-	else {
+		ret = GetProcAddressses(HTTFILE, ProcList, _countof(ProcList));
+		if (!ret) {
+			FreeTTFILECommon();
+			return FALSE;
+		}
 		TTFILESetUILanguageFile(ts.UILanguageFile);
-	}
-
-	TTFILESetFileSendFilter = (PTTFILESetFileSendFilter)GetProcAddress(HTTFILE,
-	                                                                   MAKEINTRESOURCE(IdTTFILESetFileSendFilter));
-	if (TTFILESetFileSendFilter==NULL) {
-		Err = TRUE;
-	}
-	else {
 		TTFILESetFileSendFilter(ts.FileSendFilter);
 	}
-
-	if (Err)
-	{
-		FreeLibrary(HTTFILE);
-		HTTFILE = NULL;
-		return FALSE;
-	}
-	else {
-		TTFILECount = 1;
-		return TRUE;
-	}
+	TTFILECount++;
+	return TRUE;
 }
 
 BOOL FreeTTFILE()
@@ -244,8 +179,7 @@
 		return TRUE;
 	if (HTTFILE!=NULL)
 	{
-		FreeLibrary(HTTFILE);
-		HTTFILE = NULL;
+		FreeTTFILECommon();
 	}
 	return TRUE;
 }

Modified: branches/cmake/teraterm/teraterm/filesys.h
===================================================================
--- branches/cmake/teraterm/teraterm/filesys.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/filesys.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -31,28 +31,28 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-typedef BOOL (PASCAL *PGetSetupFname)
+typedef BOOL (WINAPI *PGetSetupFname)
   (HWND HWin, WORD FuncId, PTTSet ts);
-typedef BOOL (PASCAL *PGetTransFname)
+typedef BOOL (WINAPI *PGetTransFname)
   (PFileVar fv, PCHAR CurDir, WORD FuncId, LPLONG Option);
-typedef BOOL (PASCAL *PGetMultiFname)
+typedef BOOL (WINAPI *PGetMultiFname)
   (PFileVar fv, PCHAR CurDir, WORD FuncId, LPWORD Option);
-typedef BOOL (PASCAL *PGetGetFname)
+typedef BOOL (WINAPI *PGetGetFname)
   (HWND HWin, PFileVar fv);
-typedef void (PASCAL *PSetFileVar) (PFileVar fv);
-typedef BOOL (PASCAL *PGetXFname)
+typedef void (WINAPI *PSetFileVar) (PFileVar fv);
+typedef BOOL (WINAPI *PGetXFname)
   (HWND HWin, BOOL Receive, LPLONG Option, PFileVar fv, PCHAR CurDir);
-typedef void (PASCAL *PProtoInit)
+typedef void (WINAPI *PProtoInit)
   (int Proto, PFileVar fv, PCHAR pv, PComVar cv, PTTSet ts);
-typedef BOOL (PASCAL *PProtoParse)
+typedef BOOL (WINAPI *PProtoParse)
   (int Proto, PFileVar fv, PCHAR pv, PComVar cv);
-typedef void (PASCAL *PProtoTimeOutProc)
+typedef void (WINAPI *PProtoTimeOutProc)
   (int Proto, PFileVar fv, PCHAR pv, PComVar cv);
-typedef BOOL (PASCAL *PProtoCancel)
+typedef BOOL (WINAPI *PProtoCancel)
   (int Proto, PFileVar fv, PCHAR pv, PComVar cv);
-typedef BOOL (PASCAL *PTTFILESetUILanguageFile)
+typedef BOOL (WINAPI *PTTFILESetUILanguageFile)
   (char *file);
-typedef BOOL (PASCAL *PTTFILESetFileSendFilter)
+typedef BOOL (WINAPI *PTTFILESetFileSendFilter)
   (char *file);
 
 extern PGetSetupFname GetSetupFname;

Modified: branches/cmake/teraterm/teraterm/teklib.c
===================================================================
--- branches/cmake/teraterm/teraterm/teklib.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/teklib.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -33,6 +33,7 @@
 #include "tttypes.h"
 #include "tektypes.h"
 #include "ttwinman.h"
+#include "ttutil.h"
 
 #include "teklib.h"
 
@@ -49,7 +50,6 @@
 PTEKWMSize TEKWMSize;
 PTEKCMCopy TEKCMCopy;
 PTEKCMCopyScreen TEKCMCopyScreen;
-
 PTEKPrint TEKPrint;
 PTEKClearScreen TEKClearScreen;
 PTEKSetupFont TEKSetupFont;
@@ -58,125 +58,64 @@
 PTEKEnd TEKEnd;
 
 static HMODULE HTTTEK = NULL;
+static UseCount = 0;
 
-#define IdTEKInit	   1
-#define IdTEKResizeWindow  2
-#define IdTEKChangeCaret   3
-#define IdTEKDestroyCaret  4
-#define IdTEKParse	   5
-#define IdTEKReportGIN	   6
-#define IdTEKPaint	   7
-#define IdTEKWMLButtonDown 8
-#define IdTEKWMLButtonUp   9
-#define IdTEKWMMouseMove   10
-#define IdTEKWMSize	   11
-#define IdTEKCMCopy	   12
-#define IdTEKCMCopyScreen  13
-#define IdTEKPrint	   14
-#define IdTEKClearScreen   15
-#define IdTEKSetupFont	   16
-#define IdTEKResetWin	   17
-#define IdTEKRestoreSetup  18
-#define IdTEKEnd	   19
+static const GetProcAddressList ProcList[] = {
+	{ &TEKInit, "TEKInit" },
+	{ &TEKResizeWindow, "TEKResizeWindow" },
+	{ &TEKChangeCaret, "TEKChangeCaret" },
+	{ &TEKDestroyCaret, "TEKDestroyCaret" },
+	{ &TEKParse, "TEKParse" },
+	{ &TEKReportGIN, "TEKReportGIN" },
+	{ &TEKPaint, "TEKPaint" },
+	{ &TEKWMLButtonDown, "TEKWMLButtonDown" },
+	{ &TEKWMLButtonUp, "TEKWMLButtonUp" },
+	{ &TEKWMMouseMove, "TEKWMMouseMove" },
+	{ &TEKWMSize, "TEKWMSize" },
+	{ &TEKCMCopy, "TEKCMCopy" },
+	{ &TEKCMCopyScreen, "TEKCMCopyScreen" },
+	{ &TEKPrint, "TEKPrint" },
+	{ &TEKClearScreen, "TEKClearScreen" },
+	{ &TEKSetupFont, "TEKSetupFont" },
+	{ &TEKResetWin, "TEKResetWin" },
+	{ &TEKRestoreSetup, "TEKRestoreSetup" },
+	{ &TEKEnd, "TEKEnd" },
+};
 
-BOOL LoadTTTEK()
+static void FreeTTTEKCommon()
 {
-  BOOL Err;
+    FreeLibrary(HTTTEK);
+    HTTTEK = NULL;
 
-  if (HTTTEK != NULL) return TRUE;
-  HTTTEK = LoadHomeDLL("TTPTEK.DLL");
-  if (HTTTEK == NULL) return FALSE;
+	ClearProcAddressses(ProcList, _countof(ProcList));
+}
 
-  Err = FALSE;
-  TEKInit = (PTEKInit)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKInit));
-  if (TEKInit==NULL) Err = TRUE;
+BOOL LoadTTTEK()
+{
+	if (UseCount == 0) {
+		BOOL ret;
 
-  TEKResizeWindow = (PTEKResizeWindow)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKResizeWindow));
-  if (TEKResizeWindow==NULL) Err = TRUE;
+		HTTTEK = LoadHomeDLL("TTPTEK.DLL");
+		if (HTTTEK == NULL) return FALSE;
 
-  TEKChangeCaret = (PTEKChangeCaret)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKChangeCaret));
-  if (TEKChangeCaret==NULL) Err = TRUE;
-
-  TEKDestroyCaret = (PTEKDestroyCaret)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKDestroyCaret));
-  if (TEKDestroyCaret==NULL) Err = TRUE;
-
-  TEKParse = (PTEKParse)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKParse));
-  if (TEKParse==NULL) Err = TRUE;
-
-  TEKReportGIN = (PTEKReportGIN)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKReportGIN));
-  if (TEKReportGIN==NULL) Err = TRUE;
-
-  TEKPaint = (PTEKPaint)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKPaint));
-  if (TEKPaint==NULL) Err = TRUE;
-
-  TEKWMLButtonDown = (PTEKWMLButtonDown)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKWMLButtonDown));
-  if (TEKWMLButtonDown==NULL) Err = TRUE;
-
-  TEKWMLButtonUp = (PTEKWMLButtonUp)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKWMLButtonUp));
-  if (TEKWMLButtonUp==NULL) Err = TRUE;
-
-  TEKWMMouseMove = (PTEKWMMouseMove)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKWMMouseMove));
-  if (TEKWMMouseMove==NULL) Err = TRUE;
-
-  TEKWMSize = (PTEKWMSize)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKWMSize));
-  if (TEKWMSize==NULL) Err = TRUE;
-
-  TEKCMCopy = (PTEKCMCopy)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKCMCopy));
-  if (TEKCMCopy==NULL) Err = TRUE;
-
-  TEKCMCopyScreen = (PTEKCMCopyScreen)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKCMCopyScreen));
-  if (TEKCMCopyScreen==NULL) Err = TRUE;
-
-  TEKPrint = (PTEKPrint)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKPrint));
-  if (TEKPrint==NULL) Err = TRUE;
-
-  TEKClearScreen = (PTEKClearScreen)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKClearScreen));
-  if (TEKClearScreen==NULL) Err = TRUE;
-
-  TEKSetupFont = (PTEKSetupFont)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKSetupFont));
-  if (TEKSetupFont==NULL) Err = TRUE;
-
-  TEKResetWin = (PTEKResetWin)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKResetWin));
-  if (TEKResetWin==NULL) Err = TRUE;
-
-  TEKRestoreSetup = (PTEKRestoreSetup)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKRestoreSetup));
-  if (TEKRestoreSetup==NULL) Err = TRUE;
-
-  TEKEnd = (PTEKEnd)GetProcAddress(HTTTEK,
-    MAKEINTRESOURCE(IdTEKEnd));
-  if (TEKEnd==NULL) Err = TRUE;
-
-  if (Err)
-  {
-    FreeLibrary(HTTTEK);
-    HTTTEK = NULL;
-  }
-  return (! Err);
+		ret = GetProcAddressses(HTTTEK, ProcList, _countof(ProcList));
+		if (!ret)
+		{
+			FreeTTTEKCommon();
+		}
+	}
+	UseCount++;
+	return TRUE;
 }
 
-void FreeTTTEK()
+BOOL FreeTTTEK()
 {
-  if (HTTTEK!=NULL)
-  {
-    FreeLibrary(HTTTEK);
-    HTTTEK = NULL;
-  }
+	if (UseCount == 0) {
+		return FALSE;
+	}
+	UseCount--;
+	if (UseCount == 0) {
+		FreeTTTEKCommon();
+	}
+	return TRUE;
 }

Modified: branches/cmake/teraterm/teraterm/teklib.h
===================================================================
--- branches/cmake/teraterm/teraterm/teklib.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/teklib.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -33,43 +33,43 @@
 extern "C" {
 #endif
 
-typedef void (PASCAL *PTEKInit)
+typedef void (WINAPI *PTEKInit)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKResizeWindow)
+typedef void (WINAPI *PTEKResizeWindow)
   (PTEKVar tk, PTTSet ts, int W, int H);
-typedef void (PASCAL *PTEKChangeCaret)
+typedef void (WINAPI *PTEKChangeCaret)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKDestroyCaret)
+typedef void (WINAPI *PTEKDestroyCaret)
   (PTEKVar tk, PTTSet ts);
-typedef int (PASCAL *PTEKParse)
+typedef int (WINAPI *PTEKParse)
   (PTEKVar tk, PTTSet ts, PComVar cv);
-typedef void (PASCAL *PTEKReportGIN)
+typedef void (WINAPI *PTEKReportGIN)
   (PTEKVar tk, PTTSet ts, PComVar cv, BYTE KeyCode);
-typedef void (PASCAL *PTEKPaint)
+typedef void (WINAPI *PTEKPaint)
   (PTEKVar tk, PTTSet ts, HDC PaintDC, PAINTSTRUCT *PaintInfo);
-typedef void (PASCAL *PTEKWMLButtonDown)
+typedef void (WINAPI *PTEKWMLButtonDown)
   (PTEKVar tk, PTTSet ts, PComVar cv, POINT pos);
-typedef void (PASCAL *PTEKWMLButtonUp)
+typedef void (WINAPI *PTEKWMLButtonUp)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKWMMouseMove)
+typedef void (WINAPI *PTEKWMMouseMove)
   (PTEKVar tk, PTTSet ts, POINT p);
-typedef void (PASCAL *PTEKWMSize)
+typedef void (WINAPI *PTEKWMSize)
   (PTEKVar tk, PTTSet ts, int W, int H, int cx, int cy);
-typedef void (PASCAL *PTEKCMCopy)
+typedef void (WINAPI *PTEKCMCopy)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKCMCopyScreen)
+typedef void (WINAPI *PTEKCMCopyScreen)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKPrint)
+typedef void (WINAPI *PTEKPrint)
   (PTEKVar tk, PTTSet ts, HDC PrintDC, BOOL SelFlag);
-typedef void (PASCAL *PTEKClearScreen)
+typedef void (WINAPI *PTEKClearScreen)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKSetupFont)
+typedef void (WINAPI *PTEKSetupFont)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKResetWin)
+typedef void (WINAPI *PTEKResetWin)
   (PTEKVar tk, PTTSet ts, WORD EmuOld);
-typedef void (PASCAL *PTEKRestoreSetup)
+typedef void (WINAPI *PTEKRestoreSetup)
   (PTEKVar tk, PTTSet ts);
-typedef void (PASCAL *PTEKEnd)
+typedef void (WINAPI *PTEKEnd)
   (PTEKVar tk);
 
 extern PTEKInit TEKInit;
@@ -94,7 +94,7 @@
 
 /* proto types */
 BOOL LoadTTTEK();
-void FreeTTTEK();
+BOOL FreeTTTEK();
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/teraterm/ttdialog.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttdialog.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttdialog.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,13 @@
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttplug.h" /* TTPLUG */
+#include "ttutil.h"
 
 #include "ttdialog.h"
 #include "ttwinman.h"
 
 static HMODULE HTTDLG = NULL;
-static TTDLGUseCount = 0;
+static int TTDLGUseCount = 0;
 
 PSetupTerminal SetupTerminal;
 PSetupWin SetupWin;
@@ -51,112 +52,44 @@
 PWindowWindow WindowWindow;
 PTTDLGSetUILanguageFile TTDLGSetUILanguageFile;
 
-#define IdSetupTerminal   1
-#define IdSetupWin        2
-#define IdSetupKeyboard   3
-#define IdSetupSerialPort 4
-#define IdSetupTCPIP      5
-#define IdGetHostName     6
-#define IdChangeDirectory 7
-#define IdAboutDialog     8
-#define IdChooseFontDlg   9
-#define IdSetupGeneral    10
-#define IdWindowWindow    11
-#define IdTTDLGSetUILanguageFile  12
+static const GetProcAddressList ProcList[] = {
+	{ &SetupTerminal, "SetupTerminal", 8 },
+	{ &SetupWin, "SetupWin", 8 },
+	{ &SetupKeyboard, "SetupKeyboard", 8 },
+	{ &SetupSerialPort, "SetupSerialPort", 8 },
+	{ &SetupTCPIP, "SetupTCPIP", 8 },
+	{ &GetHostName, "GetHostName", 8 },
+	{ &ChangeDirectory, "ChangeDirectory", 8 },
+	{ &AboutDialog, "AboutDialog", 4 },
+	{ &ChooseFontDlg, "ChooseFontDlg", 12 },
+	{ &SetupGeneral, "SetupGeneral", 8 },
+	{ &WindowWindow, "WindowWindow", 8 },
+	{ &TTDLGSetUILanguageFile, "TTDLGSetUILanguageFile", 4 },
+};
 
+static void FreeTTDLGCommon()
+{
+	FreeLibrary(HTTDLG);
+	HTTDLG = NULL;
+
+	ClearProcAddressses(ProcList, _countof(ProcList));
+}
+
 BOOL LoadTTDLG()
 {
-	BOOL Err;
+	if (TTDLGUseCount == 0) {
+		BOOL ret;
 
-	if (HTTDLG == NULL) {
-		TTDLGUseCount = 0;
-
 		HTTDLG = LoadHomeDLL("TTPDLG.DLL");
 		if (HTTDLG==NULL) return FALSE;
 
-		Err = FALSE;
-
-		SetupTerminal = (PSetupTerminal)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupTerminal));
-		if (SetupTerminal==NULL) {
-			Err = TRUE;
-		}
-
-		SetupWin = (PSetupWin)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupWin));
-		if (SetupWin==NULL) {
-			Err = TRUE;
-		}
-
-		SetupKeyboard = (PSetupKeyboard)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupKeyboard));
-		if (SetupKeyboard==NULL) {
-			Err = TRUE;
-		}
-
-		SetupSerialPort = (PSetupSerialPort)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupSerialPort));
-		if (SetupSerialPort==NULL) {
-			Err = TRUE;
-		}
-
-		SetupTCPIP = (PSetupTCPIP)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupTCPIP));
-		if (SetupTCPIP==NULL) {
-			Err = TRUE;
-		}
-
-		GetHostName = (PGetHostName)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdGetHostName));
-		if (GetHostName==NULL) {
-			Err = TRUE;
-		}
-
-		ChangeDirectory = (PChangeDirectory)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdChangeDirectory));
-		if (ChangeDirectory==NULL) {
-			Err = TRUE;
-		}
-
-		AboutDialog = (PAboutDialog)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdAboutDialog));
-		if (AboutDialog==NULL) {
-			Err = TRUE;
-		}
-
-		ChooseFontDlg = (PChooseFontDlg)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdChooseFontDlg));
-		if (ChooseFontDlg==NULL) {
-			Err = TRUE;
-		}
-
-		SetupGeneral = (PSetupGeneral)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdSetupGeneral));
-		if (SetupGeneral==NULL) {
-			Err = TRUE;
-		}
-
-		WindowWindow = (PWindowWindow)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdWindowWindow));
-		if (WindowWindow==NULL) {
-			Err = TRUE;
-		}
-
-		TTDLGSetUILanguageFile = (PTTDLGSetUILanguageFile)GetProcAddress(HTTDLG,
-		  MAKEINTRESOURCE(IdTTDLGSetUILanguageFile));
-		if (TTDLGSetUILanguageFile==NULL) {
-			Err = TRUE;
-		}
-		else {
-			TTDLGSetUILanguageFile(ts.UILanguageFile);
-		}
-
-		if (Err) {
-			FreeLibrary(HTTDLG);
-			HTTDLG = NULL;
+		ret = GetProcAddressses(HTTDLG, ProcList, _countof(ProcList));
+		if (!ret) {
+			FreeTTDLGCommon();
 			return FALSE;
 		}
 
+		TTDLGSetUILanguageFile(ts.UILanguageFile);
 		TTXGetUIHooks(); /* TTPLUG */
 	}
 	TTDLGUseCount++;
@@ -165,17 +98,13 @@
 
 BOOL FreeTTDLG()
 {
-	if (TTDLGUseCount==0) {
+	if (TTDLGUseCount == 0) {
 		return FALSE;
 	}
 	TTDLGUseCount--;
-	if (TTDLGUseCount>0) {
-		return TRUE;
+	if (TTDLGUseCount == 0) {
+		FreeTTDLGCommon();
 	}
-	if (HTTDLG!=NULL) {
-		FreeLibrary(HTTDLG);
-		HTTDLG = NULL;
-	}
-	return FALSE;
+	return TRUE;
 }
 

Modified: branches/cmake/teraterm/teraterm/ttdialog.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttdialog.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttdialog.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -32,29 +32,29 @@
 extern "C" {
 #endif
 
-typedef BOOL (PASCAL *PSetupTerminal)
+typedef BOOL (WINAPI *PSetupTerminal)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PSetupWin)
+typedef BOOL (WINAPI *PSetupWin)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PSetupKeyboard)
+typedef BOOL (WINAPI *PSetupKeyboard)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PSetupSerialPort)
+typedef BOOL (WINAPI *PSetupSerialPort)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PSetupTCPIP)
+typedef BOOL (WINAPI *PSetupTCPIP)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PGetHostName)
+typedef BOOL (WINAPI *PGetHostName)
   (HWND WndParent, PGetHNRec GetHNRec);
-typedef BOOL (PASCAL *PChangeDirectory)
+typedef BOOL (WINAPI *PChangeDirectory)
   (HWND WndParent, PCHAR CurDir);
-typedef BOOL (PASCAL *PAboutDialog)
+typedef BOOL (WINAPI *PAboutDialog)
   (HWND WndParent);
-typedef BOOL (PASCAL *PChooseFontDlg)
+typedef BOOL (WINAPI *PChooseFontDlg)
   (HWND WndParent, LPLOGFONT LogFont, PTTSet ts);
-typedef BOOL (PASCAL *PSetupGeneral)
+typedef BOOL (WINAPI *PSetupGeneral)
   (HWND WndParent, PTTSet ts);
-typedef BOOL (PASCAL *PWindowWindow)
+typedef BOOL (WINAPI *PWindowWindow)
   (HWND WndParent, PBOOL Close);
-typedef BOOL (PASCAL *PTTDLGSetUILanguageFile)
+typedef BOOL (WINAPI *PTTDLGSetUILanguageFile)
   (char *file);
 
 extern PSetupTerminal SetupTerminal;

Modified: branches/cmake/teraterm/teraterm/ttfileio.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttfileio.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttfileio.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -38,7 +38,7 @@
 TCreateFile PCreateFile;
 TCloseFile PCloseFile;
 
-static BOOL PASCAL DummyWriteFile(HANDLE fh, LPCVOID buff,
+static BOOL WINAPI DummyWriteFile(HANDLE fh, LPCVOID buff,
   DWORD len, LPDWORD wbytes, LPOVERLAPPED wol)
 {
 	*wbytes = len;

Modified: branches/cmake/teraterm/teraterm/ttfileio.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttfileio.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttfileio.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -31,16 +31,16 @@
 extern "C" {
 #endif
 
-typedef BOOL (PASCAL *TReadFile)
+typedef BOOL (WINAPI *TReadFile)
   (HANDLE FHandle, LPVOID Buff, DWORD ReadSize, LPDWORD ReadBytes,
    LPOVERLAPPED ReadOverLap);
-typedef BOOL (PASCAL *TWriteFile)
+typedef BOOL (WINAPI *TWriteFile)
   (HANDLE FHandle, LPCVOID Buff, DWORD WriteSize, LPDWORD WriteBytes,
    LPOVERLAPPED WriteOverLap);
-typedef HANDLE (PASCAL *TCreateFile)
+typedef HANDLE (WINAPI *TCreateFile)
   (LPCTSTR FName, DWORD AcMode, DWORD ShMode, LPSECURITY_ATTRIBUTES SecAttr,
    DWORD CreateDisposition, DWORD FileAttr, HANDLE Template);
-typedef BOOL (PASCAL *TCloseFile)
+typedef BOOL (WINAPI *TCloseFile)
   (HANDLE FHandle);
 
 extern TReadFile PReadFile;

Modified: branches/cmake/teraterm/teraterm/ttplug.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttplug.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttplug.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -104,7 +104,7 @@
   MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONEXCLAMATION);
 }
 
-void PASCAL TTXInit(PTTSet ts, PComVar cv) {
+void WINAPI TTXInit(PTTSet ts, PComVar cv) {
   ExtensionList * extensionList = NULL;
   int i;
 
@@ -148,7 +148,7 @@
   }
 }
 
-void PASCAL TTXInternalOpenTCP(TTXSockHooks * hooks) {
+void WINAPI TTXInternalOpenTCP(TTXSockHooks * hooks) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -158,7 +158,7 @@
   }
 }
 
-void PASCAL TTXInternalCloseTCP(TTXSockHooks * hooks) {
+void WINAPI TTXInternalCloseTCP(TTXSockHooks * hooks) {
   int i;
 
   for (i = NumExtensions - 1; i >= 0; i--) {
@@ -168,7 +168,7 @@
   }
 }
 
-void PASCAL TTXInternalOpenFile(TTXFileHooks * hooks) {
+void WINAPI TTXInternalOpenFile(TTXFileHooks * hooks) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -178,7 +178,7 @@
   }
 }
 
-void PASCAL TTXInternalCloseFile(TTXFileHooks * hooks) {
+void WINAPI TTXInternalCloseFile(TTXFileHooks * hooks) {
   int i;
 
   for (i = NumExtensions - 1; i >= 0; i--) {
@@ -188,7 +188,7 @@
   }
 }
 
-void PASCAL TTXInternalGetUIHooks(TTXUIHooks * hooks) {
+void WINAPI TTXInternalGetUIHooks(TTXUIHooks * hooks) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -198,7 +198,7 @@
   }
 }
 
-void PASCAL TTXInternalGetSetupHooks(TTXSetupHooks * hooks) {
+void WINAPI TTXInternalGetSetupHooks(TTXSetupHooks * hooks) {
   int i;
 
   for (i = NumExtensions - 1; i >= 0; i--) {
@@ -208,7 +208,7 @@
   }
 }
 
-void PASCAL TTXSetWinSize(int rows, int cols) {
+void WINAPI TTXSetWinSize(int rows, int cols) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -218,7 +218,7 @@
   }
 }
 
-void PASCAL TTXModifyMenu(HMENU menu) {
+void WINAPI TTXModifyMenu(HMENU menu) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -228,7 +228,7 @@
   }
 }
 
-void PASCAL TTXModifyPopupMenu(HMENU menu) {
+void WINAPI TTXModifyPopupMenu(HMENU menu) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {
@@ -238,7 +238,7 @@
   }
 }
 
-BOOL PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
+BOOL WINAPI TTXProcessCommand(HWND hWin, WORD cmd) {
   int i;
 
   for (i = NumExtensions - 1; i >= 0; i--) {
@@ -252,7 +252,7 @@
   return FALSE;
 }
 
-void PASCAL TTXEnd(void) {
+void WINAPI TTXEnd(void) {
   int i;
 
   if (NumExtensions==0) return;
@@ -274,7 +274,7 @@
   NumExtensions = 0;
 }
 
-void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
+void WINAPI TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
   int i;
 
   for (i = 0; i < NumExtensions; i++) {

Modified: branches/cmake/teraterm/teraterm/ttplug.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttplug.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttplug.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -38,12 +38,12 @@
 
 /* This function initializes the extensions and is called at the beginning
    of the program. */
-void PASCAL TTXInit(PTTSet ts, PComVar cv);
+void WINAPI TTXInit(PTTSet ts, PComVar cv);
 
 /* This function is called when a TCP connection is about to be opened.
    This macro stuff is to make sure that the functions in the caller's
    EXE or DLL are hooked. */
-void PASCAL TTXInternalOpenTCP(TTXSockHooks * hooks);
+void WINAPI TTXInternalOpenTCP(TTXSockHooks * hooks);
 #define TTXOpenTCP()                                             \
   do {                                                           \
     static TTXSockHooks SockHooks = {                            \
@@ -59,7 +59,7 @@
 /* This function is called when a TCP connection has been closed.
    This macro stuff is to make sure that the functions in the caller's
    EXE or DLL are hooked. */
-void PASCAL TTXInternalCloseTCP(TTXSockHooks * hooks);
+void WINAPI TTXInternalCloseTCP(TTXSockHooks * hooks);
 #define TTXCloseTCP()                                            \
   do {                                                           \
     static TTXSockHooks SockHooks = {                            \
@@ -72,7 +72,7 @@
     TTXInternalCloseTCP(&SockHooks);                             \
   } while (0)
 
-void PASCAL TTXInternalOpenFile(TTXFileHooks * hooks);
+void WINAPI TTXInternalOpenFile(TTXFileHooks * hooks);
 #define TTXOpenFile()                                            \
   do {                                                           \
     static TTXFileHooks FileHooks = {                            \
@@ -81,7 +81,7 @@
     TTXInternalOpenFile(&FileHooks);                             \
   } while (0)
 
-void PASCAL TTXInternalCloseFile(TTXFileHooks * hooks);
+void WINAPI TTXInternalCloseFile(TTXFileHooks * hooks);
 #define TTXCloseFile()                                           \
   do {                                                           \
     static TTXFileHooks FileHooks = {                            \
@@ -93,7 +93,7 @@
 /* This function is called after the TTDLG DLL has been loaded.
    This macro stuff is to make sure that the functions in the caller's
    EXE or DLL are hooked. */
-void PASCAL TTXInternalGetUIHooks(TTXUIHooks * hooks);
+void WINAPI TTXInternalGetUIHooks(TTXUIHooks * hooks);
 #define TTXGetUIHooks()                                            \
   do {                                                             \
     static TTXUIHooks UIHooks = {                                  \
@@ -107,7 +107,7 @@
 /* This function is called after the TTSET DLL has been loaded.
    This macro stuff is to make sure that the functions in the caller's
    EXE or DLL are hooked. */
-void PASCAL TTXInternalGetSetupHooks(TTXSetupHooks * hooks);
+void WINAPI TTXInternalGetSetupHooks(TTXSetupHooks * hooks);
 #define TTXGetSetupHooks()                                            \
   do {                                                                \
     static TTXSetupHooks SetupHooks = {                               \
@@ -118,27 +118,27 @@
   } while (0)
 
 /* This function is called when the window size has changed. */
-void PASCAL TTXSetWinSize(int rows, int cols);
+void WINAPI TTXSetWinSize(int rows, int cols);
 
 /* This function adds the extensions' entries to the menu, which is the
    handle for the program's menubar. */
-void PASCAL TTXModifyMenu(HMENU menu);
+void WINAPI TTXModifyMenu(HMENU menu);
 
 /* This function is called when a popup menu is about to be displayed.
    The status of the entries is set appropriately. */
-void PASCAL TTXModifyPopupMenu(HMENU menu);
+void WINAPI TTXModifyPopupMenu(HMENU menu);
 
 /* This function calls on the extensions to handle a command. It returns
    TRUE if they handle it, otherwise FALSE. */
-BOOL PASCAL TTXProcessCommand(HWND hWin, WORD cmd);
+BOOL WINAPI TTXProcessCommand(HWND hWin, WORD cmd);
 
 /* This function is called to see whether Telnet mode can be turned on when
    Tera Term thinks it has detected a telnetd */
-void PASCAL TTXEnd(void);
+void WINAPI TTXEnd(void);
 
 /* This function is called when a new Tera Term is being started with certain
    settings and the extension may wish to add some options to the command line */
-void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec);
+void WINAPI TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec);
 #ifdef __cplusplus
 }
 #endif

Modified: branches/cmake/teraterm/teraterm/ttsetup.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttsetup.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttsetup.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -33,9 +33,13 @@
 
 #include "ttsetup.h"
 #include "ttplug.h" /* TTPLUG */
+#include "ttutil.h"
 
 #include "ttwinman.h"
 
+static HANDLE HTTSET = NULL;
+static int UseCount = 0;
+
 PReadIniFile ReadIniFile;
 PWriteIniFile WriteIniFile;
 PReadKeyboardCnf ReadKeyboardCnf;
@@ -45,73 +49,53 @@
 PCopySerialList CopySerialList;
 PAddValueToList AddValueToList;
 
-static HANDLE HTTSET = NULL;
+static const GetProcAddressList ProcList[] = {
+	{ &ReadIniFile, "ReadIniFile", 8 },
+	{ &WriteIniFile, "WriteIniFile", 8 },
+	{ &ReadKeyboardCnf, "ReadKeyboardCnf", 12 },
+	{ &CopyHostList, "CopyHostList", 8 },
+	{ &AddHostToList, "AddHostToList", 8 },
+	{ &ParseParam, "ParseParam", 12 },
+	{ &CopySerialList, "CopySerialList", 20 },
+	{ &AddValueToList, "AddValueToList", 20 },
+};
 
-#define IdReadIniFile     1
-#define IdWriteIniFile    2
-#define IdReadKeyboardCnf 3
-#define IdCopyHostList    4
-#define IdAddHostToList   5
-#define IdParseParam      6
-#define IdCopySerialList  7
-#define IdAddValueToList  8
+static void FreeTTSetCommon()
+{
+	FreeLibrary(HTTSET);
+	HTTSET = NULL;
 
+	ClearProcAddressses(ProcList, _countof(ProcList));
+}
+
 BOOL LoadTTSET()
 {
-  BOOL Err;
+	if (UseCount == 0) {
+		BOOL ret;
 
-  if (HTTSET != NULL) return TRUE;
-  HTTSET = LoadHomeDLL("TTPSET.DLL");
-  if (HTTSET == NULL) return FALSE;
+		HTTSET = LoadHomeDLL("TTPSET.DLL");
+		if (HTTSET == NULL) return FALSE;
 
-  Err = FALSE;
-  ReadIniFile =
-	(PReadIniFile)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdReadIniFile));
-  if (ReadIniFile==NULL) Err = TRUE;
+		ret = GetProcAddressses(HTTSET, ProcList, _countof(ProcList));
+		if (!ret) {
+			FreeTTSetCommon();
+			return FALSE;
+		}
 
-  WriteIniFile =
-	(PWriteIniFile)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdWriteIniFile));
-  if (WriteIniFile==NULL) Err = TRUE;
-
-  ReadKeyboardCnf =
-	(PReadKeyboardCnf)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdReadKeyboardCnf));
-  if (ReadKeyboardCnf==NULL) Err = TRUE;
-
-  CopyHostList =
-	(PCopyHostList)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdCopyHostList));
-  if (CopyHostList==NULL) Err = TRUE;
-
-  AddHostToList =
-	(PAddHostToList)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdAddHostToList));
-  if (AddHostToList==NULL) Err = TRUE;
-
-  ParseParam =
-	(PParseParam)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdParseParam));
-  if (ParseParam==NULL) Err = TRUE;
-
-  CopySerialList =
-	(PCopySerialList)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdCopySerialList));
-  if (CopySerialList==NULL) Err = TRUE;
-
-  AddValueToList =
-	(PAddValueToList)GetProcAddress(HTTSET, MAKEINTRESOURCE(IdAddValueToList));
-  if (AddValueToList==NULL) Err = TRUE;
-
-  if (Err)
-  {
-    FreeLibrary(HTTSET);
-    HTTSET = NULL;
-    return FALSE;
-  }
-  TTXGetSetupHooks(); /* TTPLUG */
-  return TRUE;
+		TTXGetSetupHooks(); /* TTPLUG */
+	}
+	UseCount++;
+	return TRUE;
 }
 
-void FreeTTSET()
+BOOL FreeTTSET()
 {
-  if (HTTSET != NULL)
-  {
-    FreeLibrary(HTTSET);
-    HTTSET = NULL;
-  }
+	if (UseCount == 0) {
+		return FALSE;
+	}
+	UseCount--;
+	if (UseCount == 0) {
+		FreeTTSetCommon();
+	}
+	return TRUE;
 }

Modified: branches/cmake/teraterm/teraterm/ttsetup.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttsetup.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttsetup.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -32,21 +32,21 @@
 extern "C" {
 #endif
 
-typedef void (PASCAL *PReadIniFile)
+typedef void (WINAPI *PReadIniFile)
   (PCHAR FName, PTTSet ts);
-typedef void (PASCAL *PWriteIniFile)
+typedef void (WINAPI *PWriteIniFile)
   (PCHAR FName, PTTSet ts);
-typedef void (PASCAL *PReadKeyboardCnf)
+typedef void (WINAPI *PReadKeyboardCnf)
   (PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning);
-typedef void (PASCAL *PCopyHostList)
+typedef void (WINAPI *PCopyHostList)
   (PCHAR IniSrc, PCHAR IniDest);
-typedef void (PASCAL *PAddHostToList)
+typedef void (WINAPI *PAddHostToList)
   (PCHAR FName, PCHAR Host);
-typedef void (PASCAL *PParseParam)
+typedef void (WINAPI *PParseParam)
   (PCHAR Param, PTTSet ts, PCHAR DDETopic);
-typedef void (PASCAL *PCopySerialList)
+typedef void (WINAPI *PCopySerialList)
   (PCHAR IniSrc, PCHAR IniDest, PCHAR section, PCHAR key, int MaxList);
-typedef void (PASCAL *PAddValueToList)
+typedef void (WINAPI *PAddValueToList)
   (PCHAR FName, PCHAR Host, PCHAR section, PCHAR key, int MaxList);
 
 extern PReadIniFile ReadIniFile;
@@ -60,7 +60,7 @@
 
 /* proto types */
 BOOL LoadTTSET();
-void FreeTTSET();
+BOOL FreeTTSET();
 
 #ifdef __cplusplus
 }

Added: branches/cmake/teraterm/teraterm/ttutil.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttutil.c	                        (rev 0)
+++ branches/cmake/teraterm/teraterm/ttutil.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -0,0 +1,72 @@
+/*
+ * (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* misc. routines  */
+#include <windows.h>
+#include <stdio.h>
+#include "ttutil.h"
+
+BOOL GetProcAddressses(HMODULE hModule, const GetProcAddressList list[], int count)
+{
+	int i;
+	for (i = 0; i < count; i++) {
+		void **pfunc = list[i].func;
+		const char *name = list[i].name;
+		static const char *symbol_templates[] = {
+			"%s",
+#if defined(_MSC_VER)
+			"_%s@%d"
+#endif
+#if defined(__MINGW32__)
+			"%s@%d"
+#endif
+		};
+		void *func = NULL;
+		int j;
+		for (j = 0; j < _countof(symbol_templates); j++) {
+			char buf[64];
+			sprintf_s(buf, sizeof(buf), symbol_templates[j], name, list[i].arg_bytes);
+			func = GetProcAddress(hModule, buf);
+			if (func != NULL) break;
+		}
+		if (func == NULL) {
+			return FALSE;
+		}
+		*pfunc = func;
+	}
+	return TRUE;
+}
+
+void ClearProcAddressses(const GetProcAddressList list[], int count)
+{
+	int i;
+	for (i = 0; i < count; i++) {
+		void **pfunc = list[i].func;
+		*pfunc = NULL;
+	}
+}

Added: branches/cmake/teraterm/teraterm/ttutil.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttutil.h	                        (rev 0)
+++ branches/cmake/teraterm/teraterm/ttutil.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -0,0 +1,48 @@
+/*
+ * (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* useful routines */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+	void *func;
+	const char *name;
+	int arg_bytes;
+} GetProcAddressList;
+
+BOOL GetProcAddressses(HMODULE hModule, const GetProcAddressList list[], int count);
+void ClearProcAddressses(const GetProcAddressList list[], int count);
+
+#ifdef __cplusplus
+}
+#endif

Modified: branches/cmake/teraterm/teraterm/ttwinman.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttwinman.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttwinman.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -39,6 +39,7 @@
 #include "htmlhelp.h"
 #include "i18n.h"
 #include "commlib.h"
+#include "../ttpcmn/language.h"
 
 HWND HVTWin = NULL;
 HWND HTEKWin = NULL;
@@ -78,7 +79,6 @@
 {
 #define IS_SJIS(n) (ts.KanjiCode == IdSJIS && IsDBCSLeadByte(n))
 #define IS_EUC(n) (ts.KanjiCode == IdEUC && (n & 0x80))
-	extern WORD PASCAL JIS2SJIS(WORD KCode);
 	int len = strlen(str);
 	char *cc = _alloca(len + 1);
 	char *c = cc;

Modified: branches/cmake/teraterm/teraterm/ttwsk.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttwsk.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/ttwsk.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -36,46 +36,46 @@
 extern "C" {
 #endif
 
-typedef int (PASCAL *Tclosesocket) (SOCKET s);
-typedef int (PASCAL *Tconnect)
+typedef int (WINAPI *Tclosesocket) (SOCKET s);
+typedef int (WINAPI *Tconnect)
   (SOCKET s, const struct sockaddr *name, int namelen);
-typedef u_long (PASCAL *Thtonl)
+typedef u_long (WINAPI *Thtonl)
   (u_long hostlong);
-typedef u_short (PASCAL *Thtons)
+typedef u_short (WINAPI *Thtons)
   (u_short hostshort);
-typedef unsigned long (PASCAL *Tinet_addr)
+typedef unsigned long (WINAPI *Tinet_addr)
   (const char * cp);
-typedef int (PASCAL *Tioctlsocket)
+typedef int (WINAPI *Tioctlsocket)
   (SOCKET s, long cmd, u_long *argp);
-typedef int (PASCAL *Trecv)
+typedef int (WINAPI *Trecv)
   (SOCKET s, char * buf, int len, int flags);
-typedef int (PASCAL *Tselect)
+typedef int (WINAPI *Tselect)
   (int nfds, fd_set *readfds, fd_set *writefds,
    fd_set *exceptfds, const struct timeval *timeout);
-typedef int (PASCAL *Tsend)
+typedef int (WINAPI *Tsend)
   (SOCKET s, const char * buf, int len, int flags);
-typedef int (PASCAL *Tsetsockopt)
+typedef int (WINAPI *Tsetsockopt)
   (SOCKET s, int level, int optname,
    const char * optval, int optlen);
-typedef SOCKET (PASCAL *Tsocket)
+typedef SOCKET (WINAPI *Tsocket)
   (int af, int type, int protocol);
-//typedef struct hostent * (PASCAL *Tgethostbyname)
+//typedef struct hostent * (WINAPI *Tgethostbyname)
 //  (const char * name);
-typedef int (PASCAL *TWSAStartup)
+typedef int (WINAPI *TWSAStartup)
   (WORD wVersionRequired, LPWSADATA lpWSAData);
-typedef int (PASCAL *TWSACleanup)(void);
-typedef int (PASCAL *TWSAAsyncSelect)
+typedef int (WINAPI *TWSACleanup)(void);
+typedef int (WINAPI *TWSAAsyncSelect)
   (SOCKET s, HWND hWnd, u_int wMsg,long lEvent);
-typedef HANDLE (PASCAL *TWSAAsyncGetHostByName)
+typedef HANDLE (WINAPI *TWSAAsyncGetHostByName)
   (HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen);
-typedef int (PASCAL *TWSACancelAsyncRequest)(HANDLE hAsyncTaskHandle);
-typedef int (PASCAL *TWSAGetLastError)(void);
-typedef HANDLE (PASCAL *TWSAAsyncGetAddrInfo)
+typedef int (WINAPI *TWSACancelAsyncRequest)(HANDLE hAsyncTaskHandle);
+typedef int (WINAPI *TWSAGetLastError)(void);
+typedef HANDLE (WINAPI *TWSAAsyncGetAddrInfo)
   (HWND hWnd, unsigned int wMsg, const char * hostname,
    const char * portname, struct addrinfo * hints,
    struct addrinfo * * res);
-// typedef int (PASCAL *Tgetaddrinfo)(const char *name, const char *port, const struct addrinfo *hints, struct addrinfo **res);
-typedef void (PASCAL *Tfreeaddrinfo)(struct addrinfo *ai);
+// typedef int (WINAPI *Tgetaddrinfo)(const char *name, const char *port, const struct addrinfo *hints, struct addrinfo **res);
+typedef void (WINAPI *Tfreeaddrinfo)(struct addrinfo *ai);
 
 BOOL LoadWinsock();
 void FreeWinsock();

Modified: branches/cmake/teraterm/teraterm/uni2sjis.map
===================================================================
--- branches/cmake/teraterm/teraterm/uni2sjis.map	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/uni2sjis.map	2018-08-26 14:44:23 UTC (rev 7190)
@@ -31,7 +31,7 @@
  * cf. ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT
  *
  */
-static codemap_t mapUnicodeToSJIS[] = {
+static const codemap_t mapUnicodeToSJIS[] = {
 	{ 0x0020, 0x0020 },
 	{ 0x0021, 0x0021 },
 	{ 0x0022, 0x0022 },

Modified: branches/cmake/teraterm/teraterm/uni_combining.map
===================================================================
--- branches/cmake/teraterm/teraterm/uni_combining.map	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/uni_combining.map	2018-08-26 14:44:23 UTC (rev 7190)
@@ -35,7 +35,7 @@
  * cf. http://developer.apple.com/technotes/tn/tn1150table.html
  *
  */
-static combining_map_t mapCombiningToPrecomposed[] = {
+static const combining_map_t mapCombiningToPrecomposed[] = {
 	 {0x00C0,   0x0041, 0x0300},
 	 {0x00C1,   0x0041, 0x0301},
 	 {0x00C2,   0x0041, 0x0302},

Modified: branches/cmake/teraterm/teraterm/unisym2decsp.map
===================================================================
--- branches/cmake/teraterm/teraterm/unisym2decsp.map	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/unisym2decsp.map	2018-08-26 14:44:23 UTC (rev 7190)
@@ -30,7 +30,7 @@
 /*
  * Map of Unicode Symbols to Dec Special Characters
  */
-static codemap_t mapUnicodeSymbolToDecSp[] = {
+static const codemap_t mapUnicodeSymbolToDecSp[] = {
 	/*
 	 * Latin-1 supplement
 	 *   http://www.unicode.org/charts/PDF/U0080.pdf

Modified: branches/cmake/teraterm/teraterm/vtterm.c
===================================================================
--- branches/cmake/teraterm/teraterm/vtterm.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/teraterm/vtterm.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -5327,7 +5327,6 @@
 //
 #include "uni2sjis.map"
 #include "unisym2decsp.map"
-extern unsigned short ConvertUnicode(unsigned short code, codemap_t *table, int tmax);
 
 
 //
@@ -5335,8 +5334,8 @@
 //
 #include "uni_combining.map"
 
-unsigned short GetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code,
-								 combining_map_t *table, int tmax)
+static unsigned short GetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code,
+										 const combining_map_t table[], int tmax)
 {
 	unsigned short result = 0;
 	int i;
@@ -5355,7 +5354,7 @@
 	return (result);
 }
 
-int GetIndexOfCombiningFirstCode(unsigned short code, combining_map_t *table, int tmax)
+static int GetIndexOfCombiningFirstCode(unsigned short code, const combining_map_t table[], int tmax)
 {
 	int low, mid, high;
 	int index = -1;

Modified: branches/cmake/teraterm/ttpcmn/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -13,13 +13,28 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
+  ../common/teraterm.h
+  ../common/tttypes.h
   ../common/i18n.c
   ../common/i18n.h
   ../common/ttlib.c
+  ../common/ttlib.h
   ../common/servicenames.c
   ../common/servicenames.h
-  ttpcmn.def
+  ../common/tt-version.h
+  ../common/ttftypes.h
+  ../common/ttcommon.h
+  ../common/tt_res.h
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   cmn_res.h
   language.c
   language.h
@@ -26,6 +41,7 @@
   ttcmn.c
   ttpcmn-version.rc
   ttpcmn.rc
+  ${COMMON_SRC}
   )
 
 include_directories(
@@ -41,10 +57,15 @@
 endif()
 
 add_library(
-  ttpcmn SHARED
+  ttpcmn
+  SHARED
   ${SRC}
   )
 
+target_compile_definitions(
+  ttpcmn
+  PRIVATE -DTTPCMN_DLL
+  )
 if(MINGW)
   set_target_properties(
 	ttpcmn

Modified: branches/cmake/teraterm/ttpcmn/language.c
===================================================================
--- branches/cmake/teraterm/ttpcmn/language.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/language.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -29,6 +29,9 @@
 
 // TTCMN.DLL character code conversion
 
+#define DllExport __declspec(dllexport) 
+#include "language.h"
+#undef DllExport
 #include "teraterm.h"
 #include "tttypes.h"
 #include <mbstring.h>
@@ -36,7 +39,15 @@
 
 #include "sjis2uni.map"
 
-unsigned short ConvertUnicode(unsigned short code, codemap_t *table, int tmax)
+#if !defined(DllExport)
+#if defined(TTPCMN)
+#define DllExport __declspec(dllexport) 
+#else
+#define DllExport __declspec(dllexport) 
+#endif
+#endif
+
+DllExport unsigned short WINAPI ConvertUnicode(unsigned short code, const codemap_t *table, int tmax)
 {
 	int low, mid, high;
 	unsigned short result;
@@ -62,7 +73,7 @@
 	return (result);
 }
 
-unsigned int PASCAL SJIS2UTF8(WORD KCode, int *byte, char *locale)
+DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, char *locale)
 {
 	wchar_t wchar;
 	int ret;
@@ -122,7 +133,7 @@
 
 
 // Japanese SJIS -> JIS
-WORD PASCAL SJIS2JIS(WORD KCode)
+DllExport WORD WINAPI SJIS2JIS(WORD KCode)
 {
 	WORD x0,x1,x2,y0;
 	BYTE b = LOBYTE(KCode);
@@ -149,13 +160,13 @@
 }
 
 // Japanese SJIS -> EUC
-WORD PASCAL SJIS2EUC(WORD KCode)
+DllExport WORD WINAPI SJIS2EUC(WORD KCode)
 {
 	return (SJIS2JIS(KCode) | 0x8080);
 }
 
 // Japanese JIS -> SJIS
-WORD PASCAL JIS2SJIS(WORD KCode)
+DllExport WORD WINAPI JIS2SJIS(WORD KCode)
 {
 	WORD n1, n2, SJIS;
 
@@ -182,7 +193,7 @@
 
 /* Russian charset conversion table by Andrey Nikiforov 19971114 */
 /* Updated by NAGATA Shinya 20111228 */
-static BYTE cpconv[4][4][128] =
+static const BYTE cpconv[4][4][128] =
 {
 #if 0
 // 1251 -> 1251 = dummy
@@ -589,7 +600,7 @@
 };
 
 // Russian character set conversion
-BYTE PASCAL RussConv(int cin, int cout, BYTE b)
+DllExport BYTE WINAPI RussConv(int cin, int cout, BYTE b)
 // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
 // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
 {
@@ -600,7 +611,7 @@
 }
 
 // Russian character set conversion for a character string
-void PASCAL RussConvStr(int cin, int cout, PCHAR Str, int count)
+DllExport void WINAPI RussConvStr(int cin, int cout, PCHAR Str, int count)
 // cin: input character set (IdWindows/IdKOI8/Id866/IdISO)
 // cin: output character set (IdWindows/IdKOI8/Id866/IdISO)
 {

Modified: branches/cmake/teraterm/ttpcmn/language.h
===================================================================
--- branches/cmake/teraterm/ttpcmn/language.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/language.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -31,18 +31,25 @@
 
 #pragma once
 
+#include <windows.h>	// for WINAPI
+#include "codemap.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#if !defined(DllExport)
+#define DllExport __declspec(dllimport)
+#endif
+
 /* proto types */
-unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, char *locale);
-WORD WINAPI SJIS2JIS(WORD KCode);
-WORD WINAPI SJIS2EUC(WORD KCode);
-WORD WINAPI JIS2SJIS(WORD KCode);
-BYTE WINAPI RussConv(int cin, int cout, BYTE b);
-void WINAPI RussConvStr
-  (int cin, int cout, PCHAR Str, int count);
+DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, char *locale);
+DllExport WORD WINAPI SJIS2JIS(WORD KCode);
+DllExport WORD WINAPI SJIS2EUC(WORD KCode);
+DllExport WORD WINAPI JIS2SJIS(WORD KCode);
+DllExport BYTE WINAPI RussConv(int cin, int cout, BYTE b);
+DllExport void WINAPI RussConvStr(int cin, int cout, PCHAR Str, int count);
+DllExport unsigned short WINAPI ConvertUnicode(unsigned short code, const codemap_t *table, int tmax);
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/ttpcmn/sjis2uni.map
===================================================================
--- branches/cmake/teraterm/ttpcmn/sjis2uni.map	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/sjis2uni.map	2018-08-26 14:44:23 UTC (rev 7190)
@@ -31,7 +31,7 @@
  * cf. ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT 
  *
  */
-static codemap_t mapSJISToUnicode[] = {
+static const codemap_t mapSJISToUnicode[] = {
 	{ 0x0020, 0x0020 },
 	{ 0x0021, 0x0021 },
 	{ 0x0022, 0x0022 },

Modified: branches/cmake/teraterm/ttpcmn/ttcmn.c
===================================================================
--- branches/cmake/teraterm/ttpcmn/ttcmn.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/ttcmn.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -41,11 +41,14 @@
 #include <locale.h>
 #include <htmlhelp.h>
 
+#define DllExport __declspec(dllexport) 
+#include "language.h"
+#undef DllExport
+
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttftypes.h"
 #include "ttlib.h"
-#include "language.h"
 #include "compat_w95.h"
 #include "tt_res.h"
 #include "ttcommon.h"

Deleted: branches/cmake/teraterm/ttpcmn/ttpcmn.def
===================================================================
--- branches/cmake/teraterm/ttpcmn/ttpcmn.def	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpcmn/ttpcmn.def	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,91 +0,0 @@
-EXPORTS
-  StartTeraTerm @1
-  ChangeDefaultSet @2
-  GetDefaultSet @3
-  GetKeyCode @4
-  GetKeyStr @5
-  SetCOMFlag @44
-  ClearCOMFlag @45
-  CheckCOMFlag @46
-  RegWin @10
-  UnregWin @11
-  SetWinMenu @12
-  SetWinList @13
-  SelectWin @14
-  SelectNextWin @15
-  GetNthWin @16
-  GetRegisteredWindowCount @89
-  ShowAllWin @54
-  CommReadRawByte @20
-  CommInsert1Byte @21
-  CommRead1Byte @22
-  CommRawOut @23
-  CommBinaryOut @24
-  CommBinaryBuffOut @52
-  CommTextOut @25
-  CommBinaryEcho @26
-  CommTextEcho @27
-  DetectComPorts @42
-  GetDefaultFName @47
-  ExtractFileName @48
-  replaceInvalidFileNameChar @74
-  b64encode @75
-  b64decode @76
-  CreateNotifyIcon @77
-  DeleteNotifyIcon @78
-  ShowNotifyIcon @80
-  HideNotifyIcon @81
-  SetVerNotifyIcon @82
-  NotifyMessage @79
-  SetCustomNotifyIcon @85
-  GetCustomNotifyIcon @86
-  
-  SJIS2JIS @30
-  SJIS2EUC @31
-  JIS2SJIS @32
-  RussConv @33
-  RussConvStr @34
-  ConvertUnicode @35
-  CopyTTSetToShmem @36
-  CopyShmemToTTSet @37
-  
-  GetI18nStr @40
-  GetI18nLogfont @41
-  
-  OutputDebugPrintf @49
-  
-  is_NT4 @50
-  doSelectFolder @51
-
-  mctimelocal @53
-  RestartTeraTerm @55
-  ShowAllWinSidebySide @56
-  ShowAllWinStacked @57
-  ShowAllWinCascade @58
-  BroadcastClosingMessage @59
-  UndoAllWin @60
-
-  OpenHelp @61
-
-  GetParam @62
-  DequoteParam @63
-
-  CheckComPort @64
-
-  IsWindows95 @65
-  IsWindowsMe @83
-  IsWindowsNT4 @66
-  IsWindows2000 @84
-  IsWindowsNTKernel @67
-  IsWindows2000OrLater @68
-  IsWindowsVistaOrLater @69
-  IsWindows7OrLater @70
-  HasMultiMonitorSupport @71
-  HasGetAdaptersAddresses @72
-  HasDnsQuery @73
-  HasBalloonTipSupport @87
-  GetDownloadFolder @88
-
-  parse_port @90
-  parse_port_from_buf @91
-  service_name @92

Modified: branches/cmake/teraterm/ttpdlg/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpdlg/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpdlg/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -21,25 +21,27 @@
   set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /i ${CMAKE_CURRENT_SOURCE_DIR}/../common")
 endif()
 
-if(MSVC)
-  set(SRC_DEF ttpdlg.def)
-else()
-  set(SRC_DEF ttpdlg_mingw.def)
-endif()
-  
-set(SRC
+set(COMMON_SRC
   ../common/dlglib.c
   ../common/dlglib.h
   ../common/ttlib.c
   ../common/ttlib.h
   ../common/teraterm.ico
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   dlg_res.h
   ttdlg.c
-  ttpdlg.def
   ttpdlg.rc
   ttpdlg-version.rc
   ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
-  ${SRC_DEF}
+  ${COMMON_SRC}
   )
 
 include_directories(

Modified: branches/cmake/teraterm/ttpdlg/ttdlg.c
===================================================================
--- branches/cmake/teraterm/ttpdlg/ttdlg.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpdlg/ttdlg.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -50,6 +50,9 @@
 #include "oniguruma.h"
 #undef ONIG_EXTERN
 
+#undef DllExport
+#define DllExport __declspec(dllexport) 
+
 static char * ProtocolFamilyList[] = { "UNSPEC", "IPv6", "IPv4", NULL };
 
 #undef EFFECT_ENABLED	// \x83G\x83t\x83F\x83N\x83g\x82̗L\x8C\xF8\x89”\xDB
@@ -70,7 +73,7 @@
 static HFONT DlgWinFont;
 static HFONT DlgWinlistFont;
 
-char UILanguageFile[MAX_PATH];
+static char UILanguageFile[MAX_PATH];
 
 static const TCHAR *NLListRcv[] = {"CR","CR+LF", "LF", "AUTO", NULL};
 static const TCHAR *NLList[] = {"CR","CR+LF", "LF", NULL};
@@ -109,7 +112,7 @@
 	 "230400", "460800", "921600", NULL};
 
 
-BOOL CALLBACK TermDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK TermDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
 	WORD w;
@@ -540,7 +543,7 @@
 	return FALSE;
 }
 
-void DispSample(HWND Dialog, PTTSet ts, int IAttr)
+static void DispSample(HWND Dialog, PTTSet ts, int IAttr)
 {
 	int i,x,y;
 	COLORREF Text, Back;
@@ -583,7 +586,7 @@
 	ReleaseDC(Dialog,DC);
 }
 
-void ChangeColor(HWND Dialog, PTTSet ts, int IAttr, int IOffset)
+static void ChangeColor(HWND Dialog, PTTSet ts, int IAttr, int IOffset)
 {
 	SetDlgItemInt(Dialog,IDC_WINRED,ts->TmpColor[IAttr][IOffset],FALSE);
 	SetDlgItemInt(Dialog,IDC_WINGREEN,ts->TmpColor[IAttr][IOffset+1],FALSE);
@@ -592,7 +595,7 @@
 	DispSample(Dialog,ts,IAttr);
 }
 
-void ChangeSB (HWND Dialog, PTTSet ts, int IAttr, int IOffset)
+static void ChangeSB (HWND Dialog, PTTSet ts, int IAttr, int IOffset)
 {
 	HWND HRed, HGreen, HBlue;
 
@@ -606,7 +609,7 @@
 	ChangeColor(Dialog,ts,IAttr,IOffset);
 }
 
-void RestoreVar(HWND Dialog, PTTSet ts, int *IAttr, int *IOffset)
+static void RestoreVar(HWND Dialog, PTTSet ts, int *IAttr, int *IOffset)
 {
 	WORD w;
 
@@ -626,7 +629,7 @@
 	}
 }
 
-BOOL CALLBACK WinDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK WinDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
 	HWND Wnd, HRed, HGreen, HBlue;
@@ -1234,7 +1237,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK KeybDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK KeybDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
 	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
@@ -1369,7 +1372,7 @@
 static const TCHAR *StopList[] = {"1 bit", "1.5 bit", "2 bit", NULL};
 static const TCHAR *FlowList[] = {"Xon/Xoff","hardware","none",NULL};
 
-BOOL CALLBACK SerialDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK SerialDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
 	int i, w, sel;
@@ -1577,7 +1580,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK TCPIPDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK TCPIPDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
 	char EntName[10];
@@ -1879,7 +1882,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK HostDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK HostDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PGetHNRec GetHNRec;
 	char EntName[128];
@@ -2153,7 +2156,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK DirDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK DirDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PCHAR CurDir;
 	char HomeDir[MAXPATHLEN];
@@ -2536,7 +2539,7 @@
 }
 
 
-BOOL CALLBACK AboutDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK AboutDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	char buf[128], tmpbuf[128];
 	HDC hdc;
@@ -3002,7 +3005,7 @@
 	return (n + 1);  // 1origin
 }
 
-BOOL CALLBACK GenDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK GenDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	static int langui_sel = 1, uilist_count = 0;
 	PTTSet ts;
@@ -3164,7 +3167,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK WinListDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK WinListDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PBOOL Close;
 	int n;
@@ -3280,7 +3283,7 @@
 	return FALSE;
 }
 
-BOOL PASCAL SetupTerminal(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupTerminal(HWND WndParent, PTTSet ts)
 {
 	int i;
 
@@ -3305,7 +3308,7 @@
 		                     WndParent, TermDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL SetupWin(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupWin(HWND WndParent, PTTSet ts)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3313,7 +3316,7 @@
 		                     WndParent, WinDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL SetupKeyboard(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupKeyboard(HWND WndParent, PTTSet ts)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3321,7 +3324,7 @@
 		                     WndParent, KeybDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL SetupSerialPort(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupSerialPort(HWND WndParent, PTTSet ts)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3329,7 +3332,7 @@
 		                     WndParent, SerialDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL SetupTCPIP(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupTCPIP(HWND WndParent, PTTSet ts)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3337,7 +3340,7 @@
 		                     WndParent, TCPIPDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL GetHostName(HWND WndParent, PGetHNRec GetHNRec)
+DllExport BOOL WINAPI GetHostName(HWND WndParent, PGetHNRec GetHNRec)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3345,7 +3348,7 @@
 		                     WndParent, HostDlg, (LPARAM)GetHNRec);
 }
 
-BOOL PASCAL ChangeDirectory(HWND WndParent, PCHAR CurDir)
+DllExport BOOL WINAPI ChangeDirectory(HWND WndParent, PCHAR CurDir)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3353,7 +3356,7 @@
 		                     WndParent, DirDlg, (LPARAM)CurDir);
 }
 
-BOOL PASCAL AboutDialog(HWND WndParent)
+DllExport BOOL WINAPI AboutDialog(HWND WndParent)
 {
 	return
 		(BOOL)DialogBox(hInst,
@@ -3406,7 +3409,7 @@
 #ifndef CF_INACTIVEFONTS
 #define CF_INACTIVEFONTS 0x02000000L
 #endif
-BOOL PASCAL ChooseFontDlg(HWND WndParent, LPLOGFONT LogFont, PTTSet ts)
+DllExport BOOL WINAPI ChooseFontDlg(HWND WndParent, LPLOGFONT LogFont, PTTSet ts)
 {
 	CHOOSEFONT cf;
 	BOOL Ok;
@@ -3429,7 +3432,7 @@
 	return Ok;
 }
 
-BOOL PASCAL SetupGeneral(HWND WndParent, PTTSet ts)
+DllExport BOOL WINAPI SetupGeneral(HWND WndParent, PTTSet ts)
 {
 	return
 		(BOOL)DialogBoxParam(hInst,
@@ -3437,7 +3440,7 @@
 		                     WndParent, (DLGPROC)&GenDlg, (LPARAM)ts);
 }
 
-BOOL PASCAL WindowWindow(HWND WndParent, PBOOL Close)
+DllExport BOOL WINAPI WindowWindow(HWND WndParent, PBOOL Close)
 {
 	*Close = FALSE;
 	return
@@ -3447,7 +3450,7 @@
 		                     (DLGPROC)&WinListDlg, (LPARAM)Close);
 }
 
-void PASCAL TTDLGSetUILanguageFile(char *file)
+DllExport void WINAPI TTDLGSetUILanguageFile(char *file)
 {
 	strncpy_s(UILanguageFile, sizeof(UILanguageFile), file, _TRUNCATE);
 }

Deleted: branches/cmake/teraterm/ttpdlg/ttpdlg.def
===================================================================
--- branches/cmake/teraterm/ttpdlg/ttpdlg.def	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpdlg/ttpdlg.def	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,14 +0,0 @@
-EXPORTS
-  SetupTerminal @1
-  SetupWin @2
-  SetupKeyboard @3
-  SetupSerialPort @4
-  SetupTCPIP @5
-  GetHostName @6
-  ChangeDirectory @7
-  AboutDialog @8
-  ChooseFontDlg @9
-  SetupGeneral @10
-  WindowWindow @11
-
-  TTDLGSetUILanguageFile @12

Modified: branches/cmake/teraterm/ttpfile/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -13,11 +13,20 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
   ../common/dlglib.c
   ../common/dlglib.h
   ../common/ttlib.c
   ../common/ttlib.h
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   bplus.c
   bplus.h
   ftlib.c
@@ -36,7 +45,7 @@
   file_res.h
   ttpfile-version.rc
   ttpfile.rc
-  ttpfile.def
+  ${COMMON_SRC}
   )
 
 include_directories(

Modified: branches/cmake/teraterm/ttpfile/ttfile.c
===================================================================
--- branches/cmake/teraterm/ttpfile/ttfile.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpfile/ttfile.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -53,6 +53,9 @@
 
 #include "compat_w95.h"
 
+#undef DllExport
+#define DllExport __declspec(dllexport) 
+
 static HANDLE hInst;
 
 static HFONT DlgFoptFont;
@@ -62,7 +65,7 @@
 char UILanguageFile[MAX_PATH];
 char FileSendFilter[128];
 
-BOOL PASCAL GetSetupFname(HWND HWin, WORD FuncId, PTTSet ts)
+DllExport BOOL WINAPI GetSetupFname(HWND HWin, WORD FuncId, PTTSet ts)
 {
 	int i, j;
 	OPENFILENAME ofn;
@@ -421,8 +424,7 @@
 
 BOOL CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam);
 
-BOOL PASCAL GetTransFname
-  (PFileVar fv, PCHAR CurDir, WORD FuncId, LPLONG Option)
+DllExport BOOL WINAPI GetTransFname(PFileVar fv, PCHAR CurDir, WORD FuncId, LPLONG Option)
 {
 	char uimsg[MAX_UIMSG];
 	char FNFilter[sizeof(FileSendFilter)*3], *pf;
@@ -638,8 +640,7 @@
 	return FALSE;
 }
 
-BOOL PASCAL GetMultiFname
-  (PFileVar fv, PCHAR CurDir, WORD FuncId, LPWORD Option)
+DllExport BOOL WINAPI GetMultiFname(PFileVar fv, PCHAR CurDir, WORD FuncId, LPWORD Option)
 {
 	int i, len;
 	char uimsg[MAX_UIMSG];
@@ -867,7 +868,7 @@
 	return FALSE;
 }
 
-BOOL PASCAL GetGetFname(HWND HWin, PFileVar fv)
+DllExport BOOL WINAPI GetGetFname(HWND HWin, PFileVar fv)
 {
 	return (BOOL)DialogBoxParam(hInst,
 	                            MAKEINTRESOURCE(IDD_GETFNDLG),
@@ -874,7 +875,7 @@
 	                            HWin, GetFnDlg, (LONG)fv);
 }
 
-void PASCAL SetFileVar(PFileVar fv)
+DllExport void WINAPI SetFileVar(PFileVar fv)
 {
 	int i;
 	char uimsg[MAX_UIMSG];
@@ -1086,8 +1087,7 @@
 	return FALSE;
 }
 
-BOOL PASCAL GetXFname
-  (HWND HWin, BOOL Receive, LPLONG Option, PFileVar fv, PCHAR CurDir)
+DllExport BOOL WINAPI GetXFname(HWND HWin, BOOL Receive, LPLONG Option, PFileVar fv, PCHAR CurDir)
 {
 	char uimsg[MAX_UIMSG];
 	char FNFilter[sizeof(FileSendFilter)*2+128], *pf;
@@ -1182,7 +1182,7 @@
 	return Ok;
 }
 
-void PASCAL ProtoInit(int Proto, PFileVar fv, PCHAR pv, PComVar cv, PTTSet ts)
+DllExport void WINAPI ProtoInit(int Proto, PFileVar fv, PCHAR pv, PComVar cv, PTTSet ts)
 {
 	switch (Proto) {
 	case PROTO_KMT:
@@ -1206,8 +1206,7 @@
 	}
 }
 
-BOOL PASCAL ProtoParse
-  (int Proto, PFileVar fv, PCHAR pv, PComVar cv)
+DllExport BOOL WINAPI ProtoParse(int Proto, PFileVar fv, PCHAR pv, PComVar cv)
 {
 	BOOL Ok;
 
@@ -1256,8 +1255,7 @@
 	return Ok;
 }
 
-void PASCAL ProtoTimeOutProc
-  (int Proto, PFileVar fv, PCHAR pv, PComVar cv)
+DllExport void WINAPI ProtoTimeOutProc(int Proto, PFileVar fv, PCHAR pv, PComVar cv)
 {
 	switch (Proto) {
 	case PROTO_KMT:
@@ -1281,8 +1279,7 @@
 	}
 }
 
-BOOL PASCAL ProtoCancel
-  (int Proto, PFileVar fv, PCHAR pv, PComVar cv)
+DllExport BOOL WINAPI ProtoCancel(int Proto, PFileVar fv, PCHAR pv, PComVar cv)
 {
 	switch (Proto) {
 	case PROTO_KMT:
@@ -1310,12 +1307,12 @@
 	return TRUE;
 }
 
-void PASCAL TTFILESetUILanguageFile(char *file)
+DllExport void WINAPI TTFILESetUILanguageFile(char *file)
 {
 	strncpy_s(UILanguageFile, sizeof(UILanguageFile), file, _TRUNCATE);
 }
 
-void PASCAL TTFILESetFileSendFilter(char *file)
+DllExport void WINAPI TTFILESetFileSendFilter(char *file)
 {
 	strncpy_s(FileSendFilter, sizeof(FileSendFilter), file, _TRUNCATE);
 }

Deleted: branches/cmake/teraterm/ttpfile/ttpfile.def
===================================================================
--- branches/cmake/teraterm/ttpfile/ttpfile.def	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpfile/ttpfile.def	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,15 +0,0 @@
-EXPORTS
-  GetSetupFname @1
-  GetTransFname @2
-  GetMultiFname @3
-  GetGetFname @4
-  SetFileVar @5
-  GetXFname @6
-
-  ProtoInit @7
-  ProtoParse @8
-  ProtoTimeOutProc @9
-  ProtoCancel @10
-
-  TTFILESetUILanguageFile @11
-  TTFILESetFileSendFilter @12

Modified: branches/cmake/teraterm/ttpmacro/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -16,12 +16,20 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
   ../common/i18n.c
   ../common/i18n.h
   ../common/ttlib.c
   ../common/ttlib.h
-  #
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   errdlg.cpp
   errdlg.h
   inpdlg.cpp
@@ -57,9 +65,9 @@
   ttmparse.h
   wait4all.c
   wait4all.h
-
   ttpmacro.rc
   ttm-version.rc
+  ${COMMON_SRC}
   )
 
 include_directories(

Modified: branches/cmake/teraterm/ttpmacro/ttmenc.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmenc.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpmacro/ttmenc.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -33,7 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-BOOL EncSeparate(PCHAR Str, int far *i, LPBYTE b)
+BOOL EncSeparate(PCHAR Str, int *i, LPBYTE b)
 {
 	int cptr, bptr;
 	unsigned int d;

Modified: branches/cmake/teraterm/ttpmacro/ttmparse.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmparse.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpmacro/ttmparse.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -812,7 +812,7 @@
 	return TRUE;
 }
 
-BOOL GetNumber(int far *Num)
+BOOL GetNumber(int *Num)
 {
 	BYTE b;
 
@@ -981,7 +981,7 @@
 		LabVarCount--;
 }
 
-void CopyLabel(WORD ILabel, BINT far *Ptr, LPWORD Level)
+void CopyLabel(WORD ILabel, BINT *Ptr, LPWORD Level)
 {
 	*Ptr = LabVal[ILabel];
 	*Level = (WORD)LabLevel[ILabel];
@@ -995,7 +995,7 @@
  *   Evaluate following operator.
  *     not, ~, !, +(unary), -(unary)
  */
-BOOL GetFactor(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL GetFactor(LPWORD ValType, int *Val, LPWORD Err)
 {
 	TName Name;
 	WORD P, WId;
@@ -1094,7 +1094,7 @@
  *   Evaluate following operator.
  *     *, /, %
  */
-BOOL EvalMultiplication(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalMultiplication(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1155,7 +1155,7 @@
  *   Evaluate following operator.
  *     +, -
  */
-BOOL EvalAddition(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalAddition(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1209,7 +1209,7 @@
  *   Evaluate following operator.
  *     >>, <<, >>>
  */
-BOOL EvalBitShift(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalBitShift(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1283,7 +1283,7 @@
  *   Evaluate following operator.
  *     &
  */
-BOOL EvalBitAnd(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalBitAnd(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1330,7 +1330,7 @@
  *   Evaluate following operator.
  *     ^
  */
-BOOL EvalBitXor(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalBitXor(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1377,7 +1377,7 @@
  *   Evaluate following operator.
  *     |
  */
-BOOL EvalBitOr(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalBitOr(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1424,7 +1424,7 @@
  *   Evaluate following operator.
  *     <, >, <=, >=
  */
-BOOL EvalGreater(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalGreater(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1482,7 +1482,7 @@
  *   Evaluate following operator.
  *     =, ==, <>, !=
  */
-BOOL EvalEqual(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalEqual(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1536,7 +1536,7 @@
  *   Evaluate following operator.
  *     &&
  */
-BOOL EvalLogicalAnd(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL EvalLogicalAnd(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P, Type, Er;
 	int Val1, Val2;
@@ -1583,7 +1583,7 @@
  *   Evaluate following operator.
  *     ||
  */
-BOOL GetExpression(LPWORD ValType, int far *Val, LPWORD Err)
+BOOL GetExpression(LPWORD ValType, int *Val, LPWORD Err)
 {
 	WORD P1, P2, Type, Er;
 	int Val1, Val2;
@@ -1638,7 +1638,7 @@
 	}
 }
 
-void GetIntVal(int far *Val, LPWORD Err)
+void GetIntVal(int *Val, LPWORD Err)
 {
 	WORD ValType;
 
@@ -1801,7 +1801,7 @@
 }
 
 // for ifdefined (2006.9.23 maya)
-void GetVarType(LPWORD ValType, int far *Val, LPWORD Err)
+void GetVarType(LPWORD ValType, int *Val, LPWORD Err)
 {
 	TName Name;
 	WORD WId;

Modified: branches/cmake/teraterm/ttpmacro/ttmparse.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmparse.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpmacro/ttmparse.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -305,12 +305,12 @@
 typedef DWORD BINT;
 
 typedef char TName[MaxNameLen];
-typedef TName far *PName;
+typedef TName *PName;
 typedef char TStrVal [MaxStrLen];
-typedef TStrVal far *PStrVal;
+typedef TStrVal *PStrVal;
 
 typedef DWORD TVarId;
-typedef TVarId far *PVarId;
+typedef TVarId *PVarId;
 
 #ifdef __cplusplus
 extern "C" {
@@ -336,9 +336,9 @@
 int NewIntAryVar(PCHAR Name, int size);
 int NewStrAryVar(PCHAR Name, int size);
 void DelLabVar(WORD ILevel);
-void CopyLabel(WORD ILabel, BINT far *Ptr, LPWORD Level);
-BOOL GetExpression(LPWORD ValType, int far *Val, LPWORD Err);
-void GetIntVal(int far *Val, LPWORD Err);
+void CopyLabel(WORD ILabel, BINT *Ptr, LPWORD Level);
+BOOL GetExpression(LPWORD ValType, int *Val, LPWORD Err);
+void GetIntVal(int *Val, LPWORD Err);
 void SetIntVal(TVarId VarId, int Val);
 int CopyIntVal(TVarId VarId);
 void GetIntVar(PVarId VarId, LPWORD Err);
@@ -347,7 +347,7 @@
 void GetStrVar(PVarId VarId, LPWORD Err);
 void SetStrVal(TVarId VarId, PCHAR Str);
 PCHAR StrVarPtr(TVarId VarId);
-void GetVarType(LPWORD ValType, int far *Val, LPWORD Err);
+void GetVarType(LPWORD ValType, int *Val, LPWORD Err);
 TVarId GetIntVarFromArray(TVarId VarId, int Index, LPWORD Err);
 TVarId GetStrVarFromArray(TVarId VarId, int Index, LPWORD Err);
 BOOL GetIndex(int *Index, LPWORD Err);

Modified: branches/cmake/teraterm/ttpset/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -13,12 +13,22 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
+  ../common/tttypes.h
   ../common/ttlib.c
   ../common/ttlib.h
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   ttset.c
   ttpset-version.rc
-  ttpset.def
+  ${COMMON_SRC}
   )
 
 include_directories(

Deleted: branches/cmake/teraterm/ttpset/ttpset.def
===================================================================
--- branches/cmake/teraterm/ttpset/ttpset.def	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpset/ttpset.def	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,9 +0,0 @@
-EXPORTS
-  ReadIniFile @1
-  WriteIniFile @2
-  ReadKeyboardCnf @3
-  CopyHostList @4
-  AddHostToList @5
-  ParseParam @6
-  CopySerialList @7
-  AddValueToList @8

Modified: branches/cmake/teraterm/ttpset/ttset.c
===================================================================
--- branches/cmake/teraterm/ttpset/ttset.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttpset/ttset.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -48,19 +48,22 @@
 #define CLEARTYPE_QUALITY 5
 #endif
 
+#undef DllExport
+#define DllExport __declspec(dllexport) 
+
 #define Section "Tera Term"
 
 #define MaxStrLen (LONG)512
 
-static PCHAR far TermList[] =
+static const char *TermList[] =
 	{ "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
 	"VT320", "VT382", "VT420", "VT520", "VT525", NULL };
 
-static PCHAR far RussList[] =
+static const char *RussList[] =
 	{ "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
-static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
+static const char *RussList2[] = { "Windows", "KOI8-R", NULL };
 
-WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
+static WORD str2id(const char *List[], PCHAR str, WORD DefId)
 {
 	WORD i;
 	i = 0;
@@ -74,7 +77,7 @@
 	return i;
 }
 
-void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
+static void id2str(const char *List[], WORD Id, WORD DefId, PCHAR str, int destlen)
 {
 	int i;
 
@@ -90,7 +93,7 @@
 	strncpy_s(str, destlen, List[i], _TRUNCATE);
 }
 
-int IconName2IconId(const char *name) {
+static int IconName2IconId(const char *name) {
 	int id;
 
 	if (_stricmp(name, "tterm") == 0) {
@@ -123,7 +126,7 @@
 	return id;
 }
 
-void IconId2IconName(char *name, int len, int id) {
+static void IconId2IconName(char *name, int len, int id) {
 	char *icon;
 	switch (id) {
 		case IDI_TTERM:
@@ -519,7 +522,7 @@
 
 }
 
-void PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
+DllExport void WINAPI ReadIniFile(PCHAR FName, PTTSet ts)
 {
 	int i;
 	HDC TmpDC;
@@ -585,13 +588,13 @@
 
 	/* VT win position */
 	GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);	/* default: random position */
-	GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
-	GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
+	GetNthNum(Temp, 1, (int*) (&ts->VTPos.x));
+	GetNthNum(Temp, 2, (int*) (&ts->VTPos.y));
 
 	/* TEK win position */
 	GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);	/* default: random position */
-	GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
-	GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
+	GetNthNum(Temp, 1, (int*) &(ts->TEKPos.x));
+	GetNthNum(Temp, 2, (int*) &(ts->TEKPos.y));
 
 	/* Save VT Window position */
 	ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
@@ -791,7 +794,7 @@
 	GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                     (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -801,7 +804,7 @@
 	GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                         (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -813,7 +816,7 @@
 	GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                          (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -825,7 +828,7 @@
 	GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                          (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -840,7 +843,7 @@
 	GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                      (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -855,7 +858,7 @@
 	GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
 	                        Temp, sizeof(Temp), FName);
 	for (i = 0; i <= 5; i++)
-		GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
+		GetNthNum(Temp, i + 1, (int*) &(ts->TmpColor[0][i]));
 	for (i = 0; i <= 1; i++)
 		ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
 		                      (BYTE) ts->TmpColor[0][i * 3 + 1],
@@ -893,10 +896,10 @@
 		n /= 4;
 		for (i = 0; i < n; i++) {
 			int colorid, r, g, b;
-			GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
-			GetNthNum(Temp, i * 4 + 2, (int far *) &r);
-			GetNthNum(Temp, i * 4 + 3, (int far *) &g);
-			GetNthNum(Temp, i * 4 + 4, (int far *) &b);
+			GetNthNum(Temp, i * 4 + 1, (int*) &colorid);
+			GetNthNum(Temp, i * 4 + 2, (int*) &r);
+			GetNthNum(Temp, i * 4 + 3, (int*) &g);
+			GetNthNum(Temp, i * 4 + 4, (int*) &b);
 			ts->ANSIColor[colorid & 15] =
 				RGB((BYTE) r, (BYTE) g, (BYTE) b);
 		}
@@ -928,8 +931,8 @@
 	GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
 	                        Temp, sizeof(Temp), FName);
 	GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
-	GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
-	GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
+	GetNthNum(Temp, 2, (int*) &(ts->VTFontSize.x));
+	GetNthNum(Temp, 3, (int*) &(ts->VTFontSize.y));
 	GetNthNum(Temp, 4, &(ts->VTFontCharSet));
 
 	/* Bold font flag */
@@ -945,8 +948,8 @@
 	GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
 	                        Temp, sizeof(Temp), FName);
 	GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
-	GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
-	GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
+	GetNthNum(Temp, 2, (int*) &(ts->TEKFontSize.x));
+	GetNthNum(Temp, 3, (int*) &(ts->TEKFontSize.y));
 	GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
 
 	/* BS key */
@@ -1342,8 +1345,8 @@
 	}
 	else {
 		GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
-		GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
-		GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
+		GetNthNum(Temp, 2, (int*) &(ts->PrnFontSize.x));
+		GetNthNum(Temp, 3, (int*) &(ts->PrnFontSize.y));
 		GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
 	}
 
@@ -1465,14 +1468,14 @@
 	// VT-print scaling factors (pixels per inch) --- special option
 	GetPrivateProfileString(Section, "VTPPI", "0,0",
 	                        Temp, sizeof(Temp), FName);
-	GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
-	GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
+	GetNthNum(Temp, 1, (int*) &ts->VTPPI.x);
+	GetNthNum(Temp, 2, (int*) &ts->VTPPI.y);
 
 	// TEK-print scaling factors (pixels per inch) --- special option
 	GetPrivateProfileString(Section, "TEKPPI", "0,0",
 	                        Temp, sizeof(Temp), FName);
-	GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
-	GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
+	GetNthNum(Temp, 1, (int*) &ts->TEKPPI.x);
+	GetNthNum(Temp, 2, (int*) &ts->TEKPPI.y);
 
 	// Show "Window" menu -- special option
 	if (GetOnOff(Section, "WindowMenu", FName, TRUE))
@@ -2066,7 +2069,7 @@
 	ReadCygtermConfFile(ts);
 }
 
-void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
+DllExport void WINAPI WriteIniFile(PCHAR FName, PTTSet ts)
 {
 	int i;
 	char Temp[MAX_PATH];
@@ -3429,8 +3432,8 @@
 	KeyMap->Map[KeyId - 1] = Num;
 }
 
-void PASCAL ReadKeyboardCnf
-	(PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning) {
+DllExport void WINAPI ReadKeyboardCnf(PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning)
+{
 	int i, j, Ptr;
 	char EntName[7];
 	char TempStr[221];
@@ -3682,8 +3685,9 @@
 				}
 }
 
-void PASCAL CopySerialList(PCHAR IniSrc, PCHAR IniDest, PCHAR section,
-                               PCHAR key, int MaxList)
+DllExport void WINAPI CopySerialList(
+	PCHAR IniSrc, PCHAR IniDest, PCHAR section,
+	PCHAR key, int MaxList)
 {
 	int i, j;
 	char EntName[10], EntName2[10];
@@ -3715,8 +3719,9 @@
 	WritePrivateProfileString(NULL, NULL, NULL, IniDest);
 }
 
-void PASCAL AddValueToList(PCHAR FName, PCHAR Host, PCHAR section,
-                               PCHAR key, int MaxList)
+DllExport void WINAPI AddValueToList(
+	PCHAR FName, PCHAR Host, PCHAR section,
+	PCHAR key, int MaxList)
 {
 	HANDLE MemH;
 	PCHAR MemP;
@@ -3776,12 +3781,12 @@
 }
 
  /* copy hostlist from source IniFile to dest IniFile */
-void PASCAL CopyHostList(PCHAR IniSrc, PCHAR IniDest)
+DllExport void WINAPI CopyHostList(PCHAR IniSrc, PCHAR IniDest)
 {
 	CopySerialList(IniSrc, IniDest, "Hosts", "Host", MAXHOSTLIST);
 }
 
-void PASCAL AddHostToList(PCHAR FName, PCHAR Host)
+DllExport void WINAPI AddHostToList(PCHAR FName, PCHAR Host)
 {
 	AddValueToList(FName, Host, "Hosts", "Host", MAXHOSTLIST);
 }
@@ -3921,7 +3926,7 @@
 }
 
 
-void PASCAL ParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic)
+DllExport void WINAPI ParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic)
 {
 	int i, pos, c;
 	//int param_top;
@@ -4253,7 +4258,7 @@
 }
 
 BOOL WINAPI DllMain(HANDLE hInst,
-                    ULONG ul_reason_for_call, LPVOID lpReserved)
+					ULONG ul_reason_for_call, LPVOID lpReserved)
 {
 	switch (ul_reason_for_call) {
 	case DLL_THREAD_ATTACH:

Modified: branches/cmake/teraterm/ttptek/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttptek/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttptek/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -16,19 +16,29 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(SRC
+set(COMMON_SRC
+  ../common/tttypes.h
   ../common/i18n.c
   ../common/i18n.h
   ../common/ttlib.c
   ../common/ttlib.h
-  #
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
+set(SRC
   tek_res.h
   tekesc.c
   tekesc.h
-  ttptek.def
   ttptek.rc
   ttptek-version.rc
+  tttek.h
   tttek.c
+  ${COMMON_SRC}
   )
 
 include_directories(

Modified: branches/cmake/teraterm/ttptek/tekesc.c
===================================================================
--- branches/cmake/teraterm/ttptek/tekesc.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttptek/tekesc.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -35,7 +35,11 @@
 #include <math.h>
 #include <string.h>
 
+#undef DllExport
+#define DllExport __declspec(dllexport) 
+
 #include "tekesc.h"
+#include "tttek.h"
 
 void Log1Byte(PComVar cv, BYTE b)
 {

Modified: branches/cmake/teraterm/ttptek/tekesc.h
===================================================================
--- branches/cmake/teraterm/ttptek/tekesc.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttptek/tekesc.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -29,7 +29,6 @@
 
 /* TTTEK.DLL, TEK escape sequences */
 
-void PASCAL TEKChangeCaret(PTEKVar tk, PTTSet ts);
 void ParseFirst(PTEKVar tk, PTTSet ts, PComVar cv, BYTE b);
 void TEKEscape(PTEKVar tk, PTTSet ts, PComVar cv, BYTE b);
 void SelectCode(PTEKVar tk, PTTSet ts, BYTE b);

Deleted: branches/cmake/teraterm/ttptek/ttptek.def
===================================================================
--- branches/cmake/teraterm/ttptek/ttptek.def	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttptek/ttptek.def	2018-08-26 14:44:23 UTC (rev 7190)
@@ -1,22 +0,0 @@
-EXPORTS
-  TEKInit @1
-  TEKResizeWindow @2
-  TEKChangeCaret @3
-  TEKDestroyCaret @4
-  TEKParse @5
-  TEKReportGIN @6
-  TEKPaint @7
-  TEKWMLButtonDown @8
-  TEKWMLButtonUp @9
-  TEKWMMouseMove @10
-  TEKWMSize @11
-  TEKCMCopy @12
-  TEKCMCopyScreen @13
-
-  TEKPrint @14
-  TEKClearScreen @15
-  TEKSetupFont @16
-  TEKResetWin @17
-  TEKRestoreSetup @18
-  TEKEnd @19
-

Modified: branches/cmake/teraterm/ttptek/tttek.c
===================================================================
--- branches/cmake/teraterm/ttptek/tttek.c	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/teraterm/ttptek/tttek.c	2018-08-26 14:44:23 UTC (rev 7190)
@@ -36,13 +36,18 @@
 #include <string.h>
 
 #include "ttcommon.h"
-#include "tekesc.h"
 
 #include "compat_w95.h"
 
+#undef DllExport
+#define DllExport __declspec(dllexport) 
+
+#include "tekesc.h"
+#include "tttek.h"
+
 static HANDLE hInst;
 
-void PASCAL TEKInit(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKInit(PTEKVar tk, PTTSet ts)
 {
   int i;
 
@@ -176,7 +181,7 @@
   tk->RubberBand = OnFlag;
 }
 
-void PASCAL TEKChangeCaret(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKChangeCaret(PTEKVar tk, PTTSet ts)
 {
   UINT T;
 
@@ -200,7 +205,7 @@
   }
 }
 
-void PASCAL TEKDestroyCaret(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKDestroyCaret(PTEKVar tk, PTTSet ts)
 {
   DestroyCaret();
   if (ts->NonblinkingCursor!=0)
@@ -207,7 +212,7 @@
 	KillTimer(tk->HWin,IdCaretTimer);
 }
 
-void PASCAL TEKResizeWindow(PTEKVar tk, PTTSet ts, int W, int H)
+DllExport void WINAPI TEKResizeWindow(PTEKVar tk, PTTSet ts, int W, int H)
 {
   int i, Height, Width;
   TEXTMETRIC Metrics;
@@ -402,7 +407,7 @@
   tk->ScaleFont = FALSE;
 }
 
-int PASCAL TEKParse(PTEKVar tk, PTTSet ts, PComVar cv)
+DllExport int WINAPI TEKParse(PTEKVar tk, PTTSet ts, PComVar cv)
 {
   BOOL f;
   int c;
@@ -468,7 +473,7 @@
   return (tk->ChangeEmu);
 }
 
-void PASCAL TEKReportGIN(PTEKVar tk, PTTSet ts, PComVar cv, BYTE KeyCode)
+DllExport void WINAPI TEKReportGIN(PTEKVar tk, PTTSet ts, PComVar cv, BYTE KeyCode)
 {
   BYTE Code[11];
   int X, Y;
@@ -490,8 +495,7 @@
   tk->IgnoreCount = 6;
 }
 
-void PASCAL TEKPaint
-  (PTEKVar tk, PTTSet ts, HDC PaintDC, PAINTSTRUCT *PaintInfo)
+DllExport void WINAPI TEKPaint(PTEKVar tk, PTTSet ts, HDC PaintDC, PAINTSTRUCT *PaintInfo)
 {
   int X,Y,W,H;
 
@@ -511,8 +515,7 @@
   if (tk->GIN) ToggleCrossHair(tk,ts,TRUE);
 }
 
-void PASCAL TEKWMLButtonDown
-  (PTEKVar tk, PTTSet ts, PComVar cv, POINT pos)
+DllExport void WINAPI TEKWMLButtonDown(PTEKVar tk, PTTSet ts, PComVar cv, POINT pos)
 {
   BYTE b;
 
@@ -542,7 +545,7 @@
   }
 }
 
-void PASCAL TEKWMLButtonUp(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKWMLButtonUp(PTEKVar tk, PTTSet ts)
 {
   int X;
 
@@ -571,7 +574,7 @@
   }
 }
 
-void PASCAL TEKWMMouseMove(PTEKVar tk, PTTSet ts, POINT p)
+DllExport void WINAPI TEKWMMouseMove(PTEKVar tk, PTTSet ts, POINT p)
 {
   int X, Y;
 
@@ -603,7 +606,7 @@
   if (tk->GIN) SetCapture(tk->HWin);
 }
 
-void PASCAL TEKWMSize(PTEKVar tk, PTTSet ts, int W, int H, int cx, int cy)
+DllExport void WINAPI TEKWMSize(PTEKVar tk, PTTSet ts, int W, int H, int cx, int cy)
 {
   int Width, Height;
 
@@ -661,7 +664,7 @@
   SwitchRubberBand(tk,ts,tk->Select);
 }
 
-void PASCAL TEKCMCopy(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKCMCopy(PTEKVar tk, PTTSet ts)
 {
   int x, y;
 
@@ -679,13 +682,13 @@
     abs(tk->SelectEnd.y - tk->SelectStart.y));                          
 }
 
-void PASCAL TEKCMCopyScreen(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKCMCopyScreen(PTEKVar tk, PTTSet ts)
 {
   /* copy fullscreen to clipboard */
   CopyToClipboard(tk, ts, 0, 0, tk->ScreenWidth, tk->ScreenHeight);
 }
 
-void PASCAL TEKPrint(PTEKVar tk, PTTSet ts, HDC PrintDC, BOOL SelFlag)
+DllExport void WINAPI TEKPrint(PTEKVar tk, PTTSet ts, HDC PrintDC, BOOL SelFlag)
 {
   POINT PPI;
   RECT Margin;
@@ -764,7 +767,7 @@
   SwitchRubberBand(tk,ts,tk->Select);
 }
 
-void PASCAL TEKClearScreen(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKClearScreen(PTEKVar tk, PTTSet ts)
 {
   RECT R;
 
@@ -778,7 +781,7 @@
   TEKCaretOn(tk,ts);
 }
 
-void PASCAL TEKSetupFont(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKSetupFont(PTEKVar tk, PTTSet ts)
 {
   int W, H;
 //  BOOL Ok;
@@ -801,7 +804,7 @@
   TEKResizeWindow(tk,ts,W,H);
 }
 
-void PASCAL TEKResetWin(PTEKVar tk, PTTSet ts, WORD EmuOld)
+DllExport void WINAPI TEKResetWin(PTEKVar tk, PTTSet ts, WORD EmuOld)
 {
   HDC TmpDC;
   RECT R;
@@ -869,7 +872,7 @@
   InvalidateRect(tk->HWin,NULL,TRUE);
 }
 
-/* BOOL PASCAL TEKSetupWinDlg(PTEKVar tk, PTTSet ts)
+/* DllExport BOOL WINAPI TEKSetupWinDlg(PTEKVar tk, PTTSet ts)
 {
   BOOL Ok;
   WORD OldEmu;
@@ -886,7 +889,7 @@
   return Ok;
 } */
 
-void PASCAL TEKRestoreSetup(PTEKVar tk, PTTSet ts)
+DllExport void WINAPI TEKRestoreSetup(PTEKVar tk, PTTSet ts)
 {
   int W, H;
   RECT R;
@@ -904,7 +907,7 @@
   TEKResizeWindow(tk,ts,W,H);
 }
 
-void PASCAL TEKEnd(PTEKVar tk)
+DllExport void WINAPI TEKEnd(PTEKVar tk)
 {
   int i;
 

Modified: branches/cmake/ttssh2/ttxssh/CMakeLists.txt
===================================================================
--- branches/cmake/ttssh2/ttxssh/CMakeLists.txt	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/ttssh2/ttxssh/CMakeLists.txt	2018-08-26 14:44:23 UTC (rev 7190)
@@ -5,9 +5,21 @@
 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_zlib.cmake)
 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_openssl.cmake)
 
+set(COMMON_SRC
+  ../../teraterm/teraterm/WSAAsyncGetAddrInfo.c
+  ../../teraterm/common/ttcommon.h
+  ../../teraterm/common/i18n.h
+  ../../teraterm/common/ttlib.h
+  )
+
+source_group(
+  "common"
+  FILES
+  ${COMMON_SRC}
+  )
+
 set(SRC
   ${CMAKE_CURRENT_BINARY_DIR}/puttyversion.h
-  ../../teraterm/teraterm/WSAAsyncGetAddrInfo.c
   ../matcher/matcher.c
   arc4random.c
   arc4random.h
@@ -69,6 +81,7 @@
   util.h
   x11util.c
   x11util.h
+  ${COMMON_SRC}
   )
 
 
@@ -90,6 +103,11 @@
   ${SRC}
   )
 
+target_compile_definitions(
+  ttxssh
+  PRIVATE -DTTPCMN_IMPORT
+  )
+
 target_link_libraries(
   ttxssh
   libputty

Modified: branches/cmake/ttssh2/ttxssh/util.h
===================================================================
--- branches/cmake/ttssh2/ttxssh/util.h	2018-08-24 05:03:26 UTC (rev 7189)
+++ branches/cmake/ttssh2/ttxssh/util.h	2018-08-26 14:44:23 UTC (rev 7190)
@@ -87,6 +87,4 @@
 void UTIL_get_lang_msg(PCHAR key, PTInstVar pvar, PCHAR def);
 int UTIL_get_lang_font(PCHAR key, HWND dlg, PLOGFONT logfont, HFONT *font, PTInstVar pvar);
 
-BOOL is_NT4();
-
 #endif



Ttssh2-commit メーリングリストの案内