OSDN Git Service

Change behavior of automatic IPv4/IPv6 selection.
[ffftp/ffftp.git] / main.c
diff --git a/main.c b/main.c
index 3794252..b890086 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,6 +1,6 @@
-/*=============================================================================\r
+/*=============================================================================\r
 *\r
-*                                                                      \82e\82e\82e\82s\82o\r
+*                                                                      FFFTP\r
 *\r
 ===============================================================================\r
 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
@@ -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
 #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
 #include "aes.h"\r
+// 暗号化通信対応\r
+#include "sha.h"\r
 \r
 #include <htmlhelp.h>\r
 #include "helpid.h"\r
 \r
-// UTF-8\91Î\89\9e\r
+// UTF-8対応\r
 #undef __MBSWRAPPER_H__\r
 #include "mbswrapper.h"\r
 \r
 \r
-#define RESIZE_OFF             0               /* \83E\83C\83\93\83h\83E\82Ì\8bæ\90Ø\82è\88Ê\92u\95Ï\8dX\82µ\82Ä\82¢\82È\82¢ */\r
-#define RESIZE_ON              1               /* \83E\83C\83\93\83h\83E\82Ì\8bæ\90Ø\82è\88Ê\92u\95Ï\8dX\92\86 */\r
-#define RESIZE_PREPARE 2               /* \83E\83C\83\93\83h\83E\82Ì\8bæ\90Ø\82è\88Ê\92u\95Ï\8dX\82Ì\8f\80\94õ */\r
+#define RESIZE_OFF             0               /* ウインドウの区切り位置変更していない */\r
+#define RESIZE_ON              1               /* ウインドウの区切り位置変更中 */\r
+#define RESIZE_PREPARE 2               /* ウインドウの区切り位置変更の準備 */\r
 \r
-#define RESIZE_HPOS            0               /* \83\8d\81[\83J\83\8b\81|\83z\83X\83g\8aÔ\82Ì\8bæ\90Ø\82è\88Ê\92u\95Ï\8dX */\r
-#define RESIZE_VPOS            1               /* \83\8a\83X\83g\81|\83^\83X\83N\8aÔ\82Ì\8bæ\90Ø\82è\88Ê\92u\82Ì\95Ï\8dX */\r
+#define RESIZE_HPOS            0               /* ローカル-ホスト間の区切り位置変更 */\r
+#define RESIZE_VPOS            1               /* リスト-タスク間の区切り位置の変更 */\r
 \r
 \r
-/*===== \83v\83\8d\83g\83^\83C\83v =====*/\r
+/*===== プロトタイプ =====*/\r
 \r
 static int InitApp(LPSTR lpszCmdLine, int cmdShow);\r
 static int MakeAllWindows(int cmdShow);\r
@@ -79,10 +84,12 @@ 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
-/*===== \83\8d\81[\83J\83\8b\82È\83\8f\81[\83N =====*/\r
+/*===== ローカルなワーク =====*/\r
 \r
 static const char FtpClassStr[] = "FFFTPWin";\r
 \r
@@ -112,9 +119,9 @@ static char HelpPath[FMAX_PATH+1];
 static char IniPath[FMAX_PATH+1];\r
 static int ForceIni = NO;\r
 \r
-TRANSPACKET MainTransPkt;              /* \83t\83@\83C\83\8b\93]\91\97\97p\83p\83P\83b\83g */\r
-                                                               /* \82±\82ê\82ð\8eg\82Á\82Ä\93]\91\97\82ð\8ds\82¤\82Æ\81A\83c\81[\83\8b\83o\81[\82Ì\93]\91\97 */\r
-                                                               /* \92\86\8e~\83{\83^\83\93\82Å\92\86\8e~\82Å\82«\82é */\r
+TRANSPACKET MainTransPkt;              /* ファイル転送用パケット */\r
+                                                               /* これを使って転送を行うと、ツールバーの転送 */\r
+                                                               /* 中止ボタンで中止できる */\r
 \r
 char TitleHostName[HOST_ADRS_LEN+1];\r
 char FilterStr[FILTER_EXT_LEN+1] = { "*" };\r
@@ -125,20 +132,33 @@ 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
-/*===== \83O\83\8d\81[\83o\83\8b\82È\83\8f\81[\83N =====*/\r
+\r
+/*===== グローバルなワーク =====*/\r
 \r
 HWND hHelpWin = NULL;\r
 \r
-/* \90Ý\92è\92l */\r
+/* 設定値 */\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
@@ -156,7 +176,7 @@ int RecvMode = TRANS_DLG;
 int SendMode = TRANS_DLG;\r
 int MoveMode = MOVE_DLG;\r
 int ListType = LVS_REPORT;\r
-// LIST\82Ì\83L\83\83\83b\83V\83\85\82ð\96³\8cø\82É\82·\82é\81i\83\8a\83\82\81[\83g\82Ì\83f\83B\83\8c\83N\83g\83\8a\82Ì\95\\8e¦\82ª\8dX\90V\82³\82ê\82È\82¢\83o\83O\91Î\8dô\81j\r
+// LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)\r
 //int CacheEntry = 10;\r
 int CacheEntry = -10;\r
 int CacheSave = NO;\r
@@ -208,20 +228,28 @@ int MirUpDelNotify = YES;
 int MirDownDelNotify = YES; \r
 int FolderAttr = NO;\r
 int FolderAttrNum = 777;\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
 \r
-/*----- \83\81\83C\83\93\83\8b\81[\83`\83\93 --------------------------------------------------------\r
+/*----- メインルーチン --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              HINSTANCE hInstance : \82±\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\82±\82Ì\83C\83\93\83X\83^\83\93\83X\82Ì\83n\83\93\83h\83\8b\r
-*              HINSTANCE hPrevInstance : \82±\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\92¼\91O\82Ì\83C\83\93\83X\83^\83\93\83X\82Ì\83n\83\93\83h\83\8b\r
-*              LPSTR lpszCmdLine : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\8bN\93®\82µ\82½\82Æ\82«\82Ì\83R\83}\83\93\83h\83\89\83C\83\93\82ð\82³\82·\83\8d\83\93\83O\83|\83C\83\93\83^\r
-*              int cmdShow : \8dÅ\8f\89\82É\95\\8e¦\82·\82é\83E\83C\83\93\83h\83E\82Ì\8c`\8e®\81B\r
+*              HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
+*              HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
+*              LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
+*              int cmdShow : 最初に表示するウインドウの形式。\r
 *\r
 *      Return Value\r
-*              int \8dÅ\8cã\82Ì\83\81\83b\83Z\81[\83W\82ÌwParam\r
+*              int 最後のメッセージのwParam\r
 *----------------------------------------------------------------------------*/\r
 \r
 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)\r
@@ -230,9 +258,77 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
        int Ret;\r
        BOOL Sts;\r
 \r
+       // プロセス保護\r
+#ifdef ENABLE_PROCESS_PROTECTION\r
+       {\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
+                       {\r
+                               ProtectLevel = PROCESS_PROTECTION_LOW;\r
+                               break;\r
+                       }\r
+               }\r
+               if(ProtectLevel != PROCESS_PROTECTION_NONE)\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
+#endif\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
+#endif\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
+#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
@@ -242,14 +338,18 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
 \r
        InitCommonControls();\r
 \r
+       // FTPS対応\r
 #ifdef USE_OPENSSL\r
        LoadOpenSSL();\r
 #endif\r
 \r
+       // SFTP対応\r
+       LoadPuTTY();\r
+\r
        Ret = FALSE;\r
        hWndFtp = NULL;\r
        hInstFtp = hInstance;\r
-       if(InitApp(lpszCmdLine, cmdShow) == SUCCESS)\r
+       if(InitApp(lpszCmdLine, cmdShow) == FFFTP_SUCCESS)\r
        {\r
                for(;;)\r
                {\r
@@ -257,10 +357,12 @@ 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
-                               /* \83f\83B\83\8c\83N\83g\83\8a\96¼\82Ì\95\\8e¦\83R\83\93\83{\83{\83b\83N\83X\82ÅBS\82âRET\82ª\8cø\82­\82æ\82¤\82É */\r
-                               /* \83R\83\93\83{\83{\83b\83N\83X\93à\82Å\82Í\83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é */\r
+                               /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
+                               /* コンボボックス内ではアクセラレータを無効にする */\r
                                if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
                                   (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
                                   ((hHelpWin != NULL) && (GetAncestor(Msg.hwnd, GA_ROOT) == hHelpWin)) ||\r
@@ -275,25 +377,28 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
                Ret = Msg.wParam;\r
        }\r
     UnregisterClass(FtpClassStr, hInstFtp);\r
+       // FTPS対応\r
 #ifdef USE_OPENSSL\r
        FreeOpenSSL();\r
 #endif\r
+       // SFTP対応\r
+       FreePuTTY();\r
        OleUninitialize();\r
        return(Ret);\r
 }\r
 \r
 \r
-/*----- \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\8f\89\8aú\90Ý\92è --------------------------------------------\r
+/*----- アプリケーションの初期設定 --------------------------------------------\r
 *\r
 *      Parameter\r
-*              HINSTANCE hInstance : \82±\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\82±\82Ì\83C\83\93\83X\83^\83\93\83X\82Ì\83n\83\93\83h\83\8b\r
-*              HINSTANCE hPrevInstance : \82±\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\92¼\91O\82Ì\83C\83\93\83X\83^\83\93\83X\82Ì\83n\83\93\83h\83\8b\r
-*              LPSTR lpszCmdLine : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\8bN\93®\82µ\82½\82Æ\82«\82Ì\83R\83}\83\93\83h\83\89\83C\83\93\82ð\82³\82·\83\8d\83\93\83O\83|\83C\83\93\83^\r
-*              int cmdShow : \8dÅ\8f\89\82É\95\\8e¦\82·\82é\83E\83C\83\93\83h\83E\82Ì\8c`\8e®\81B\r
+*              HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
+*              HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
+*              LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
+*              int cmdShow : 最初に表示するウインドウの形式。\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int InitApp(LPSTR lpszCmdLine, int cmdShow)\r
@@ -302,15 +407,17 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
        int Err;\r
        WSADATA WSAData;\r
        char PwdBuf[FMAX_PATH+1];\r
-       int useDefautPassword = 0; /* \8cx\8d\90\95\95\\8e¦\97p */\r
+       int useDefautPassword = 0; /* 警告文表示用 */\r
        int masterpass;\r
 \r
-       sts = FAIL;\r
+       sts = FFFTP_FAIL;\r
 \r
        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
@@ -320,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
@@ -338,12 +449,12 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
 \r
 //             AllocConsole();\r
 \r
-               /* 2010.02.01 genta \83}\83X\83^\81[\83p\83X\83\8f\81[\83h\82ð\93ü\97Í\82³\82¹\82é\r
-                 -z \83I\83v\83V\83\87\83\93\82ª\82 \82é\82Æ\82«\82Í\8dÅ\8f\89\82¾\82¯\83X\83L\83b\83v\r
-                 -z \83I\83v\83V\83\87\83\93\82ª\82È\82¢\82Æ\82«\82Í\81C\83f\83t\83H\83\8b\83g\83p\83X\83\8f\81[\83h\82ð\82Ü\82¸\8e\8e\82·\r
-                 LoadRegistory()\82·\82é\r
-                 \83p\83X\83\8f\81[\83h\82ª\95s\88ê\92v\82È\82ç\8dÄ\93ü\97Í\82·\82é\82©\90q\82Ë\82é\81D\r
-                 (\94j\91¹\82µ\82Ä\82¢\82½\8fê\8d\87\82Í\82³\82¹\82È\82¢)\r
+               /* 2010.02.01 genta マスターパスワードを入力させる\r
+                 -z オプションがあるときは最初だけスキップ\r
+                 -z オプションがないときは,デフォルトパスワードをまず試す\r
+                 LoadRegistry()する\r
+                 パスワードが不一致なら再入力するか尋ねる.\r
+                 (破損していた場合はさせない)\r
                */\r
                if( CheckMasterPassword(lpszCmdLine, PwdBuf))\r
                {\r
@@ -351,26 +462,26 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                        useDefautPassword = 0;\r
                }\r
                else {\r
-                       /* \83p\83X\83\8f\81[\83h\8ew\92è\96³\82µ */\r
+                       /* パスワード指定無し */\r
                        SetMasterPassword( NULL );\r
-                       /* \82±\82Ì\8fê\82Å\82Í\95\\8e¦\82Å\82«\82È\82¢\82Ì\82Å\83t\83\89\83O\82¾\82¯\97§\82Ä\82Ä\82¨\82­*/\r
+                       /* この場では表示できないのでフラグだけ立てておく*/\r
                        useDefautPassword = 2;\r
                }\r
 \r
-               /* \83p\83X\83\8f\81[\83h\83`\83F\83b\83N\82Ì\82Ý\8eÀ\8e{ */\r
+               /* パスワードチェックのみ実施 */\r
                masterpass = 1;\r
                while( ValidateMasterPassword() == YES &&\r
                                GetMasterPasswordStatus() == PASSWORD_UNMATCH ){\r
                        \r
                        if( useDefautPassword != 2 ){\r
-                               /* \8dÄ\83g\83\89\83C\82·\82é\82©\8am\94F */\r
+                               /* 再トライするか確認 */\r
                                if( MessageBox(NULL, MSGJPN304, "FFFTP", MB_YESNO | MB_ICONEXCLAMATION) == IDNO ){\r
-                                       useDefautPassword = 0; /* \95s\88ê\92v\82È\82Ì\82Å\81C\82à\82Í\82â\83f\83t\83H\83\8b\83g\82©\82Ç\82¤\82©\82Í\95ª\82©\82ç\82È\82¢ */\r
+                                       useDefautPassword = 0; /* 不一致なので,もはやデフォルトかどうかは分からない */\r
                                        break;\r
                                }\r
                        }\r
                        \r
-                       /* \8dÄ\93ü\97Í\82³\82¹\82é*/\r
+                       /* 再入力させる*/\r
                        masterpass = EnterMasterPasswordAndSet(masterpasswd_dlg, NULL);\r
                        if( masterpass == 2 ){\r
                                useDefautPassword = 1;\r
@@ -386,22 +497,26 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                \r
                if(masterpass != 0)\r
                {\r
-                       LoadRegistory();\r
+                       LoadRegistry();\r
 \r
-                       // \88Ã\8d\86\89»\92Ê\90M\91Î\89\9e\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
                                LoadRasLib();\r
                        LoadKernelLib();\r
 \r
-                       //\83^\83C\83}\82Ì\90¸\93x\82ð\89ü\91P\r
+                       //タイマの精度を改善\r
                        timeBeginPeriod(1);\r
 \r
                        CountPrevFfftpWindows();\r
 \r
-                       if(MakeAllWindows(cmdShow) == SUCCESS)\r
+                       if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)\r
                        {\r
                                hWndCurFocus = GetLocalHwnd();\r
 \r
@@ -413,7 +528,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                                DispTransferType();\r
                                SetHostKanaCnvImm(YES);\r
                                SetHostKanjiCodeImm(KANJI_NOCNV);\r
-                               // \96{\93\96\82Í\83\8d\81[\83J\83\8b\82Ì\83f\83t\83H\83\8b\83g\82ðUTF-8\82É\82µ\82½\82¢\82ª\8b\8c\83o\81[\83W\83\87\83\93\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ßShift_JIS\82É\90Ý\92è\r
+                               // 本当はローカルのデフォルトをUTF-8にしたいが旧バージョンとの互換性のためShift_JISに設定\r
 //                             SetLocalKanjiCodeImm(KANJI_UTF8N);\r
                                SetLocalKanjiCodeImm(KANJI_SJIS);\r
                                DispListType();\r
@@ -424,14 +539,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                                if(CacheSave == YES)\r
                                        LoadCache();\r
 \r
-                               if(MakeTransferThread() == SUCCESS)\r
+                               if(MakeTransferThread() == FFFTP_SUCCESS)\r
                                {\r
                                        DoPrintf("DEBUG MESSAGE ON ! ##");\r
 \r
                                        DispWindowTitle();\r
-                                       // SourceForge.JP\82É\82æ\82é\83t\83H\81[\83N\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 Hiromichi Matsushima, Suguru Kawamoto.");\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
@@ -455,14 +570,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                                        DispTransferFiles();\r
 \r
                                        StartupProc(lpszCmdLine);\r
-                                       sts = SUCCESS;\r
+                                       sts = FFFTP_SUCCESS;\r
 \r
-                                       /* \83Z\83L\83\85\83\8a\83e\83B\8cx\8d\90\95\82Ì\95\\8e¦ */\r
+                                       /* セキュリティ警告文の表示 */\r
                                        if( useDefautPassword ){\r
                                                SetTaskMsg(MSGJPN300);\r
                                        }\r
                                        \r
-                                       /* \83p\83X\83\8f\81[\83h\95s\88ê\92v\8cx\8d\90\95\82Ì\95\\8e¦ */\r
+                                       /* パスワード不一致警告文の表示 */\r
                                        switch( GetMasterPasswordStatus() ){\r
                                        case PASSWORD_UNMATCH:\r
                                                SetTaskMsg(MSGJPN301);\r
@@ -478,7 +593,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                }\r
        }\r
 \r
-       // \88Ã\8d\86\89»\92Ê\90M\91Î\89\9e\r
+       // 暗号化通信対応\r
 #ifdef USE_OPENSSL\r
        if(IsOpenSSLLoaded())\r
                SetTaskMsg(MSGJPN318);\r
@@ -486,21 +601,21 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
                SetTaskMsg(MSGJPN319);\r
 #endif\r
 \r
-       if(sts == FAIL)\r
+       if(sts == FFFTP_FAIL)\r
                DeleteAllObject();\r
 \r
        return(sts);\r
 }\r
 \r
 \r
-/*----- \83E\83C\83\93\83h\83E\82ð\8dì\90¬\82·\82é --------------------------------------------------\r
+/*----- ウインドウを作成する --------------------------------------------------\r
 *\r
 *      Parameter\r
-*              int cmdShow : \8dÅ\8f\89\82É\95\\8e¦\82·\82é\83E\83C\83\93\83h\83E\82Ì\8c`\8e®\81B\r
+*              int cmdShow : 最初に表示するウインドウの形式。\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int MakeAllWindows(int cmdShow)\r
@@ -516,7 +631,7 @@ static int MakeAllWindows(int cmdShow)
        int StsLvtips;\r
        int StsSocket;\r
 \r
-       /*===== \83\81\83C\83\93\83E\83C\83\93\83h\83E =====*/\r
+       /*===== メインウインドウ =====*/\r
 \r
        RootColorBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));\r
 \r
@@ -539,13 +654,7 @@ static int MakeAllWindows(int cmdShow)
                WinPosX = CW_USEDEFAULT;\r
                WinPosY = 0;\r
        }\r
-       // UTF-8\91Î\89\9e\r
-       // \83\86\81[\83U\81[\92è\8b`\82Ì\83N\83\89\83X\82Í\83f\83t\83H\83\8b\83g\82ÌWNDPROC\82ªShift_JIS\90ê\97p\82Ì\82½\82ß\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
@@ -560,21 +669,21 @@ static int MakeAllWindows(int cmdShow)
                        MoveWindow(hWndFtp, Rect2.left, Rect2.top, WinWidth, WinHeight, FALSE);\r
                }\r
 \r
-               /*===== \83X\83e\83C\83^\83X\83o\81[ =====*/\r
+               /*===== ステイタスバー =====*/\r
 \r
                StsSbar = MakeStatusBarWindow(hWndFtp, hInstFtp);\r
 \r
                CalcWinSize();\r
 \r
-               /*===== \83c\81[\83\8b\83o\81[ =====*/\r
+               /*===== ツールバー =====*/\r
 \r
                StsTbar = MakeToolBarWindow(hWndFtp, hInstFtp);\r
 \r
-               /*===== \83t\83@\83C\83\8b\83\8a\83X\83g\83E\83C\83\93\83h\83E =====*/\r
+               /*===== ファイルリストウインドウ =====*/\r
 \r
                StsList = MakeListWin(hWndFtp, hInstFtp);\r
 \r
-               /*==== \83^\83X\83N\83E\83C\83\93\83h\83E ====*/\r
+               /*==== タスクウインドウ ====*/\r
 \r
                StsTask = MakeTaskWindow(hWndFtp, hInstFtp);\r
 \r
@@ -584,39 +693,39 @@ static int MakeAllWindows(int cmdShow)
 \r
                ShowWindow(hWndFtp, cmdShow);\r
 \r
-               /*==== \83\\83P\83b\83g\83E\83C\83\93\83h\83E ====*/\r
+               /*==== ソケットウインドウ ====*/\r
 \r
                StsSocket = MakeSocketWin(hWndFtp, hInstFtp);\r
 \r
                StsLvtips = InitListViewTips(hWndFtp, hInstFtp);\r
        }\r
 \r
-       Sts = SUCCESS;\r
+       Sts = FFFTP_SUCCESS;\r
        if((hWndFtp == NULL) ||\r
-          (StsTbar == FAIL) ||\r
-          (StsList == FAIL) ||\r
-          (StsSbar == FAIL) ||\r
-          (StsTask == FAIL) ||\r
-          (StsLvtips == FAIL) ||\r
-          (StsSocket == FAIL))\r
+          (StsTbar == FFFTP_FAIL) ||\r
+          (StsList == FFFTP_FAIL) ||\r
+          (StsSbar == FFFTP_FAIL) ||\r
+          (StsTask == FFFTP_FAIL) ||\r
+          (StsLvtips == FFFTP_FAIL) ||\r
+          (StsSocket == FFFTP_FAIL))\r
        {\r
-               Sts = FAIL;\r
+               Sts = FFFTP_FAIL;\r
        }\r
 \r
-       if(Sts == SUCCESS)\r
+       if(Sts == FFFTP_SUCCESS)\r
                SetListViewType();\r
 \r
        return(Sts);\r
 }\r
 \r
 \r
-/*----- \83E\83C\83\93\83h\83E\82Ì\83^\83C\83g\83\8b\82ð\95\\8e¦\82·\82é ----------------------------------------\r
+/*----- ウインドウのタイトルを表示する ----------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void DispWindowTitle(void)\r
@@ -633,13 +742,13 @@ void DispWindowTitle(void)
 }\r
 \r
 \r
-/*----- \91S\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dí\8f\9c ----------------------------------------------\r
+/*----- 全てのオブジェクトを削除 ----------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void DeleteAllObject(void)\r
@@ -649,13 +758,13 @@ static void DeleteAllObject(void)
 //move to WM_DESTROY\r
        WSACleanup();\r
 \r
-//test \83V\83X\83e\83\80\94C\82¹\r
+//test システム任せ\r
 //     if(ListFont != NULL)\r
 //             DeleteObject(ListFont);\r
 //     if(RootColorBrush != NULL)\r
 //             DeleteObject(RootColorBrush);\r
 \r
-//test \83V\83X\83e\83\80\94C\82¹\r
+//test システム任せ\r
 //     DeleteListViewTips();\r
 //     DeleteListWin();\r
 //     DeleteStatusBarWindow();\r
@@ -675,13 +784,13 @@ static void DeleteAllObject(void)
 }\r
 \r
 \r
-/*----- \83\81\83C\83\93\83E\83C\83\93\83h\83E\82Ì\83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\82ð\95Ô\82· ----------------------------\r
+/*----- メインウインドウのウインドウハンドルを返す ----------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              HWND \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
+*              HWND ウインドウハンドル\r
 *----------------------------------------------------------------------------*/\r
 \r
 HWND GetMainHwnd(void)\r
@@ -690,13 +799,13 @@ HWND GetMainHwnd(void)
 }\r
 \r
 \r
-/*----- \8c»\8dÝ\83t\83H\81[\83J\83X\82ª\82 \82é\83E\83C\83\93\83h\83E\82Ì\83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\82ð\95Ô\82· --------------\r
+/*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              HWND \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
+*              HWND ウインドウハンドル\r
 *----------------------------------------------------------------------------*/\r
 \r
 HWND GetFocusHwnd(void)\r
@@ -705,13 +814,13 @@ HWND GetFocusHwnd(void)
 }\r
 \r
 \r
-/*----- \8c»\8dÝ\83t\83H\81[\83J\83X\82ª\82 \82é\83E\83C\83\93\83h\83E\82Ì\82ð\83Z\83b\83g\82·\82é --------------------------\r
+/*----- 現在フォーカスがあるウインドウのをセットする --------------------------\r
 *\r
 *      Parameter\r
-*              HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
+*              HWND hWnd : ウインドウハンドル\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void SetFocusHwnd(HWND hWnd)\r
@@ -721,13 +830,13 @@ void SetFocusHwnd(HWND hWnd)
 }\r
 \r
 \r
-/*----- \83v\83\8d\83O\83\89\83\80\82Ì\83C\83\93\83X\83^\83\93\83X\82ð\95Ô\82· ----------------------------------------\r
+/*----- プログラムのインスタンスを返す ----------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              HINSTANCE \83C\83\93\83X\83^\83\93\83X\r
+*              HINSTANCE インスタンス\r
 *----------------------------------------------------------------------------*/\r
 \r
 HINSTANCE GetFtpInst(void)\r
@@ -736,37 +845,59 @@ HINSTANCE GetFtpInst(void)
 }\r
 \r
 \r
-/*----- \83\81\83C\83\93\83E\83C\83\93\83h\83E\82Ì\83\81\83b\83Z\81[\83W\8f\88\97\9d --------------------------------------\r
+/*----- メインウインドウのメッセージ処理 --------------------------------------\r
 *\r
 *      Parameter\r
-*              HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
-*              UINT message  : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
-*              WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
-*              LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
+*              HWND hWnd : ウインドウハンドル\r
+*              UINT message  : メッセージ番号\r
+*              WPARAM wParam : メッセージの WPARAM 引数\r
+*              LPARAM lParam : メッセージの LPARAM 引数\r
 *\r
 *      Return Value\r
-*              \83\81\83b\83Z\81[\83W\82É\91Î\89\9e\82·\82é\96ß\82è\92l\r
+*              メッセージに対応する戻り値\r
 *----------------------------------------------------------------------------*/\r
 \r
 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\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
@@ -787,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
@@ -825,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
@@ -837,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
@@ -905,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
@@ -1003,17 +1165,21 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        DispTransferType();\r
                                        CheckHistoryNum(0);\r
                                        SetAllHistoryToMenu();\r
-                                       // \88Ã\8d\86\89»\92Ê\90M\91Î\89\9e\r
+                                       // 暗号化通信対応\r
                                        SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
                                        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
@@ -1062,11 +1228,12 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        DispTransferType();\r
                                        break;\r
 \r
-                               // UTF-8\91Î\89\9e\r
+                               // UTF-8対応\r
                                case MENU_KNJ_SJIS :\r
                                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
@@ -1075,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
@@ -1083,9 +1251,11 @@ 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() == SUCCESS)\r
+                                       if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
                                                GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
                                        SuppressRefresh = 0;\r
                                        break;\r
@@ -1107,8 +1277,10 @@ 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() == SUCCESS)\r
+                                       if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
                                                GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
                                        SuppressRefresh = 0;\r
                                        break;\r
@@ -1135,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
@@ -1171,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
@@ -1187,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
@@ -1203,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
@@ -1211,7 +1387,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
                                        if( GetMasterPasswordStatus() != PASSWORD_OK )\r
                                        {\r
-                                               /* \8b­\90§\93I\82É\90Ý\92è\82·\82é\82©\8am\94F */\r
+                                               /* 強制的に設定するか確認 */\r
                                                if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
                                                        break;\r
                                                }\r
@@ -1251,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
@@ -1259,7 +1441,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                        }\r
                                        break;\r
                        }\r
-// \8fí\82É\83z\83X\83g\82©\83\8d\81[\83J\83\8b\82Ö\83t\83H\81[\83J\83X\82ð\88Ú\93®\r
+// 常にホストかローカルへフォーカスを移動\r
 //                     SetFocus(hWndCurFocus);\r
                        MakeButtonsFocus();\r
                        break;\r
@@ -1267,9 +1449,14 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                case WM_NOTIFY :\r
                        switch(((LPNMHDR)lParam)->code)\r
                        {\r
-                               /* \83c\81[\83\8b\83`\83b\83v\83R\83\93\83g\83\8d\81[\83\8b\83\81\83b\83Z\81[\83W\82Ì\8f\88\97\9d */\r
-                               case TTN_NEEDTEXT:\r
+                               /* ツールチップコントロールメッセージの処理 */\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
@@ -1288,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
@@ -1359,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
@@ -1379,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
@@ -1391,15 +1594,14 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
                                                        lpttt->lpszText = MSGJPN176;\r
                                                        break;\r
                                        }\r
-                                       // UTF-8\82©\82çShift_JIS\82Ö\95Ï\8a·\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
@@ -1407,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
@@ -1414,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
@@ -1505,13 +1711,13 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 }\r
 \r
 \r
-/*----- \83v\83\8d\83O\83\89\83\80\8aJ\8en\8e\9e\82Ì\8f\88\97\9d ------------------------------------------------\r
+/*----- プログラム開始時の処理 ------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char *Cmd : \83R\83}\83\93\83h\83\89\83C\83\93\95\8e\9a\97ñ\r
+*              char *Cmd : コマンドライン文字列\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void StartupProc(char *Cmd)\r
@@ -1571,18 +1777,18 @@ static void StartupProc(char *Cmd)
 }\r
 \r
 \r
-/*----- \83R\83}\83\93\83h\83\89\83C\83\93\82ð\89ð\90Í --------------------------------------------------\r
+/*----- コマンドラインを解析 --------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char *Str : \83R\83}\83\93\83h\83\89\83C\83\93\95\8e\9a\97ñ\r
-*              int *AutoConnect : \90Ú\91±\83z\83X\83g\94Ô\8d\86\82ð\95Ô\82·\83\8f\81[\83N\r
-*              int *CmdOption : \83I\83v\83V\83\87\83\93\82ð\95Ô\82·\83\8f\81[\83N\r
-*              char *unc : unc\82ð\95Ô\82·\83\8f\81[\83N\r
-*              int Max : unc\82Ì\8dÅ\91å\92·\r
+*              char *Str : コマンドライン文字列\r
+*              int *AutoConnect : 接続ホスト番号を返すワーク\r
+*              int *CmdOption : オプションを返すワーク\r
+*              char *unc : uncを返すワーク\r
+*              int Max : uncã\81®æ\9c\80大é\95·\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      0=\8ew\92è\82È\82µ\81A1=URL\8ew\92è\81A2=\90Ý\92è\96¼\8ew\92è\81A-1=\83G\83\89\81[\r
+*              int ステータス\r
+*                      0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
 *\r
 *      Note\r
 *              -m      --mirror\r
@@ -1599,10 +1805,10 @@ static void StartupProc(char *Cmd)
 *              -k      --kana\r
 *              -u      --eucname\r
 *              -i      --jisname\r
-*              -n  --ini               (CheckIniFileName\82Å\8c\9f\8dõ)\r
+*              -n  --ini               (CheckIniFileNameで検索)\r
 *                      --saveoff\r
 *                      --saveon\r
-*              -z      --mpasswd       (CheckMasterPassword\82Å\8c\9f\8dõ)     2010.01.30 genta \92Ç\89Á\r
+*              -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
@@ -1695,6 +1901,24 @@ static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc
                        {\r
                                hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
                        }\r
+                       // プロセス保護\r
+#ifdef ENABLE_PROCESS_PROTECTION\r
+                       else if(strcmp(Tmp, "--restart") == 0)\r
+                       {\r
+                       }\r
+                       else if(strcmp(Tmp, "--protect") == 0)\r
+                       {\r
+                       }\r
+                       else if(strcmp(Tmp, "--protect-high") == 0)\r
+                       {\r
+                       }\r
+                       else if(strcmp(Tmp, "--protect-medium") == 0)\r
+                       {\r
+                       }\r
+                       else if(strcmp(Tmp, "--protect-low") == 0)\r
+                       {\r
+                       }\r
+#endif\r
                        else\r
                        {\r
                                SetTaskMsg(MSGJPN180, Tmp);\r
@@ -1719,15 +1943,15 @@ static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc
 }\r
 \r
 \r
-/*----- INI\83t\83@\83C\83\8b\82Ì\83p\83X\96¼\82Ì\8ew\92è\82ð\83`\83F\83b\83N ------------------------------------\r
+/*----- INIファイルのパス名の指定をチェック ------------------------------------\r
 *\r
 *      Parameter\r
-*              char *Str : \83R\83}\83\93\83h\83\89\83C\83\93\95\8e\9a\97ñ\r
-*              char *Ini : ini\83t\83@\83C\83\8b\96¼\82ð\95Ô\82·\83\8f\81[\83N\r
+*              char *Str : コマンドライン文字列\r
+*              char *Ini : iniファイル名を返すワーク\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      0=\8ew\92è\82È\82µ\81A1=\82 \82è\r
+*              int ステータス\r
+*                      0=指定なし、1=あり\r
 *\r
 *      Note\r
 *              -n  --ini\r
@@ -1738,25 +1962,25 @@ static int CheckIniFileName(char *Str, char *Ini)
        return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
 }\r
 \r
-/* \83}\83X\83^\81[\83p\83X\83\8f\81[\83h\82Ì\8ew\92è\82ð\83`\83F\83b\83N */\r
+/* マスターパスワードの指定をチェック */\r
 static int CheckMasterPassword(char *Str, char *Ini)\r
 {\r
        return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
 }\r
 \r
-/*----- \83I\83v\83V\83\87\83\93\82Ì\8cã\82ë\82Ì\83g\81[\83N\83\93\82ð\8eæ\82è\8fo\82· ------------------------------------\r
+/*----- オプションの後ろのトークンを取り出す ------------------------------------\r
 *\r
 *      Parameter\r
-*              char *Str : \83R\83}\83\93\83h\83\89\83C\83\93\95\8e\9a\97ñ\r
-*              char *Result : \8eæ\82è\8fo\82µ\82½\95\8e\9a\97ñ\82ð\8ai\94[\82·\82é\83\8f\81[\83N\r
-*              const char* Opt1, *Opt2: \83I\83v\83V\83\87\83\93\95\8e\9a\97ñ(2\82Â)\r
+*              char *Str : コマンドライン文字列\r
+*              char *Result : 取り出した文字列を格納するワーク\r
+*              const char* Opt1, *Opt2: オプション文字列(2つ)\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      0=\8ew\92è\82È\82µ\81A1=\82 \82è\r
+*              int ステータス\r
+*                      0=指定なし、1=あり\r
 *\r
 *      Note\r
-*              2010.01.30 genta \83}\83X\83^\81[\83p\83X\83\8f\81[\83h\8eæ\82è\8fo\82µ\82Ì\82½\82ß\8b¤\92Ê\89»\r
+*              2010.01.30 genta マスターパスワード取り出しのため共通化\r
 *----------------------------------------------------------------------------*/\r
 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
 {\r
@@ -1780,15 +2004,15 @@ static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const
        return(Ret);\r
 }\r
 \r
-/*----- \83g\81[\83N\83\93\82ð\95Ô\82· --------------------------------------------------------\r
+/*----- トークンを返す --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char *Str : \95\8e\9a\97ñ\r
-*              char *Buf : \95\8e\9a\97ñ\82ð\95Ô\82·\83o\83b\83t\83@\r
+*              char *Str : 文字列\r
+*              char *Buf : 文字列を返すバッファ\r
 *\r
 *      Return Value\r
-*              char *\95Ô\82µ\82½\83g\81[\83N\83\93\82Ì\96\96\94ö\r
-*                      NULL=\8fI\82í\82è\r
+*              char *返したトークンの末尾\r
+*                      NULL=終わり\r
 *----------------------------------------------------------------------------*/\r
 \r
 static char *GetToken(char *Str, char *Buf)\r
@@ -1830,17 +2054,20 @@ static char *GetToken(char *Str, char *Buf)
 }\r
 \r
 \r
-/*----- \83v\83\8d\83O\83\89\83\80\8fI\97¹\8e\9e\82Ì\8f\88\97\9d ------------------------------------------------\r
+/*----- プログラム終了時の処理 ------------------------------------------------\r
 *\r
 *      Parameter\r
-*              HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
+*              HWND hWnd : ウインドウハンドル\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void ExitProc(HWND hWnd)\r
 {\r
+       // 環境依存の不具合対策\r
+       char Tmp[FMAX_PATH+1];\r
+\r
        CancelFlg = YES;\r
 \r
        CloseTransferThread();\r
@@ -1859,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
@@ -1869,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
@@ -1879,15 +2114,15 @@ static void ExitProc(HWND hWnd)
 }\r
 \r
 \r
-/*----- \83t\83@\83C\83\8b\96¼\82ð\83_\83u\83\8b\83N\83\8a\83b\83N\82µ\82½\82Æ\82«\82Ì\8f\88\97\9d ------------------------------\r
+/*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
 *\r
 *      Parameter\r
-*              int Win : \83E\83C\83\93\83h\83E\94Ô\8d\86 (WIN_xxx)\r
-*              int Mode : \8fí\82É\81u\8aJ\82­\81v\93®\8dì\82ð\82·\82é\82©\82Ç\82¤\82© (YES/NO)\r
-*              int App : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\94Ô\8d\86\81i-1=\8aÖ\98A\82Ã\82¯\97D\90æ\81j\r
+*              int Win : ウインドウ番号 (WIN_xxx)\r
+*              int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
+*              int App : アプリケーション番号(-1=関連づけ優先)\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void DoubleClickProc(int Win, int Mode, int App)\r
@@ -1912,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
@@ -1928,13 +2165,13 @@ void DoubleClickProc(int Win, int Mode, int App)
                                        else\r
                                                ChangeDir(WIN_LOCAL, Tmp);\r
                                }\r
-                               else if(CheckClosedAndReconnect() == SUCCESS)\r
+                               else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
                                {\r
                                        if((App != -1) || (Type == NODE_FILE))\r
                                        {\r
                                                if((DclickOpen == YES) || (Mode == YES))\r
                                                {\r
-                                                       // \83r\83\85\81[\83\8f\82Q\81A\82R\82Ì\83p\83X\82ª "d " \82Å\8en\82Ü\82Á\82Ä\82¢\82½\82ç\8d·\95ª\83r\83\85\81[\83A\8eg\97p\r
+                                                       // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
                                                        if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
                                                                UseDiffViewer = YES;\r
                                                        else\r
@@ -1942,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
@@ -1982,13 +2223,15 @@ void DoubleClickProc(int Win, int Mode, int App)
 \r
                                                        DisableUserOpe();\r
 \r
-                                                       /* \95s\90³\82È\83p\83X\82ð\8c\9f\8fo */\r
+                                                       /* 不正なパスを検出 */\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
@@ -2021,17 +2264,17 @@ void DoubleClickProc(int Win, int Mode, int App)
 }\r
 \r
 \r
-/*----- \83t\83H\83\8b\83_\82Ì\88Ú\93® --------------------------------------------------------\r
+/*----- フォルダの移動 --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              int Win : \83E\83C\83\93\83h\83E\94Ô\8d\86 (WIN_xxx)\r
-*              char *Path : \88Ú\93®\90æ\82Ì\83p\83X\96¼\r
+*              int Win : ウインドウ番号 (WIN_xxx)\r
+*              char *Path : 移動先のパス名\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Note\r
-*              \83t\83H\83\8b\83_\93¯\8e\9e\88Ú\93®\82Ì\8f\88\97\9d\82à\8ds\82¤\r
+*              フォルダ同時移動の処理も行う\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void ChangeDir(int Win, char *Path)\r
@@ -2040,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
@@ -2054,16 +2302,16 @@ static void ChangeDir(int Win, char *Path)
 \r
        if((Win == WIN_LOCAL) || (Sync == YES))\r
        {\r
-               if(DoLocalCWD(Path) == SUCCESS)\r
+               if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
                        GetLocalDirForWnd();\r
        }\r
 \r
        if((Win == WIN_REMOTE) || (Sync == YES))\r
        {\r
-               if(CheckClosedAndReconnect() == SUCCESS)\r
+               if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
                {\r
 #if defined(HAVE_OPENVMS)\r
-                       /* OpenVMS\82Ì\8fê\8d\87\81A".DIR;?"\82ð\8eæ\82é */\r
+                       /* OpenVMSの場合、".DIR;?"を取る */\r
                        if (AskHostType() == HTYPE_VMS)\r
                                ReformVMSDirName(Path, TRUE);\r
 #endif\r
@@ -2071,17 +2319,19 @@ static void ChangeDir(int Win, char *Path)
                                GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
                }\r
        }\r
+       // デッドロック対策\r
+       EnableUserOpe();\r
        return;\r
 }\r
 \r
 \r
-/*----- \83E\83C\83\93\83h\83E\82Ì\83T\83C\83Y\95Ï\8dX\82Ì\8f\88\97\9d ------------------------------------------\r
+/*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void ResizeWindowProc(void)\r
@@ -2134,13 +2384,13 @@ static void ResizeWindowProc(void)
 }\r
 \r
 \r
-/*----- \83E\83C\83\93\83h\83E\82Ì\8ae\95\94\95ª\82Ì\83T\83C\83Y\82ð\8cv\8eZ\82·\82é ----------------------------------\r
+/*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void CalcWinSize(void)\r
@@ -2174,13 +2424,13 @@ static void CalcWinSize(void)
 \r
 \r
 #if 0\r
-/*----- \83E\83C\83\93\83h\83E\82Ì\95\\8e¦\88Ê\92u\82ð\8eæ\93¾\82·\82é ----------------------------------------\r
+/*----- ウインドウの表示位置を取得する ----------------------------------------\r
 *\r
 *      Parameter\r
-*              HWND hWnd : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
+*              HWND hWnd : ウインドウハンドル\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void AskWindowPos(HWND hWnd)\r
@@ -2197,15 +2447,15 @@ static void AskWindowPos(HWND hWnd)
 #endif\r
 \r
 \r
-/*----- \83f\83B\83\8c\83N\83g\83\8a\83\8a\83X\83g\82Æ\83t\83@\83C\83\8b\83\8a\83X\83g\82Ì\8b«\8aE\95Ï\8dX\8f\88\97\9d ----------------------\r
+/*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
 *\r
 *      Parameter\r
-*              WPARAM Keys : WM_MOUSEMOVE\82È\82Ç\82ÌWPARAM\82Ì\92l\r
-*              int x : \83}\83E\83X\83J\81[\83\\83\8b\82Ì\82w\8dÀ\95W\r
-*              int y : \83}\83E\83X\83J\81[\83\\83\8b\82Ì\82x\8dÀ\95W\r
+*              WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
+*              int x : マウスカーソルのX座標\r
+*              int y : マウスカーソルのY座標\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
@@ -2218,7 +2468,7 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
                if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
                   (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
                {\r
-                       /* \8b«\8aE\88Ê\92u\95Ï\8dX\97p\83J\81[\83\\83\8b\82É\95Ï\8dX */\r
+                       /* 境界位置変更用カーソルに変更 */\r
                        SetCapture(hWndFtp);\r
                        hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
                        SetCursor(hCursor);\r
@@ -2227,7 +2477,7 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
                }\r
                else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
                {\r
-                       /* \8b«\8aE\88Ê\92u\95Ï\8dX\97p\83J\81[\83\\83\8b\82É\95Ï\8dX */\r
+                       /* 境界位置変更用カーソルに変更 */\r
                        SetCapture(hWndFtp);\r
                        hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
                        SetCursor(hCursor);\r
@@ -2239,7 +2489,7 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
        {\r
                if(Keys & MK_LBUTTON)\r
                {\r
-                       /* \8b«\8aE\88Ê\92u\95Ï\8dX\8aJ\8en */\r
+                       /* 境界位置変更開始 */\r
                        Resizing = RESIZE_ON;\r
                        GetWindowRect(hWndFtp, &Rect);\r
                        GetClientRect(GetSbarWnd(), &Rect1);\r
@@ -2257,7 +2507,7 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
                           ((ResizePos == RESIZE_VPOS) &&\r
                                ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
                        {\r
-                               /* \8c³\82Ì\83J\81[\83\\83\8b\82É\96ß\82· */\r
+                               /* 元のカーソルに戻す */\r
                                ReleaseCapture();\r
                                hCursor = LoadCursor(NULL, IDC_ARROW);\r
                                SetCursor(hCursor);\r
@@ -2279,7 +2529,7 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
 \r
                if((Keys & MK_LBUTTON) == 0)\r
                {\r
-                       /* \8b«\8aE\88Ê\92u\95Ï\8dX\8fI\97¹ */\r
+                       /* 境界位置変更終了 */\r
                        ReleaseCapture();\r
                        ClipCursor(NULL);\r
                        hCursor = LoadCursor(NULL, IDC_ARROW);\r
@@ -2291,13 +2541,13 @@ static void CheckResizeFrame(WPARAM Keys, int x, int y)
 }\r
 \r
 \r
-/*----- \83t\83@\83C\83\8b\88ê\97\97\8fî\95ñ\82ð\83r\83\85\81[\83\8f\82Å\95\\8e¦ --------------------------------------\r
+/*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void DispDirInfo(void)\r
@@ -2311,14 +2561,14 @@ static void DispDirInfo(void)
 \r
 \r
 \r
-/*----- \83r\83\85\81[\83\8f\82ð\8bN\93® --------------------------------------------------------\r
+/*----- ビューワを起動 --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char Fname : \83t\83@\83C\83\8b\96¼\r
-*              int App : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\94Ô\8d\86\81i-1=\8aÖ\98A\82Ã\82¯\97D\90æ\81j\r
+*              char Fname : ファイル名\r
+*              int App : アプリケーション番号(-1=関連づけ優先)\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void ExecViewer(char *Fname, int App)\r
@@ -2328,18 +2578,30 @@ 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()\82Í\8aÖ\98A\95t\82¯\82ç\82ê\82½\83v\83\8d\83O\83\89\83\80\82Ì\83p\83X\96¼\82É\83X\83y\81[\83X\82ª       */\r
-       /* \8aÜ\82Ü\82ê\82Ä\82¢\82é\8e\9e\81A\8aÔ\88á\82Á\82½\83p\83X\96¼\82ð\95Ô\82·\8e\96\82ª\82 \82é\81B                                       */\r
-       /* \82»\82±\82Å\81A\8aÖ\98A\95t\82¯\82ç\82ê\82½\83v\83\8d\83O\83\89\83\80\82Ì\8bN\93®\82ÍShellExecute()\82ð\8eg\82¤\81B       */\r
+       /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
+       /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
+       /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
 \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
@@ -2355,25 +2617,41 @@ 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
 }\r
 \r
 \r
-/*----- \8d·\95ª\95\\8e¦\83r\83\85\81[\83\8f\82ð\8bN\93® ------------------------------------------------\r
+/*----- 差分表示ビューワを起動 ------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char Fname1 : \83t\83@\83C\83\8b\96¼\r
-*              char Fname2 : \83t\83@\83C\83\8b\96¼2\r
-*              int App : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\94Ô\8d\86\81i2 or 3\81j\r
+*              char Fname1 : ファイル名\r
+*              char Fname2 : ファイル名2\r
+*              int App : アプリケーション番号(2 or 3)\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void ExecViewer2(char *Fname1, char *Fname2, int App)\r
@@ -2383,14 +2661,16 @@ 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()\82Í\8aÖ\98A\95t\82¯\82ç\82ê\82½\83v\83\8d\83O\83\89\83\80\82Ì\83p\83X\96¼\82É\83X\83y\81[\83X\82ª       */\r
-       /* \8aÜ\82Ü\82ê\82Ä\82¢\82é\8e\9e\81A\8aÔ\88á\82Á\82½\83p\83X\96¼\82ð\95Ô\82·\8e\96\82ª\82 \82é\81B                                       */\r
-       /* \82»\82±\82Å\81A\8aÖ\98A\95t\82¯\82ç\82ê\82½\83v\83\8d\83O\83\89\83\80\82Ì\8bN\93®\82ÍShellExecute()\82ð\8eg\82¤\81B       */\r
+       /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
+       /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
+       /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
 \r
        AskLocalCurDir(CurDir, FMAX_PATH);\r
 \r
-       strcpy(AssocProg, ViewerName[App] + 2); /* \90æ\93ª\82Ì "d " \82Í\93Ç\82Ý\94ò\82Î\82· */\r
+       strcpy(AssocProg, ViewerName[App] + 2); /* 先頭の "d " は読み飛ばす */\r
 \r
        if(strchr(Fname1, ' ') == NULL && strchr(Fname2, ' ') == NULL)\r
                sprintf(ComLine, "%s %s %s", AssocProg, Fname1, Fname2);\r
@@ -2402,23 +2682,39 @@ 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
 }\r
 \r
 \r
-/*----- \83e\83\93\83|\83\89\83\8a\83t\83@\83C\83\8b\96¼\82ð\83e\83\93\83|\83\89\83\8a\83t\83@\83C\83\8b\83\8a\83X\83g\82É\92Ç\89Á ------------------\r
+/*----- テンポラリファイル名をテンポラリファイルリストに追加 ------------------\r
 *\r
 *      Parameter\r
-*              char *Fname : \83e\83\93\83|\83\89\83\8a\83t\83@\83C\83\8b\96¼\r
+*              char *Fname : テンポラリファイル名\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void AddTempFileList(char *Fname)\r
@@ -2443,13 +2739,13 @@ void AddTempFileList(char *Fname)
 }\r
 \r
 \r
-/*----- \83e\83\93\83|\83\89\83\8a\83t\83@\83C\83\8b\83\8a\83X\83g\82É\93o\98^\82³\82ê\82Ä\82¢\82é\83t\83@\83C\83\8b\82ð\91S\82Ä\8dí\8f\9c ------------\r
+/*----- テンポラリファイルリストに登録されているファイルを全て削除 ------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void DeleteAlltempFile(void)\r
@@ -2468,26 +2764,28 @@ static void DeleteAlltempFile(void)
                Pos = Next;\r
        }\r
 \r
-       // OLE D&D\82Ì\83e\83\93\83|\83\89\83\8a\82ð\8dí\8f\9c\82·\82é (2007.9.11 yutaka)\r
+       // OLE D&Dのテンポラリを削除する (2007.9.11 yutaka)\r
        doDeleteRemoteFile();\r
 \r
        return;\r
 }\r
 \r
 \r
-/*----- \82`\82\82\82\8f\82\95\82\94\83_\83C\83A\83\8d\83O\83{\83b\83N\83X\82Ì\83R\81[\83\8b\83o\83b\83N\8aÖ\90\94 ------------------------\r
+/*----- Aboutダイアログボックスのコールバック関数 ------------------------\r
 *\r
 *      Parameter\r
-*              HWND hDlg : \83E\83C\83\93\83h\83E\83n\83\93\83h\83\8b\r
-*              UINT message : \83\81\83b\83Z\81[\83W\94Ô\8d\86\r
-*              WPARAM wParam : \83\81\83b\83Z\81[\83W\82Ì WPARAM \88ø\90\94\r
-*              LPARAM lParam : \83\81\83b\83Z\81[\83W\82Ì LPARAM \88ø\90\94\r
+*              HWND hDlg : ウインドウハンドル\r
+*              UINT message : メッセージ番号\r
+*              WPARAM wParam : メッセージの WPARAM 引数\r
+*              LPARAM lParam : メッセージの LPARAM 引数\r
 *\r
 *      Return Value\r
 *              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
@@ -2519,13 +2817,13 @@ static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPA
 }\r
 \r
 \r
-/*----- \83T\83E\83\93\83h\82ð\96Â\82ç\82· ------------------------------------------------------\r
+/*----- サウンドを鳴らす ------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              Int num : \83T\83E\83\93\83h\82Ì\8eí\97Þ (SND_xxx)\r
+*              Int num : サウンドの種類 (SND_xxx)\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void SoundPlay(int Num)\r
@@ -2537,13 +2835,13 @@ void SoundPlay(int Num)
 }\r
 \r
 \r
-/*----- \83w\83\8b\83v\83t\83@\83C\83\8b\82Ì\83p\83X\96¼\82ð\95Ô\82· ------------------------------------------\r
+/*----- ヘルプファイルのパス名を返す ------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83p\83X\96¼\r
+*              char *パス名\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskHelpFilePath(void)\r
@@ -2552,13 +2850,13 @@ char *AskHelpFilePath(void)
 }\r
 \r
 \r
-/*----- \83e\83\93\83|\83\89\83\8a\83t\83@\83C\83\8b\82Ì\83p\83X\96¼\82ð\95Ô\82· --------------------------------------\r
+/*----- テンポラリファイルのパス名を返す --------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83p\83X\96¼\r
+*              char *パス名\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskTmpFilePath(void)\r
@@ -2567,13 +2865,13 @@ char *AskTmpFilePath(void)
 }\r
 \r
 \r
-/*----- INI\83t\83@\83C\83\8b\82Ì\83p\83X\96¼\82ð\95Ô\82· ---------------------------------------------\r
+/*----- INIファイルのパス名を返す ---------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83p\83X\96¼\r
+*              char *パス名\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskIniFilePath(void)\r
@@ -2581,13 +2879,13 @@ char *AskIniFilePath(void)
        return(IniPath);\r
 }\r
 \r
-/*----- INI\83t\83@\83C\83\8b\82Ì\82Ý\82ð\8eg\82¤\82©\82Ç\82¤\82©\82ð\95Ô\82· -----------------------------------\r
+/*----- INIファイルのみを使うかどうかを返す -----------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X : YES/NO\r
+*              int ステータス : YES/NO\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskForceIni(void)\r
@@ -2598,13 +2896,13 @@ int AskForceIni(void)
 \r
 \r
 \r
-/*----- \83\81\83b\83Z\81[\83W\8f\88\97\9d --------------------------------------------------------\r
+/*----- メッセージ処理 --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \8fI\97¹\83t\83\89\83O (YES=WM_CLOSE\82ª\97\88\82½/NO)\r
+*              int 終了フラグ (YES=WM_CLOSEが来た/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int BackgrndMessageProc(void)\r
@@ -2613,13 +2911,16 @@ int BackgrndMessageProc(void)
        int Ret;\r
 \r
        Ret = NO;\r
-       SendMessage(GetMainHwnd(), WM_NULL, 0, 0);\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
-                       /* \83f\83B\83\8c\83N\83g\83\8a\96¼\82Ì\95\\8e¦\83R\83\93\83{\83{\83b\83N\83X\82ÅBS\82âRET\82ª\8cø\82­\82æ\82¤\82É */\r
-                       /* \83R\83\93\83{\83{\83b\83N\83X\93à\82Å\82Í\83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é */\r
+                       /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
+                       /* コンボボックス内ではアクセラレータを無効にする */\r
                        if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
                           (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
                           ((hHelpWin != NULL) && (Msg.hwnd == hHelpWin)) ||\r
@@ -2641,13 +2942,13 @@ int BackgrndMessageProc(void)
 }\r
 \r
 \r
-/*----- \8e©\93®\8fI\97¹\83t\83\89\83O\82ð\83N\83\8a\83A\82·\82é --------------------------------------------\r
+/*----- 自動終了フラグをクリアする --------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void ResetAutoExitFlg(void)\r
@@ -2657,13 +2958,13 @@ void ResetAutoExitFlg(void)
 }\r
 \r
 \r
-/*----- \8e©\93®\8fI\97¹\83t\83\89\83O\82ð\95Ô\82· --------------------------------------------------\r
+/*----- 自動終了フラグを返す --------------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83t\83\89\83O (YES/NO)\r
+*              int フラグ (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskAutoExit(void)\r
@@ -2671,26 +2972,43 @@ int AskAutoExit(void)
        return(AutoExit);\r
 }\r
 \r
-/*----- \83\86\81[\83U\82É\83p\83X\83\8f\81[\83h\82ð\93ü\97Í\82³\82¹\81C\82»\82ê\82ð\90Ý\92è\82·\82é -----------------------\r
+/*----- ユーザにパスワードを入力させ,それを設定する -----------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int : 0/\83\86\81[\83U\83L\83\83\83\93\83Z\83\8b, 1/\90Ý\92è\82µ\82½, 2/\83f\83t\83H\83\8b\83g\90Ý\92è\r
+*              int : 0/ユーザキャンセル, 1/設定した, 2/デフォルト設定\r
 *----------------------------------------------------------------------------*/\r
 int EnterMasterPasswordAndSet( int Res, HWND hWnd )\r
 {\r
        char buf[MAX_PASSWORD_LEN + 1];\r
+       // パスワードの入力欄を非表示\r
+       // 非表示にしたため新しいパスワードを2回入力させる\r
+       char buf1[MAX_PASSWORD_LEN + 1];\r
        char *p;\r
        int Flag;\r
 \r
        buf[0] = NUL;\r
        if( InputDialogBox(Res, hWnd, NULL, buf, MAX_PASSWORD_LEN + 1,\r
                &Flag, IDH_HELP_TOPIC_0000064) == YES){\r
-               /* \96\96\94ö\82Ì\8bó\94\92\82ð\8dí\8f\9c */\r
+               // パスワードの入力欄を非表示\r
+               if(Res == newmasterpasswd_dlg)\r
+               {\r
+                       buf1[0] = NUL;\r
+                       if( InputDialogBox(Res, hWnd, NULL, buf1, MAX_PASSWORD_LEN + 1,\r
+                               &Flag, IDH_HELP_TOPIC_0000064) != YES){\r
+                               return 0;\r
+                       }\r
+                       if(strcmp(buf, buf1) != 0)\r
+                       {\r
+                               MessageBox(hWnd, MSGJPN325, "FFFTP", MB_OK | MB_ICONERROR);\r
+                               return 0;\r
+                       }\r
+               }\r
+               /* 末尾の空白を削除 */\r
                RemoveTailingSpaces(buf);\r
-               /* \90æ\93ª\82Ì\8bó\94\92\82ð\8dí\8f\9c */\r
+               /* 先頭の空白を削除 */\r
                for( p = buf; *p == ' '; p++ )\r
                        ;\r
                \r
@@ -2699,7 +3017,7 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd )
                        return 1;\r
                }\r
                else {\r
-                       /* \8bó\82Ì\8fê\8d\87\82Í\83f\83t\83H\83\8b\83g\92l\82ð\90Ý\92è */\r
+                       /* 空の場合はデフォルト値を設定 */\r
                        SetMasterPassword( NULL );\r
                        return 2;\r
                }\r
@@ -2707,18 +3025,105 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd )
        return 0;\r
 }\r
 \r
-// \88Ã\8d\86\89»\92Ê\90M\91Î\89\9e\r
-BOOL __stdcall SSLTimeoutCallback()\r
+// 暗号化通信対応\r
+BOOL __stdcall SSLTimeoutCallback(BOOL* pbAborted)\r
 {\r
        Sleep(1);\r
        if(BackgrndMessageProc() == YES)\r
                return TRUE;\r
-       // \94O\82Ì\82½\82ß\83c\81[\83\8b\83o\81[\82ÌMENU_ABORT\82à\8am\94F\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* pbAborted, BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
+{\r
+       BOOL bResult;\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
+       // 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
+               if(pm0 = AllocateStringM(strlen(Certificate) + 1024))\r
+               {\r
+                       sprintf(pm0, MSGJPN326, IsHostNameMatched(AskHostAdrs(), CommonName) ? MSGJPN327 : MSGJPN328, bVerified ? MSGJPN327 : MSGJPN328, Certificate);\r
+                       if(MessageBox(GetMainHwnd(), pm0, "FFFTP", MB_YESNO) == IDYES)\r
+                       {\r
+                               for(i = MAX_CERT_CACHE_HASH - 1; i >= 1; i--)\r
+                                       memcpy(&CertificateCacheHash[i], &CertificateCacheHash[i - 1], 20);\r
+                               memcpy(&CertificateCacheHash[0], &Hash, 20);\r
+                               bResult = TRUE;\r
+                       }\r
+                       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