OSDN Git Service

Change behavior of automatic IPv4/IPv6 selection.
[ffftp/ffftp.git] / main.c
diff --git a/main.c b/main.c
index 37a0743..b890086 100644 (file)
--- a/main.c
+++ b/main.c
@@ -28,6 +28,8 @@
 /============================================================================*/\r
 \r
 #define  STRICT\r
+// IPv6対応\r
+#include <winsock2.h>\r
 #include <windows.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -37,7 +39,8 @@
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 #include <stdarg.h>\r
-#include <winsock.h>\r
+// IPv6対応\r
+//#include <winsock.h>\r
 \r
 #include "common.h"\r
 #include "resource.h"\r
@@ -81,7 +84,9 @@ static void CalcWinSize(void);
 static void CheckResizeFrame(WPARAM Keys, int x, int y);\r
 static void DispDirInfo(void);\r
 static void DeleteAlltempFile(void);\r
-static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
+// 64ビット対応\r
+//static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
 static int EnterMasterPasswordAndSet( int Res, HWND hWnd );\r
 \r
 /*===== ローカルなワーク =====*/\r
@@ -127,6 +132,11 @@ static int SuppressRefresh = 0;
 \r
 static DWORD dwCookie;\r
 \r
+// 暗号化通信対応\r
+static char SSLRootCAFilePath[FMAX_PATH+1];\r
+// マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
+static DWORD MainThreadId;\r
+\r
 \r
 /*===== グローバルなワーク =====*/\r
 \r
@@ -135,12 +145,20 @@ HWND hHelpWin = NULL;
 /* 設定値 */\r
 int WinPosX = CW_USEDEFAULT;\r
 int WinPosY = 0;\r
-int WinWidth = 630;\r
-int WinHeight = 393;\r
-int LocalWidth = 309;\r
-int TaskHeight = 50;\r
-int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
-int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
+// 機能が増えたためサイズ変更\r
+// VGAサイズに収まるようになっていたのをSVGAサイズに引き上げ\r
+//int WinWidth = 630;\r
+//int WinHeight = 393;\r
+//int LocalWidth = 309;\r
+//int TaskHeight = 50;\r
+//int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
+//int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
+int WinWidth = 790;\r
+int WinHeight = 513;\r
+int LocalWidth = 389;\r
+int TaskHeight = 100;\r
+int LocalTabWidth[4] = { 160, 110, 60, 37 };\r
+int RemoteTabWidth[6] = { 160, 110, 60, 37, 60, 60 };\r
 char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" };\r
 char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } };\r
 HFONT ListFont = NULL;\r
@@ -210,10 +228,14 @@ int MirUpDelNotify = YES;
 int MirDownDelNotify = YES; \r
 int FolderAttr = NO;\r
 int FolderAttrNum = 777;\r
-// 同時接続対応\r
-int MaxThreadCount = 1;\r
 // 暗号化通信対応\r
 BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
+BYTE SSLRootCAFileHash[20];\r
+// ファイルアイコン表示対応\r
+int DispFileIcon = NO;\r
+// ディレクトリ自動作成\r
+int MakeAllDir = NO;\r
+\r
 \r
 \r
 \r
@@ -238,71 +260,75 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
 \r
        // プロセス保護\r
 #ifdef ENABLE_PROCESS_PROTECTION\r
-       DWORD ProtectLevel;\r
-       char* pCommand;\r
-       char Option[FMAX_PATH+1];\r
-       ProtectLevel = PROCESS_PROTECTION_NONE;\r
-       pCommand = lpszCmdLine;\r
-       while(pCommand = GetToken(pCommand, Option))\r
        {\r
-               if(strcmp(Option, "--protect") == 0)\r
-               {\r
-                       ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
-                       break;\r
-               }\r
-               else if(strcmp(Option, "--protect-high") == 0)\r
-               {\r
-                       ProtectLevel = PROCESS_PROTECTION_HIGH;\r
-                       break;\r
-               }\r
-               else if(strcmp(Option, "--protect-medium") == 0)\r
-               {\r
-                       ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
-                       break;\r
-               }\r
-               else if(strcmp(Option, "--protect-low") == 0)\r
+               DWORD ProtectLevel;\r
+               char* pCommand;\r
+               char Option[FMAX_PATH+1];\r
+               ProtectLevel = PROCESS_PROTECTION_NONE;\r
+               pCommand = lpszCmdLine;\r
+               while(pCommand = GetToken(pCommand, Option))\r
                {\r
-                       ProtectLevel = PROCESS_PROTECTION_LOW;\r
-                       break;\r
+                       if(strcmp(Option, "--protect") == 0)\r
+                       {\r
+                               ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
+                               break;\r
+                       }\r
+                       else if(strcmp(Option, "--protect-high") == 0)\r
+                       {\r
+                               ProtectLevel = PROCESS_PROTECTION_HIGH;\r
+                               break;\r
+                       }\r
+                       else if(strcmp(Option, "--protect-medium") == 0)\r
+                       {\r
+                               ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
+                               break;\r
+                       }\r
+                       else if(strcmp(Option, "--protect-low") == 0)\r
+                       {\r
+                               ProtectLevel = PROCESS_PROTECTION_LOW;\r
+                               break;\r
+                       }\r
                }\r
-       }\r
-       if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
-       {\r
-               SetProcessProtectionLevel(ProtectLevel);\r
-               if(!InitializeLoadLibraryHook())\r
+               if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
                {\r
-                       MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
-                       return 0;\r
-               }\r
+                       SetProcessProtectionLevel(ProtectLevel);\r
+                       if(!InitializeLoadLibraryHook())\r
+                       {\r
+                               MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
+                               return 0;\r
+                       }\r
 #ifndef _DEBUG\r
-               if(IsDebuggerPresent())\r
-               {\r
-                       MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
-                       return 0;\r
-               }\r
+                       if(IsDebuggerPresent())\r
+                       {\r
+                               MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
+                               return 0;\r
+                       }\r
 #endif\r
-               if(!UnloadUntrustedModule())\r
-               {\r
-                       MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
-                       return 0;\r
-               }\r
+                       if(!UnloadUntrustedModule())\r
+                       {\r
+                               MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
+                               return 0;\r
+                       }\r
 #ifndef _DEBUG\r
-               if(RestartProtectedProcess(" --restart"))\r
-                       return 0;\r
+                       if(RestartProtectedProcess(" --restart"))\r
+                               return 0;\r
 #endif\r
-               if(!EnableLoadLibraryHook(TRUE))\r
-               {\r
-                       MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
-                       return 0;\r
+                       if(!EnableLoadLibraryHook(TRUE))\r
+                       {\r
+                               MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
+                               return 0;\r
+                       }\r
                }\r
+               else\r
+                       InitializeLoadLibraryHook();\r
        }\r
-       else\r
-               InitializeLoadLibraryHook();\r
 #endif\r
 \r
+       // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
 #ifdef DISABLE_MULTI_CPUS\r
        SetProcessAffinityMask(GetCurrentProcess(), 1);\r
 #endif\r
+       MainThreadId = GetCurrentThreadId();\r
 \r
        // yutaka\r
        if(OleInitialize(NULL) != S_OK){\r
@@ -317,6 +343,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
        LoadOpenSSL();\r
 #endif\r
 \r
+       // SFTP対応\r
+       LoadPuTTY();\r
+\r
        Ret = FALSE;\r
        hWndFtp = NULL;\r
        hInstFtp = hInstance;\r
@@ -328,7 +357,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
                        if((Sts == 0) || (Sts == -1))\r
                                break;\r
 \r
-                       if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
+                       // 64ビット対応\r
+//                     if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
+                       if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg))\r
                        { \r
                                /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
                                /* コンボボックス内ではアクセラレータを無効にする */\r
@@ -350,6 +381,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
 #ifdef USE_OPENSSL\r
        FreeOpenSSL();\r
 #endif\r
+       // SFTP対応\r
+       FreePuTTY();\r
        OleUninitialize();\r
        return(Ret);\r
 }\r
@@ -382,7 +415,9 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
        aes_init();\r
        srand(GetTickCount());\r
        \r
-       HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
+       // 64ビット対応\r
+//     HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
+       HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie);\r
 \r
        SaveUpdateBellInfo();\r
 \r
@@ -392,7 +427,11 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
        {\r
                Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel));\r
 \r
-               GetTempPath(FMAX_PATH, TmpPath);\r
+               // 環境依存の不具合対策\r
+//             GetTempPath(FMAX_PATH, TmpPath);\r
+               GetAppTempPath(TmpPath);\r
+               _mkdir(TmpPath);\r
+               SetYenTail(TmpPath);\r
 \r
                GetModuleFileName(NULL, HelpPath, FMAX_PATH);\r
                strcpy(GetFileName(HelpPath), "ffftp.chm");\r
@@ -413,7 +452,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                /* 2010.02.01 genta マスターパスワードを入力させる\r
                  -z オプションがあるときは最初だけスキップ\r
                  -z オプションがないときは,デフォルトパスワードをまず試す\r
-                 LoadRegistory()する\r
+                 LoadRegistry()する\r
                  パスワードが不一致なら再入力するか尋ねる.\r
                  (破損していた場合はさせない)\r
                */\r
@@ -458,11 +497,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                \r
                if(masterpass != 0)\r
                {\r
-                       LoadRegistory();\r
+                       LoadRegistry();\r
 \r
                        // 暗号化通信対応\r
                        SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
                        SetSSLConfirmCallback(SSLConfirmCallback);\r
+                       GetModuleFileName(NULL, SSLRootCAFilePath, FMAX_PATH);\r
+                       strcpy(GetFileName(SSLRootCAFilePath), "ssl.pem");\r
+                       LoadSSLRootCAFile();\r
 \r
                        LoadJre();\r
                        if(NoRasControl == NO)\r
@@ -504,7 +546,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                                        DispWindowTitle();\r
                                        // SourceForge.JPによるフォーク\r
 //                                     SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.");\r
-                                       SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, raido).");\r
+                                       SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011-2012 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, Asami, fortran90, tomo1192, Yuji Tanaka, Moriguchi Hirokazu).");\r
 \r
                                        if(ForceIni)\r
                                                SetTaskMsg("%s%s", MSGJPN283, IniPath);\r
@@ -612,13 +654,7 @@ static int MakeAllWindows(int cmdShow)
                WinPosX = CW_USEDEFAULT;\r
                WinPosY = 0;\r
        }\r
-       // UTF-8対応\r
-       // ユーザー定義のクラスはデフォルトのWNDPROCがShift_JIS専用のため\r
-//     hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
-//                             WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
-//                             WinPosX, WinPosY, WinWidth, WinHeight,\r
-//                             HWND_DESKTOP, 0, hInstFtp, NULL);\r
-       hWndFtp = CreateWindowA(FtpClassStr, "FFFTP",\r
+       hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
                                WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
                                WinPosX, WinPosY, WinWidth, WinHeight,\r
                                HWND_DESKTOP, 0, hInstFtp, NULL);\r
@@ -825,21 +861,43 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 {\r
        PAINTSTRUCT ps;\r
        LPTOOLTIPTEXT lpttt;\r
+       // UTF-8対応\r
+       LPTOOLTIPTEXTW wlpttt;\r
        RECT Rect;\r
 \r
        int TmpTransType;\r
 \r
        switch (message)\r
        {\r
+               // 自動切断対策\r
+               case WM_TIMER :\r
+                       if(wParam == 1)\r
+                               NoopProc();\r
+                       break;\r
+\r
                case WM_COMMAND :\r
+                       // 同時接続対応\r
+                       // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない\r
+                       if(CancelFlg == YES)\r
+                               RemoveReceivedData(AskCmdCtrlSkt());\r
                        switch(LOWORD(wParam))\r
                        {\r
                                case MENU_CONNECT :\r
+                                       // 自動切断対策\r
+                                       KillTimer(hWnd, 1);\r
                                        ConnectProc(DLG_TYPE_CON, -1);\r
+                                       // 自動切断対策\r
+                                       if(AskNoopInterval() > 0)\r
+                                               SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
                                        break;\r
 \r
                                case MENU_CONNECT_NUM :\r
+                                       // 自動切断対策\r
+                                       KillTimer(hWnd, 1);\r
                                        ConnectProc(DLG_TYPE_CON, (int)lParam);\r
+                                       // 自動切断対策\r
+                                       if(AskNoopInterval() > 0)\r
+                                               SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
                                        if(AskConnecting() == YES)\r
                                        {\r
                                                if(HIWORD(wParam) & OPT_MIRROR)\r
@@ -860,11 +918,21 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case MENU_SET_CONNECT :\r
+                                       // 自動切断対策\r
+                                       KillTimer(hWnd, 1);\r
                                        ConnectProc(DLG_TYPE_SET, -1);\r
+                                       // 自動切断対策\r
+                                       if(AskNoopInterval() > 0)\r
+                                               SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
                                        break;\r
 \r
                                case MENU_QUICK :\r
+                                       // 自動切断対策\r
+                                       KillTimer(hWnd, 1);\r
                                        QuickConnectProc();\r
+                                       // 自動切断対策\r
+                                       if(AskNoopInterval() > 0)\r
+                                               SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
                                        break;\r
 \r
                                case MENU_DISCONNECT :\r
@@ -898,7 +966,12 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case MENU_HIST_18 :\r
                                case MENU_HIST_19 :\r
                                case MENU_HIST_20 :\r
+                                       // 自動切断対策\r
+                                       KillTimer(hWnd, 1);\r
                                        HistoryConnectProc(LOWORD(wParam));\r
+                                       // 自動切断対策\r
+                                       if(AskNoopInterval() > 0)\r
+                                               SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
                                        break;\r
 \r
                                case MENU_UPDIR :\r
@@ -910,6 +983,22 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 \r
                                case MENU_DCLICK :\r
                                        if(hWndCurFocus == GetLocalHwnd())\r
+                                               // ローカルフォルダを開く\r
+//                                             DoubleClickProc(WIN_LOCAL, YES, -1);\r
+                                               DoubleClickProc(WIN_LOCAL, NO, -1);\r
+                                       else\r
+                                       {\r
+                                               SuppressRefresh = 1;\r
+                                               // ローカルフォルダを開く\r
+//                                             DoubleClickProc(WIN_REMOTE, YES, -1);\r
+                                               DoubleClickProc(WIN_REMOTE, NO, -1);\r
+                                               SuppressRefresh = 0;\r
+                                       }\r
+                                       break;\r
+\r
+                               // ローカルフォルダを開く\r
+                               case MENU_OPEN :\r
+                                       if(hWndCurFocus == GetLocalHwnd())\r
                                                DoubleClickProc(WIN_LOCAL, YES, -1);\r
                                        else\r
                                        {\r
@@ -978,42 +1067,42 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 \r
                                case MENU_DOWNLOAD :\r
                                        SetCurrentDirAsDirHist();\r
-                                       DownLoadProc(NO, NO, NO);\r
+                                       DownloadProc(NO, NO, NO);\r
                                        break;\r
 \r
                                case MENU_DOWNLOAD_AS :\r
                                        SetCurrentDirAsDirHist();\r
-                                       DownLoadProc(YES, NO, NO);\r
+                                       DownloadProc(YES, NO, NO);\r
                                        break;\r
 \r
                                case MENU_DOWNLOAD_AS_FILE :\r
                                        SetCurrentDirAsDirHist();\r
-                                       DownLoadProc(NO, YES, NO);\r
+                                       DownloadProc(NO, YES, NO);\r
                                        break;\r
 \r
                                case MENU_DOWNLOAD_ALL :\r
                                        SetCurrentDirAsDirHist();\r
-                                       DownLoadProc(NO, NO, YES);\r
+                                       DownloadProc(NO, NO, YES);\r
                                        break;\r
 \r
                                case MENU_DOWNLOAD_NAME :\r
                                        SetCurrentDirAsDirHist();\r
-                                       InputDownLoadProc();\r
+                                       InputDownloadProc();\r
                                        break;\r
 \r
                                case MENU_UPLOAD :\r
                                        SetCurrentDirAsDirHist();\r
-                                       UpLoadListProc(NO, NO);\r
+                                       UploadListProc(NO, NO);\r
                                        break;\r
 \r
                                case MENU_UPLOAD_AS :\r
                                        SetCurrentDirAsDirHist();\r
-                                       UpLoadListProc(YES, NO);\r
+                                       UploadListProc(YES, NO);\r
                                        break;\r
 \r
                                case MENU_UPLOAD_ALL :\r
                                        SetCurrentDirAsDirHist();\r
-                                       UpLoadListProc(NO, YES);\r
+                                       UploadListProc(NO, YES);\r
                                        break;\r
 \r
                                case MENU_MIRROR_UPLOAD :\r
@@ -1081,12 +1170,16 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case MENU_FILTER :\r
+                                       // 同時接続対応\r
+                                       CancelFlg = NO;\r
                                        SetFilter(&CancelFlg);\r
                                        break;\r
 \r
                                case MENU_SORT :\r
                                        if(SortSetting() == YES)\r
                                        {\r
+                                               // 同時接続対応\r
+                                               CancelFlg = NO;\r
                                                LocalFileSort = AskSortType(ITEM_LFILE);\r
                                                LocalDirSort = AskSortType(ITEM_LDIR);\r
                                                RemoteFileSort = AskSortType(ITEM_RFILE);\r
@@ -1140,6 +1233,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case MENU_KNJ_EUC :\r
                                case MENU_KNJ_JIS :\r
                                case MENU_KNJ_UTF8N :\r
+                               case MENU_KNJ_UTF8BOM :\r
                                case MENU_KNJ_NONE :\r
                                        SetHostKanjiCode(LOWORD(wParam));\r
                                        break;\r
@@ -1148,6 +1242,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case MENU_L_KNJ_EUC :\r
                                case MENU_L_KNJ_JIS :\r
                                case MENU_L_KNJ_UTF8N :\r
+                               case MENU_L_KNJ_UTF8BOM :\r
                                        SetLocalKanjiCode(LOWORD(wParam));\r
                                        break;\r
 \r
@@ -1156,6 +1251,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case MENU_REFRESH :\r
+                                       // 同時接続対応\r
+                                       CancelFlg = NO;\r
                                        SuppressRefresh = 1;\r
                                        GetLocalDirForWnd();\r
                                        if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
@@ -1180,6 +1277,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case REFRESH_REMOTE :\r
+                                       // 同時接続対応\r
+                                       CancelFlg = NO;\r
                                        SuppressRefresh = 1;\r
                                        if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
                                                GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
@@ -1208,7 +1307,9 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case MENU_HELP_TROUBLE :\r
-                                       ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
+                                       // 任意のコードが実行されるバグ修正\r
+//                                     ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
+                                       ShellExecute(NULL, "open", MYWEB_URL, NULL, NULL, SW_SHOW);\r
                                        break;\r
 \r
                                case MENU_BMARK_ADD :\r
@@ -1244,6 +1345,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        break;\r
 \r
                                case MENU_DOTFILE :\r
+                                       // 同時接続対応\r
+                                       CancelFlg = NO;\r
                                        DotFile ^= 1;\r
                                        DispDotFileMode();\r
                                        GetLocalDirForWnd();\r
@@ -1260,7 +1363,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 \r
                                case MENU_REGSAVE :\r
                                        GetListTabWidth();\r
-                                       SaveRegistory();\r
+                                       SaveRegistry();\r
                                        SaveSettingsToFile();\r
                                        break;\r
 \r
@@ -1276,7 +1379,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case MENU_REGINIT :\r
                                        if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
                                        {\r
-                                               ClearRegistory();\r
+                                               ClearRegistry();\r
                                                SaveExit = NO;\r
                                                PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
                                        }\r
@@ -1324,6 +1427,12 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                LocalRbuttonMenu(1);\r
                                        break;\r
 \r
+#if defined(HAVE_TANDEM)\r
+                               case MENU_SWITCH_OSS :\r
+                                       SwitchOSSProc();\r
+                                       break;\r
+#endif\r
+\r
                                default :\r
                                        if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
                                           (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
@@ -1341,8 +1450,13 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                        switch(((LPNMHDR)lParam)->code)\r
                        {\r
                                /* ツールチップコントロールメッセージの処理 */\r
-                               case TTN_NEEDTEXT:\r
+                               // UTF-8対応\r
+//                             case TTN_NEEDTEXT:\r
+                               case TTN_NEEDTEXTW:\r
                                        lpttt = (LPTOOLTIPTEXT)lParam;\r
+                                       // UTF-8対応\r
+                                       // lptttは単なる警告回避用\r
+                                       wlpttt = (LPTOOLTIPTEXTW)lParam;\r
                                        lpttt->hinst = hInstFtp;\r
                                        switch(lpttt->hdr.idFrom)\r
                                        {\r
@@ -1361,7 +1475,15 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                case MENU_DOWNLOAD :\r
                                                        lpttt->lpszText = MSGJPN157;\r
                                                        break;\r
+#if defined(HAVE_TANDEM)\r
+                                               case MENU_DOWNLOAD_AS :\r
+                                                       lpttt->lpszText = MSGJPN065;\r
+                                                       break;\r
 \r
+                                               case MENU_UPLOAD_AS :\r
+                                                       lpttt->lpszText = MSGJPN064;\r
+                                                       break;\r
+#endif\r
                                                case MENU_UPLOAD :\r
                                                        lpttt->lpszText = MSGJPN158;\r
                                                        break;\r
@@ -1432,6 +1554,10 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                        lpttt->lpszText = MSGJPN308;\r
                                                        break;\r
 \r
+                                               case MENU_KNJ_UTF8BOM :\r
+                                                       lpttt->lpszText = MSGJPN330;\r
+                                                       break;\r
+\r
                                                case MENU_KNJ_NONE :\r
                                                        lpttt->lpszText = MSGJPN173;\r
                                                        break;\r
@@ -1452,6 +1578,10 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                        lpttt->lpszText = MSGJPN312;\r
                                                        break;\r
 \r
+                                               case MENU_L_KNJ_UTF8BOM :\r
+                                                       lpttt->lpszText = MSGJPN331;\r
+                                                       break;\r
+\r
                                                case MENU_KANACNV :\r
                                                        lpttt->lpszText = MSGJPN174;\r
                                                        break;\r
@@ -1464,15 +1594,14 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                        lpttt->lpszText = MSGJPN176;\r
                                                        break;\r
                                        }\r
-                                       // UTF-8からShift_JISへ変換\r
+                                       // UTF-8対応\r
+                                       // UTF-8からUTF-16 LEへ変換\r
                                        {\r
                                                static wchar_t StringBufferUTF16[1024];\r
-                                               static char StringBufferSJIS[1024];\r
                                                if(lpttt->lpszText)\r
                                                {\r
                                                        MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
-                                                       WtoA(StringBufferSJIS, sizeof(StringBufferSJIS)/ sizeof(char), StringBufferUTF16, -1);\r
-                                                       lpttt->lpszText = StringBufferSJIS;\r
+                                                       wlpttt->lpszText = StringBufferUTF16;\r
                                                }\r
                                        }\r
                                        break;\r
@@ -1480,6 +1609,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case LVN_COLUMNCLICK :\r
                                        if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
                                        {\r
+                                               // 同時接続対応\r
+                                               CancelFlg = NO;\r
                                                SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
                                                ReSortDispList(WIN_LOCAL, &CancelFlg);\r
                                        }\r
@@ -1487,6 +1618,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        {\r
                                                if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
                                                {\r
+                                                       // 同時接続対応\r
+                                                       CancelFlg = NO;\r
                                                        SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
                                                        ReSortDispList(WIN_REMOTE, &CancelFlg);\r
                                                }\r
@@ -1932,6 +2065,9 @@ static char *GetToken(char *Str, char *Buf)
 \r
 static void ExitProc(HWND hWnd)\r
 {\r
+       // 環境依存の不具合対策\r
+       char Tmp[FMAX_PATH+1];\r
+\r
        CancelFlg = YES;\r
 \r
        CloseTransferThread();\r
@@ -1950,7 +2086,7 @@ static void ExitProc(HWND hWnd)
        if(SaveExit == YES)\r
        {\r
                GetListTabWidth();\r
-               SaveRegistory();\r
+               SaveRegistry();\r
 \r
                if((CacheEntry > 0) && (CacheSave == YES))\r
                        SaveCache();\r
@@ -1960,6 +2096,14 @@ static void ExitProc(HWND hWnd)
        else\r
                DeleteCache();\r
 \r
+       // 環境依存の不具合対策\r
+       GetAppTempPath(Tmp);\r
+       SetYenTail(Tmp);\r
+       strcat(Tmp, "file");\r
+       _rmdir(Tmp);\r
+       GetAppTempPath(Tmp);\r
+       _rmdir(Tmp);\r
+\r
        if(RasClose == YES)\r
        {\r
                DisconnectRas(RasCloseNotify);\r
@@ -2003,7 +2147,9 @@ void DoubleClickProc(int Win, int Mode, int App)
 \r
                                if(Win == WIN_LOCAL)\r
                                {\r
-                                       if((App != -1) || (Type == NODE_FILE))\r
+                                       // ローカルフォルダを開く\r
+//                                     if((App != -1) || (Type == NODE_FILE))\r
+                                       if((App != -1) || (Type == NODE_FILE) || (Mode == YES))\r
                                        {\r
                                                if((DclickOpen == YES) || (Mode == YES))\r
                                                {\r
@@ -2033,6 +2179,10 @@ void DoubleClickProc(int Win, int Mode, int App)
 \r
                                                        strcpy(Remote, TmpPath);\r
                                                        SetYenTail(Remote);\r
+                                                       // 環境依存の不具合対策\r
+                                                       strcat(Remote, "file");\r
+                                                       _mkdir(Remote);\r
+                                                       SetYenTail(Remote);\r
                                                        if (UseDiffViewer == YES) {\r
                                                                strcat(Remote, "remote.");\r
                                                        }\r
@@ -2076,10 +2226,12 @@ void DoubleClickProc(int Win, int Mode, int App)
                                                        /* 不正なパスを検出 */\r
                                                        if(CheckPathViolation(&MainTransPkt) == NO)\r
                                                        {\r
-//                                                             if((Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
+//                                                             if((Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
 //                                                             {\r
 //                                                                     ReConnectCmdSkt();\r
-                                                                       Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
+                                                                       // 同時接続対応\r
+                                                                       CancelFlg = NO;\r
+                                                                       Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
 //                                                             }\r
                                                        }\r
 \r
@@ -2131,6 +2283,11 @@ static void ChangeDir(int Win, char *Path)
        char Local[FMAX_PATH+1];\r
        char Remote[FMAX_PATH+1];\r
 \r
+       // 同時接続対応\r
+       CancelFlg = NO;\r
+\r
+       // デッドロック対策\r
+       DisableUserOpe();\r
        Sync = AskSyncMoveMode();\r
        if(Sync == YES)\r
        {\r
@@ -2162,6 +2319,8 @@ static void ChangeDir(int Win, char *Path)
                                GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
                }\r
        }\r
+       // デッドロック対策\r
+       EnableUserOpe();\r
        return;\r
 }\r
 \r
@@ -2419,6 +2578,8 @@ void ExecViewer(char *Fname, int App)
        char AssocProg[FMAX_PATH+1];\r
        char ComLine[FMAX_PATH*2+3+1];\r
        char CurDir[FMAX_PATH+1];\r
+       // 任意のコードが実行されるバグ修正\r
+       char SysDir[FMAX_PATH+1];\r
 \r
        /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
        /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
@@ -2426,11 +2587,21 @@ void ExecViewer(char *Fname, int App)
 \r
        AskLocalCurDir(CurDir, FMAX_PATH);\r
 \r
-       if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
+       // 任意のコードが実行されるバグ修正\r
+       // 拡張子が無いと補完されるため\r
+//     if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
+       if((App == -1) && (strlen(GetFileExt(GetFileName(Fname))) > 0) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
        {\r
                DoPrintf("ShellExecute - %s", Fname);\r
                ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW);\r
        }\r
+       // ローカルフォルダを開く\r
+       else if((App == -1) && (GetFileAttributes(Fname) & FILE_ATTRIBUTE_DIRECTORY))\r
+       {\r
+               MakeDistinguishableFileName(ComLine, Fname);\r
+               DoPrintf("ShellExecute - %s", Fname);\r
+               ShellExecute(NULL, "open", ComLine, NULL, Fname, SW_SHOW);\r
+       }\r
        else\r
        {\r
                App = max1(0, App);\r
@@ -2446,10 +2617,26 @@ void ExecViewer(char *Fname, int App)
                memset(&Startup, NUL, sizeof(STARTUPINFO));\r
                Startup.cb = sizeof(STARTUPINFO);\r
                Startup.wShowWindow = SW_SHOW;\r
-               if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+               // 任意のコードが実行されるバグ修正\r
+//             if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+//             {\r
+//                     SetTaskMsg(MSGJPN182, GetLastError());\r
+//                     SetTaskMsg(">>%s", ComLine);\r
+//             }\r
+               if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)\r
                {\r
-                       SetTaskMsg(MSGJPN182, GetLastError());\r
-                       SetTaskMsg(">>%s", ComLine);\r
+                       if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)\r
+                       {\r
+                               if(SetCurrentDirectory(SysDir))\r
+                               {\r
+                                       if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+                                       {\r
+                                               SetTaskMsg(MSGJPN182, GetLastError());\r
+                                               SetTaskMsg(">>%s", ComLine);\r
+                                       }\r
+                                       SetCurrentDirectory(CurDir);\r
+                               }\r
+                       }\r
                }\r
        }\r
        return;\r
@@ -2474,6 +2661,8 @@ void ExecViewer2(char *Fname1, char *Fname2, int App)
        char AssocProg[FMAX_PATH+1];\r
        char ComLine[FMAX_PATH*2+3+1];\r
        char CurDir[FMAX_PATH+1];\r
+       // 任意のコードが実行されるバグ修正\r
+       char SysDir[FMAX_PATH+1];\r
 \r
        /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
        /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
@@ -2493,10 +2682,26 @@ void ExecViewer2(char *Fname1, char *Fname2, int App)
        memset(&Startup, NUL, sizeof(STARTUPINFO));\r
        Startup.cb = sizeof(STARTUPINFO);\r
        Startup.wShowWindow = SW_SHOW;\r
-       if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+       // 任意のコードが実行されるバグ修正\r
+//     if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+//     {\r
+//             SetTaskMsg(MSGJPN182, GetLastError());\r
+//             SetTaskMsg(">>%s", ComLine);\r
+//     }\r
+       if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)\r
        {\r
-               SetTaskMsg(MSGJPN182, GetLastError());\r
-               SetTaskMsg(">>%s", ComLine);\r
+               if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)\r
+               {\r
+                       if(SetCurrentDirectory(SysDir))\r
+                       {\r
+                               if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
+                               {\r
+                                       SetTaskMsg(MSGJPN182, GetLastError());\r
+                                       SetTaskMsg(">>%s", ComLine);\r
+                               }\r
+                               SetCurrentDirectory(CurDir);\r
+                       }\r
+               }\r
        }\r
 \r
        return;\r
@@ -2578,7 +2783,9 @@ static void DeleteAlltempFile(void)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
        static char Tmp[80];\r
        int Ver;\r
@@ -2706,7 +2913,11 @@ int BackgrndMessageProc(void)
        Ret = NO;\r
        while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))\r
        {\r
-               if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
+               // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
+//             if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
+               // 64ビット対応\r
+//             if(!IsMainThread() || !HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
+               if(!IsMainThread() || !HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg))\r
                {\r
                        /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
                        /* コンボボックス内ではアクセラレータを無効にする */\r
@@ -2815,32 +3026,36 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd )
 }\r
 \r
 // 暗号化通信対応\r
-BOOL __stdcall SSLTimeoutCallback()\r
+BOOL __stdcall SSLTimeoutCallback(BOOL* pbAborted)\r
 {\r
        Sleep(1);\r
        if(BackgrndMessageProc() == YES)\r
                return TRUE;\r
-       // 念のためツールバーのMENU_ABORTも確認\r
-//     if(MainTransPkt.Abort != ABORT_NONE)\r
-//     {\r
-//             MainTransPkt.Abort = ABORT_NONE;\r
-//             return TRUE;\r
-//     }\r
+       if(*pbAborted == YES)\r
+               return TRUE;\r
        return FALSE;\r
 }\r
 \r
-BOOL __stdcall SSLConfirmCallback(BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
+BOOL __stdcall SSLConfirmCallback(BOOL* pbAborted, BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
 {\r
        BOOL bResult;\r
-       int i;\r
        uint32 Hash[5];\r
+       int i;\r
        char* pm0;\r
        bResult = FALSE;\r
        sha_memory((char*)Certificate, (uint32)(strlen(Certificate) * sizeof(char)), (uint32*)&Hash);\r
-       for(i = 0; i < MAX_CERT_CACHE_HASH; i++)\r
+       // sha.cはビッグエンディアンのため\r
+       for(i = 0; i < 5; i++)\r
+               Hash[i] = _byteswap_ulong(Hash[i]);\r
+       i = 0;\r
+       while(i < MAX_CERT_CACHE_HASH)\r
        {\r
                if(memcmp(&CertificateCacheHash[i], &Hash, 20) == 0)\r
+               {\r
                        bResult = TRUE;\r
+                       break;\r
+               }\r
+               i++;\r
        }\r
        if(!bResult)\r
        {\r
@@ -2857,6 +3072,58 @@ BOOL __stdcall SSLConfirmCallback(BOOL bVerified, LPCSTR Certificate, LPCSTR Com
                        FreeDuplicatedString(pm0);\r
                }\r
        }\r
+       if(!bResult)\r
+               *pbAborted = YES;\r
        return bResult;\r
 }\r
 \r
+BOOL LoadSSLRootCAFile()\r
+{\r
+       BOOL bResult;\r
+       HANDLE hFile;\r
+       DWORD Size;\r
+       BYTE* pBuffer;\r
+       uint32 Hash[5];\r
+       int i;\r
+       bResult = FALSE;\r
+       if((hFile = CreateFile(SSLRootCAFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)\r
+       {\r
+               Size = GetFileSize(hFile, NULL);\r
+               if(pBuffer = (BYTE*)malloc(Size))\r
+               {\r
+                       if(ReadFile(hFile, pBuffer, Size, &Size, NULL))\r
+                       {\r
+                               sha_memory((char*)pBuffer, (uint32)Size, (uint32*)&Hash);\r
+                               // sha.cはビッグエンディアンのため\r
+                               for(i = 0; i < 5; i++)\r
+                                       Hash[i] = _byteswap_ulong(Hash[i]);\r
+                               // 同梱する"ssl.pem"に合わせてSHA1ハッシュ値を変更すること\r
+                               if(memcmp(&Hash, &SSLRootCAFileHash, 20) == 0 || memcmp(&Hash, "\xF0\x1B\x48\x26\x67\x44\x3A\xFF\x0A\x16\xD3\xBB\x8A\x33\xEB\x70\x6D\x75\xA6\x0D", 20) == 0\r
+                                       || DialogBox(GetFtpInst(), MAKEINTRESOURCE(updatesslroot_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                               {\r
+                                       memcpy(&SSLRootCAFileHash, &Hash, 20);\r
+                                       if(SetSSLRootCertificate(pBuffer, Size))\r
+                                               bResult = TRUE;\r
+                               }\r
+                       }\r
+                       free(pBuffer);\r
+               }\r
+               CloseHandle(hFile);\r
+       }\r
+       return bResult;\r
+}\r
+\r
+// マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
+BOOL IsMainThread()\r
+{\r
+       if(GetCurrentThreadId() != MainThreadId)\r
+               return FALSE;\r
+       return TRUE;\r
+}\r
+\r
+// ファイルアイコン表示対応\r
+int AskDispFileIcon(void)\r
+{\r
+       return(DispFileIcon);\r
+}\r
+\r