OSDN Git Service

Fix bugs of displaying icons in the local file list.
[ffftp/ffftp.git] / connect.c
index dfbf5e0..3e17909 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -37,7 +37,7 @@
 #include <time.h>\r
 // IPv6対応\r
 //#include <winsock.h>\r
-#include <ws2tcpip.h>\r
+#include <winsock2.h>\r
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 \r
 \r
 /*===== プロトタイプ =====*/\r
 \r
-static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
-static int SendInitCommand(char *Cmd);\r
+// 64ビット対応\r
+//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+// 同時接続対応\r
+//static int SendInitCommand(char *Cmd);\r
+static int SendInitCommand(SOCKET Socket, char *Cmd, int *CancelCheckWork);\r
 static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List);\r
 static void SaveCurrentSetToHistory(void);\r
 static int ReConnectSkt(SOCKET *Skt);\r
@@ -106,8 +110,6 @@ static int TryConnect = NO;
 static SOCKET CmdCtrlSocket = INVALID_SOCKET;\r
 static SOCKET TrnCtrlSocket = INVALID_SOCKET;\r
 static HOSTDATA CurHost;\r
-// UTF-8対応\r
-static int TmpNameKanjiCode;\r
 \r
 /* 接続中の接続先、SOCKSサーバのアドレス情報を保存しておく */\r
 /* この情報はlistenソケットを取得する際に用いる */\r
@@ -123,6 +125,9 @@ static const struct in6_addr IN6ADDR_NONE = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 static int UseIPadrs;\r
 static char DomainName[HOST_ADRS_LEN+1];\r
 \r
+#if defined(HAVE_TANDEM)\r
+static int Oss = NO;  /* OSS ファイルシステムへアクセスしている場合は YES */\r
+#endif\r
 \r
 \r
 \r
@@ -161,7 +166,9 @@ void ConnectProc(int Type, int Num)
                InitPWDcommand();\r
                CopyHostFromList(AskCurrentHost(), &CurHost);\r
                // UTF-8対応\r
-               TmpNameKanjiCode = CurHost.NameKanjiCode;\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
@@ -187,23 +194,53 @@ void ConnectProc(int Type, int Num)
                        CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
-                       // UTF-8対応\r
-                       if(TmpNameKanjiCode == KANJI_AUTO)\r
+                       if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
-                               if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                               // 暗号化通信対応\r
+                               switch(CurHost.CryptMode)\r
                                {\r
-                                       SetCache(999, "");\r
-                                       TmpNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                               case CRYPT_NONE:\r
+                                       if(CurHost.UseFTPIS != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), CurHost.UseNoEncryption, CurHost.UseFTPES, NO, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_FTPES:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPIS != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, CurHost.UseFTPES, NO, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_FTPIS:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPES != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, NO, CurHost.UseFTPIS, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_SFTP:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPES != NO || CurHost.UseFTPIS != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, NO, NO, CurHost.UseSFTP);\r
+                                       }\r
+                                       break;\r
+                               }\r
+\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
+                               {\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
                                }\r
-                       }\r
 \r
-                       if(CmdCtrlSocket != INVALID_SOCKET)\r
-                       {\r
                                strcpy(TitleHostName, CurHost.HostName);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
-                               SendInitCommand(CurHost.InitCmd);\r
+                               SendInitCommand(CmdCtrlSocket, CurHost.InitCmd, &CancelFlg);\r
 \r
                                if(strlen(CurHost.LocalInitDir) > 0)\r
                                {\r
@@ -256,7 +293,9 @@ void QuickConnectProc(void)
                InitPWDcommand();\r
                CopyDefaultHost(&CurHost);\r
                // UTF-8対応\r
-               TmpNameKanjiCode = CurHost.NameKanjiCode;\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
                if(SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == FFFTP_SUCCESS)\r
                {\r
                        if(strlen(CurHost.UserName) == 0)\r
@@ -281,18 +320,15 @@ void QuickConnectProc(void)
                        CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
-                       // UTF-8対応\r
-                       if(TmpNameKanjiCode == KANJI_AUTO)\r
+                       if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
-                               if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
                                {\r
-                                       SetCache(999, "");\r
-                                       TmpNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
                                }\r
-                       }\r
 \r
-                       if(CmdCtrlSocket != INVALID_SOCKET)\r
-                       {\r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
@@ -329,7 +365,9 @@ void QuickConnectProc(void)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
 {\r
        static char *Buf;\r
        int i;\r
@@ -449,7 +487,9 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                CurHost.NameKanjiCode = Fkanji;\r
                CurHost.KanaCnv = YES;                  /* とりあえず */\r
                // UTF-8対応\r
-               TmpNameKanjiCode = CurHost.NameKanjiCode;\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                SetHostKanaCnvImm(CurHost.KanaCnv);\r
                SetHostKanjiCodeImm(CurHost.KanjiCode);\r
@@ -468,18 +508,15 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                TrnCtrlSocket = CmdCtrlSocket;\r
 \r
-               // UTF-8対応\r
-               if(TmpNameKanjiCode == KANJI_AUTO)\r
+               if(CmdCtrlSocket != INVALID_SOCKET)\r
                {\r
-                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                       // UTF-8対応\r
+                       if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
                        {\r
-                               SetCache(999, "");\r
-                               TmpNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                               if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                       CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
                        }\r
-               }\r
 \r
-               if(CmdCtrlSocket != INVALID_SOCKET)\r
-               {\r
                        strcpy(TitleHostName, CurHost.HostAdrs);\r
                        DispWindowTitle();\r
                        SoundPlay(SND_CONNECT);\r
@@ -536,7 +573,9 @@ void HistoryConnectProc(int MenuCmd)
                InitPWDcommand();\r
                CopyHistoryToHost(&Hist, &CurHost);\r
                // UTF-8対応\r
-               TmpNameKanjiCode = CurHost.NameKanjiCode;\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
@@ -559,23 +598,20 @@ void HistoryConnectProc(int MenuCmd)
                        CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
-                       // UTF-8対応\r
-                       if(TmpNameKanjiCode == KANJI_AUTO)\r
+                       if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
-                               if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
                                {\r
-                                       SetCache(999, "");\r
-                                       TmpNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
                                }\r
-                       }\r
 \r
-                       if(CmdCtrlSocket != INVALID_SOCKET)\r
-                       {\r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
-                               SendInitCommand(CurHost.InitCmd);\r
+                               SendInitCommand(CmdCtrlSocket, CurHost.InitCmd, &CancelFlg);\r
 \r
                                DoLocalCWD(CurHost.LocalInitDir);\r
                                GetLocalDirForWnd();\r
@@ -614,7 +650,9 @@ void HistoryConnectProc(int MenuCmd)
 *                      cmd1\r\ncmd2\r\n\0\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int SendInitCommand(char *Cmd)\r
+// 同時接続対応\r
+//static int SendInitCommand(char *Cmd)\r
+static int SendInitCommand(SOCKET Socket, char *Cmd, int *CancelCheckWork)\r
 {\r
        char Tmp[INITCMD_LEN+1];\r
        char *Pos;\r
@@ -625,7 +663,8 @@ static int SendInitCommand(char *Cmd)
                if((Pos = strchr(Tmp, '\r')) != NULL)\r
                        *Pos = NUL;\r
                if(strlen(Tmp) > 0)\r
-                       DoQUOTE(Tmp);\r
+//                     DoQUOTE(Tmp);\r
+                       DoQUOTE(Socket, Tmp, CancelCheckWork);\r
 \r
                if((Cmd = strchr(Cmd, '\n')) != NULL)\r
                        Cmd++;\r
@@ -719,7 +758,7 @@ int AskHostNameKanji(void)
 //             CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
 //\r
 //     return(CurHost.NameKanjiCode);\r
-       return(TmpNameKanjiCode);\r
+       return(CurHost.CurNameKanjiCode);\r
 }\r
 \r
 \r
@@ -864,6 +903,14 @@ int AskHostType(void)
        if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
                CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
 \r
+#if defined(HAVE_TANDEM)\r
+       /* OSS ファイルシステムは UNIX ファイルシステムと同じでいいので AUTO を返す\r
+          ただし、Guardian ファイルシステムに戻ったときにおかしくならないように\r
+          CurHost.HostType 変数は更新しない */\r
+       if(CurHost.HostType == HTYPE_TANDEM && Oss == YES)\r
+               return(HTYPE_AUTO);\r
+#endif\r
+\r
        return(CurHost.HostType);\r
 }\r
 \r
@@ -1053,11 +1100,18 @@ int ReConnectTrnSkt(SOCKET *Skt, int *CancelCheckWork)
                HostData.UseFTPIS = NO;\r
        if(HostData.CryptMode != CRYPT_SFTP)\r
                HostData.UseSFTP = NO;\r
+       // UTF-8対応\r
+       HostData.CurNameKanjiCode = HostData.NameKanjiCode;\r
+       // IPv6対応\r
+       HostData.CurNetType = HostData.NetType;\r
+       // 同時接続対応\r
+       HostData.NoDisplayUI = YES;\r
        // 暗号化通信対応\r
        // 同時接続対応\r
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
        if((*Skt = DoConnect(&HostData, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, CancelCheckWork)) != INVALID_SOCKET)\r
        {\r
+               SendInitCommand(*Skt, CurHost.InitCmd, CancelCheckWork);\r
 //             AskRemoteCurDir(Path, FMAX_PATH);\r
 //             DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
@@ -1099,6 +1153,7 @@ static int ReConnectSkt(SOCKET *Skt)
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
        if((*Skt = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg)) != INVALID_SOCKET)\r
        {\r
+               SendInitCommand(*Skt, CurHost.InitCmd, &CancelFlg);\r
                AskRemoteCurDir(Path, FMAX_PATH);\r
                DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
@@ -1279,6 +1334,62 @@ int AskConnecting(void)
 }\r
 \r
 \r
+#if defined(HAVE_TANDEM)\r
+/*----- 接続している本当のホストのホストタイプを返す --------------------------\r
+*\r
+*      Parameter\r
+*              なし\r
+*\r
+*      Return Value\r
+*              char *ファイル名/オプション\r
+*----------------------------------------------------------------------------*/\r
+\r
+int AskRealHostType(void)\r
+{\r
+       if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
+               CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+\r
+       return(CurHost.HostType);\r
+}\r
+\r
+/*----- OSS ファイルシステムにアクセスしているかどうかのフラグを変更する ------\r
+*\r
+*      Parameter\r
+*              int ステータス (YES/NO)\r
+*\r
+*      Return Value\r
+*              int ステータス (YES/NO)\r
+*----------------------------------------------------------------------------*/\r
+\r
+int SetOSS(int wkOss)\r
+{\r
+       if(Oss != wkOss) {\r
+               if (wkOss == YES) {\r
+                       strcpy(CurHost.InitCmd, "OSS");\r
+               } else {\r
+                       strcpy(CurHost.InitCmd, "GUARDIAN");\r
+               }\r
+       }\r
+       Oss = wkOss;\r
+       return(Oss);\r
+}\r
+\r
+/*----- OSS ファイルシステムにアクセスしているかどうかを返す ------------------\r
+*\r
+*      Parameter\r
+*              なし\r
+*\r
+*      Return Value\r
+*              int ステータス (YES/NO)\r
+*----------------------------------------------------------------------------*/\r
+\r
+int AskOSS(void)\r
+{\r
+       return(Oss);\r
+}\r
+#endif /* HAVE_TANDEM */\r
+\r
+\r
 /*----- ホストへ接続する ------------------------------------------------------\r
 *\r
 *      Parameter\r
@@ -1465,8 +1576,11 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                else\r
                                                {\r
                                                        Anony = NO;\r
+                                                       // 同時接続対応\r
+//                                                     if((strlen(User) != 0) || \r
+//                                                        (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                        if((strlen(User) != 0) || \r
-                                                          (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                          ((HostData->NoDisplayUI == NO) && (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                        {\r
                                                                if(Anony == YES)\r
                                                                {\r
@@ -1509,6 +1623,18 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                Sts = FTP_ERROR;\r
                                                                }\r
 \r
+                                                               // FTPIS対応\r
+                                                               // "PBSZ 0"と"PROT P"は黙示的に設定されているはずだが念のため\r
+                                                               if(CryptMode == CRYPT_FTPIS)\r
+                                                               {\r
+                                                                       if((Sts = command(ContSock, Reply, CancelCheckWork, "PBSZ 0")) == 200)\r
+                                                                       {\r
+                                                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "PROT P")) == 200)\r
+                                                                               {\r
+                                                                               }\r
+                                                                       }\r
+                                                               }\r
+\r
                                                                ReInPass = NO;\r
                                                                do\r
                                                                {\r
@@ -1520,8 +1646,11 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
 //                                                                     if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
                                                                        if((Sts = command(ContSock, Reply, CancelCheckWork, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
                                                                        {\r
+                                                                               // 同時接続対応\r
+//                                                                             if((strlen(Pass) != 0) || \r
+//                                                                                (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                                                if((strlen(Pass) != 0) || \r
-                                                                                  (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                                                  ((HostData->NoDisplayUI == NO) && (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                                                {\r
                                                                                        CheckOneTimePassword(Pass, Reply, Security);\r
 \r
@@ -1535,7 +1664,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        if(Sts == FTP_ERROR)\r
                                                                                        {\r
                                                                                                strcpy(Pass, "");\r
-                                                                                               if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
+                                                                                               // 同時接続対応\r
+//                                                                                             if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
+                                                                                               if(HostData->NoDisplayUI == NO && InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
                                                                                                        Continue = YES;\r
                                                                                                else\r
                                                                                                        DoPrintf("No password specified.");\r
@@ -1543,8 +1674,11 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        }\r
                                                                                        else if(Sts == FTP_CONTINUE)\r
                                                                                        {\r
+                                                                                               // 同時接続対応\r
+//                                                                                             if((strlen(Acct) != 0) || \r
+//                                                                                                (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                                                                if((strlen(Acct) != 0) || \r
-                                                                                                  (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                                                                  ((HostData->NoDisplayUI == NO) && (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                                                                {\r
                                                                                                        // 同時接続対応\r
 //                                                                                                     Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;\r
@@ -1560,6 +1694,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        DoPrintf("No password specified.");\r
                                                                                }\r
                                                                        }\r
+                                                                       // FTPES対応\r
+                                                                       if(Continue == YES)\r
+                                                                               Sts = FTP_COMPLETE;\r
                                                                }\r
                                                                while(Continue == YES);\r
                                                        }\r
@@ -1577,7 +1714,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                        }\r
                                                        else if((SavePass == YES) && (ReInPass == YES))\r
                                                        {\r
-                                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                               // 同時接続対応\r
+//                                                             if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                               if(HostData->NoDisplayUI == NO && DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
                                                                        SetHostPassword(AskCurrentHost(), Pass);\r
                                                        }\r
                                                }\r
@@ -1625,15 +1764,70 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                        HostData->Feature |= FEATURE_EPRT | FEATURE_EPSV;\r
                        }\r
                        // UTF-8対応\r
-                       if(TmpNameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
+                       if(HostData->CurNameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
                        {\r
                                if((Sts = command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON")) == 200)\r
-                                       TmpNameKanjiCode = KANJI_UTF8N;\r
+                                       HostData->CurNameKanjiCode = KANJI_UTF8N;\r
                        }\r
                }\r
        }\r
        else if(CryptMode == CRYPT_SFTP)\r
        {\r
+               // TODO:\r
+               // テストコード\r
+               // ログイン成功を確認\r
+#define strrcmp(_Str1, _Str2) (strcmp(strstr(_Str1, _Str2) ? strstr(_Str1, _Str2) : "", _Str2))\r
+               size_t r;\r
+               ContSock = SFTP_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\r
+               SFTP_SetTimeoutCallback(ContSock, SSLTimeoutCallback);\r
+               while(1)\r
+               {\r
+                       r = SFTP_recv(ContSock, Reply, 1024, 0);\r
+                       if(r == SOCKET_ERROR)\r
+                               break;\r
+                       if(r <= 0)\r
+                               continue;\r
+                       Reply[r] = '\0';\r
+                       SetTaskMsg("%s", Reply);\r
+                       if(strrcmp(Reply, "psftp> ") == 0)\r
+                               break;\r
+               }\r
+               r = SFTP_send(ContSock, "open \"", strlen("open \""), 0);\r
+               r = SFTP_send(ContSock, Host, strlen(Host), 0);\r
+               r = SFTP_send(ContSock, "\"\r\n", strlen("\"\r\n"), 0);\r
+               while(1)\r
+               {\r
+                       r = SFTP_recv(ContSock, Reply, 1024, 0);\r
+                       if(r == SOCKET_ERROR)\r
+                               break;\r
+                       if(r <= 0)\r
+                               continue;\r
+                       Reply[r] = '\0';\r
+                       SetTaskMsg("%s", Reply);\r
+                       if(strrcmp(Reply, "Store key in cache? (y/n) ") == 0)\r
+                       {\r
+                               r = SFTP_send(ContSock, "n\r\n", strlen("n\r\n"), 0);\r
+                       }\r
+                       if(strrcmp(Reply, "Update cached key? (y/n, Return cancels connection) ") == 0)\r
+                       {\r
+                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
+                       }\r
+                       if(strrcmp(Reply, "login as: ") == 0)\r
+                       {\r
+                               r = SFTP_send(ContSock, User, strlen(User), 0);\r
+                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
+                       }\r
+                       if(strrcmp(Reply, "password: ") == 0)\r
+                       {\r
+                               r = SFTP_send(ContSock, Pass, strlen(Pass), 0);\r
+                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
+                       }\r
+                       if(strrcmp(Reply, "psftp> ") == 0)\r
+                               break;\r
+                       Sleep(1);\r
+               }\r
+               SFTP_closesocket(ContSock);\r
+               ContSock = INVALID_SOCKET;\r
        }\r
 \r
        return(ContSock);\r
@@ -1804,19 +1998,21 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
 {\r
        SOCKET Result;\r
        Result = INVALID_SOCKET;\r
-       switch(CurHost.InetFamily)\r
+       switch(CurHost.CurNetType)\r
        {\r
-       case AF_UNSPEC:\r
+       case NTYPE_AUTO:\r
                if((Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
-                       CurHost.InetFamily = AF_INET;\r
-               else if(CurHost.UseIPv6 == YES && (Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
-                       CurHost.InetFamily = AF_INET6;\r
+                       CurHost.CurNetType = NTYPE_IPV4;\r
+               else if((Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
+                       CurHost.CurNetType = NTYPE_IPV6;\r
                break;\r
-       case AF_INET:\r
+       case NTYPE_IPV4:\r
                Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV4;\r
                break;\r
-       case AF_INET6:\r
+       case NTYPE_IPV6:\r
                Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV6;\r
                break;\r
        }\r
        return Result;\r
@@ -2195,14 +2391,12 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
 {\r
        SOCKET Result;\r
        Result = INVALID_SOCKET;\r
-       switch(CurHost.InetFamily)\r
+       switch(CurHost.CurNetType)\r
        {\r
-       case AF_UNSPEC:\r
-               break;\r
-       case AF_INET:\r
+       case NTYPE_IPV4:\r
                Result = GetFTPListenSocketIPv4(ctrl_skt, CancelCheckWork);\r
                break;\r
-       case AF_INET6:\r
+       case NTYPE_IPV6:\r
                Result = GetFTPListenSocketIPv6(ctrl_skt, CancelCheckWork);\r
                break;\r
        }\r
@@ -2504,14 +2698,14 @@ SOCKET GetFTPListenSocketIPv6(SOCKET ctrl_skt, int *CancelCheckWork)
 \r
        if(listen_skt != INVALID_SOCKET)\r
        {\r
-#define  US(w)  (((int)w)&0xffff)\r
+#define  UC(b)  (((int)b)&0xff)\r
                // 同時接続対応\r
 //             if((command(ctrl_skt,NULL, &CancelFlg, "PORT %d,%d,%d,%d,%d,%d",\r
 //                             UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),\r
 //                             UC(p[0]), UC(p[1])) / 100) != FTP_COMPLETE)\r
                if((command(ctrl_skt,NULL, CancelCheckWork, "EPRT |2|%s|%d|",\r
                                AddressToStringIPv6(Adrs, a),\r
-                               US(p[0])) / 100) != FTP_COMPLETE)\r
+                               (UC(p[0]) << 8) | UC(p[1])) / 100) != FTP_COMPLETE)\r
                {\r
                        SetTaskMsg(MSGJPN031);\r
                        do_closesocket(listen_skt);\r
@@ -2923,13 +3117,25 @@ int AskUseMLSD(void)
 }\r
 \r
 // IPv6対応\r
-int AskInetFamily(void)\r
+int AskCurNetType(void)\r
+{\r
+       return(CurHost.CurNetType);\r
+}\r
+\r
+// 自動切断対策\r
+int AskNoopInterval(void)\r
+{\r
+       return(CurHost.NoopInterval);\r
+}\r
+\r
+// 再転送対応\r
+int AskTransferErrorMode(void)\r
 {\r
-       return(CurHost.InetFamily);\r
+       return(CurHost.TransferErrorMode);\r
 }\r
 \r
-int AskUseIPv6(void)\r
+int AskTransferErrorNotify(void)\r
 {\r
-       return(CurHost.UseIPv6);\r
+       return(CurHost.TransferErrorNotify);\r
 }\r
 \r