OSDN Git Service

Prepare for release of 1.98f.
[ffftp/ffftp.git] / connect.c
index 7283282..122f441 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -1,6 +1,6 @@
-/*=============================================================================\r
+/*=============================================================================\r
 *\r
-*                                                              \83z\83X\83g\82Ö\82Ì\90Ú\91±\81^\90Ø\92f\r
+*                                                              ホストへの接続/切断\r
 *\r
 ===============================================================================\r
 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
 #include <string.h>\r
 #include <mbstring.h>\r
 #include <time.h>\r
-#include <winsock.h>\r
+// IPv6対応\r
+//#include <winsock.h>\r
+#include <winsock2.h>\r
+// 切断対策\r
+#include <mstcpip.h>\r
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 \r
 #include <htmlhelp.h>\r
 #include "helpid.h"\r
 \r
+// UTF-8対応\r
+#undef __MBSWRAPPER_H__\r
+#include "mbswrapper.h"\r
 \r
-/*===== \83v\83\8d\83g\83^\83C\83v =====*/\r
 \r
-static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
-static int SendInitCommand(char *Cmd);\r
+/*===== プロトタイプ =====*/\r
+\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
-static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
+// 暗号化通信対応\r
+// 同時接続対応\r
+//static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork);\r
+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork);\r
 static int CheckOneTimePassword(char *Pass, char *Reply, int Type);\r
 static BOOL CALLBACK BlkHookFnc(void);\r
 static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulong IP, char *Host, ushort Port);\r
+// IPv6対応\r
+static int Socks5MakeCmdPacketIPv6(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, char *IP, char *Host, ushort Port);\r
 static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWork);\r
-static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet);\r
-static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet);\r
+// 同時接続対応\r
+//static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet);\r
+static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet, int *CancelCheckWork);\r
+// 同時接続対応\r
+//static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet);\r
+static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet, int *CancelCheckWork);\r
 static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork);\r
 \r
-/*===== \8aO\95\94\8eQ\8fÆ =====*/\r
+/*===== 外部参照 =====*/\r
 \r
 extern char FilterStr[FILTER_EXT_LEN+1];\r
 extern char TitleHostName[HOST_ADRS_LEN+1];\r
 extern int CancelFlg;\r
 \r
-/* \90Ý\92è\92l */\r
+/* 設定値 */\r
 extern char UserMailAdrs[USER_MAIL_LEN+1];\r
 extern char FwallHost[HOST_ADRS_LEN+1];\r
 extern char FwallUser[USER_NAME_LEN+1];\r
@@ -82,8 +104,10 @@ extern int FwallLower;
 extern int FwallDelimiter;\r
 extern int PasvDefault;\r
 extern int QuickAnonymous;\r
+// 切断対策\r
+extern int TimeOut;\r
 \r
-/*===== \83\8d\81[\83J\83\8b\82È\83\8f\81[\83N =====*/\r
+/*===== ローカルなワーク =====*/\r
 \r
 static int Anonymous;\r
 static int TryConnect = NO;\r
@@ -91,25 +115,29 @@ static SOCKET CmdCtrlSocket = INVALID_SOCKET;
 static SOCKET TrnCtrlSocket = INVALID_SOCKET;\r
 static HOSTDATA CurHost;\r
 \r
-/* \90Ú\91±\92\86\82Ì\90Ú\91±\90æ\81ASOCKS\83T\81[\83o\82Ì\83A\83h\83\8c\83X\8fî\95ñ\82ð\95Û\91\82µ\82Ä\82¨\82­ */\r
-/* \82±\82Ì\8fî\95ñ\82Ílisten\83\\83P\83b\83g\82ð\8eæ\93¾\82·\82é\8dÛ\82É\97p\82¢\82é */\r
-static struct sockaddr_in SocksSockAddr;       /* SOCKS\83T\81[\83o\82Ì\83A\83h\83\8c\83X\8fî\95ñ */\r
-static struct sockaddr_in CurSockAddr;         /* \90Ú\91±\90æ\83z\83X\83g\82Ì\83A\83h\83\8c\83X\8fî\95ñ */\r
+/* 接続中の接続先、SOCKSサーバのアドレス情報を保存しておく */\r
+/* この情報はlistenソケットを取得する際に用いる */\r
+// IPv6対応\r
+//static struct sockaddr_in SocksSockAddr;     /* SOCKSサーバのアドレス情報 */\r
+//static struct sockaddr_in CurSockAddr;               /* 接続先ホストのアドレス情報 */\r
 \r
 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
-/*----- \83z\83X\83g\88ê\97\97\82ð\8eg\82Á\82Ä\83z\83X\83g\82Ö\90Ú\91± ----------------------------------------\r
+/*----- ホスト一覧を使ってホストへ接続 ----------------------------------------\r
 *\r
 *      Parameter\r
-*              int Type : \83_\83C\83A\83\8d\83O\82Ì\83^\83C\83v (DLG_TYPE_xxx)\r
-*              int Num : \90Ú\91±\82·\82é\83z\83X\83g\94Ô\8d\86(0\81`, -1=\83_\83C\83A\83\8d\83O\82ð\8fo\82·)\r
+*              int Type : ダイアログのタイプ (DLG_TYPE_xxx)\r
+*              int Num : 接続するホスト番号(0~, -1=ダイアログを出す)\r
 \r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void ConnectProc(int Type, int Num)\r
@@ -128,7 +156,7 @@ void ConnectProc(int Type, int Num)
                if(Num >= 0)\r
                        SetCurrentHost(Num);\r
 \r
-               /* \90Ú\91±\92\86\82È\82ç\90Ø\92f\82·\82é */\r
+               /* 接続中なら切断する */\r
                if(CmdCtrlSocket != INVALID_SOCKET)\r
                        DisconnectProc();\r
 \r
@@ -136,8 +164,12 @@ void ConnectProc(int Type, int Num)
 \r
                InitPWDcommand();\r
                CopyHostFromList(AskCurrentHost(), &CurHost);\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
-               if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == SUCCESS)\r
+               if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
                        SetHostKanaCnvImm(CurHost.KanaCnv);\r
                        SetHostKanjiCodeImm(CurHost.KanjiCode);\r
@@ -155,16 +187,59 @@ void ConnectProc(int Type, int Num)
                                Save = YES;\r
 \r
                        DisableUserOpe();\r
-                       CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);\r
+                       // 暗号化通信対応\r
+                       // 同時接続対応\r
+//                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
+                               // 暗号化通信対応\r
+                               switch(CurHost.CryptMode)\r
+                               {\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
                                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
@@ -189,13 +264,13 @@ void ConnectProc(int Type, int Num)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\96¼\82ð\93ü\97Í\82µ\82Ä\83z\83X\83g\82Ö\90Ú\91± ----------------------------------------\r
+/*----- ホスト名を入力してホストへ接続 ----------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void QuickConnectProc(void)\r
@@ -208,7 +283,7 @@ void QuickConnectProc(void)
 \r
        if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(hostname_dlg), GetMainHwnd(), QuickConDialogCallBack, (LPARAM)Tmp) == YES)\r
        {\r
-               /* \90Ú\91±\92\86\82È\82ç\90Ø\92f\82·\82é */\r
+               /* 接続中なら切断する */\r
                if(CmdCtrlSocket != INVALID_SOCKET)\r
                        DisconnectProc();\r
 \r
@@ -216,7 +291,11 @@ void QuickConnectProc(void)
 \r
                InitPWDcommand();\r
                CopyDefaultHost(&CurHost);\r
-               if(SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == SUCCESS)\r
+               // UTF-8対応\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
                        {\r
@@ -234,11 +313,21 @@ void QuickConnectProc(void)
                        SetSyncMoveMode(CurHost.SyncMove);\r
 \r
                        DisableUserOpe();\r
-                       CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       // 暗号化通信対応\r
+                       // 同時接続対応\r
+//                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\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
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
@@ -250,7 +339,7 @@ void QuickConnectProc(void)
                                EnableUserOpe();\r
 \r
                                if(strlen(File) > 0)\r
-                                       DirectDownLoadProc(File);\r
+                                       DirectDownloadProc(File);\r
                        }\r
                        else\r
                        {\r
@@ -263,19 +352,21 @@ void QuickConnectProc(void)
 }\r
 \r
 \r
-/*----- \83N\83C\83b\83N\90Ú\91±\83_\83C\83A\83\8d\83O\82Ì\83R\81[\83\8b\83o\83b\83N ----------------------------------\r
+/*----- クイック接続ダイアログのコールバック ----------------------------------\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 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
@@ -304,7 +395,7 @@ static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wPa
                        SendDlgItemMessage(hDlg, QHOST_PASV, BM_SETCHECK, PasvDefault, 0);\r
                        for(i = 0; i < HISTORY_MAX; i++)\r
                        {\r
-                               if(GetHistoryByNum(i, &Tmp) == SUCCESS)\r
+                               if(GetHistoryByNum(i, &Tmp) == FFFTP_SUCCESS)\r
                                {\r
 //sprintf(Str, "%s (%s) %s", Tmp.HostAdrs, Tmp.UserName, Tmp.RemoteInitDir);\r
 //SendDlgItemMessage(hDlg, QHOST_HOST, CB_ADDSTRING, 0, (LPARAM)Str);\r
@@ -341,17 +432,17 @@ static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wPa
 }\r
 \r
 \r
-/*----- \8ew\92è\82µ\82½\83z\83X\83g\96¼\82Å\83z\83X\83g\82Ö\90Ú\91± ----------------------------------------\r
+/*----- 指定したホスト名でホストへ接続 ----------------------------------------\r
 *\r
 *      Parameter\r
-*              char *unc : UNC\95\8e\9a\97ñ\r
-*              int Kanji : \83z\83X\83g\82Ì\8a¿\8e\9a\83R\81[\83h (KANJI_xxx)\r
-*              int Kana : \94¼\8ap\82©\82È\81¨\91S\8ap\95Ï\8a·\83\82\81[\83h (YES/NO)\r
-*              int Fkanji : \83t\83@\83C\83\8b\96¼\82Ì\8a¿\8e\9a\83R\81[\83h (KANJI_xxx)\r
-*              int TrMode : \93]\91\97\83\82\81[\83h (TYPE_xx)\r
+*              char *unc : UNC文字列\r
+*              int Kanji : ホストの漢字コード (KANJI_xxx)\r
+*              int Kana : 半角かな→全角変換モード (YES/NO)\r
+*              int Fkanji : ファイル名の漢字コード (KANJI_xxx)\r
+*              int TrMode : 転送モード (TYPE_xx)\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)\r
@@ -366,14 +457,14 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
        SaveBookMark();\r
        SaveCurrentSetToHost();\r
 \r
-       /* \90Ú\91±\92\86\82È\82ç\90Ø\92f\82·\82é */\r
+       /* 接続中なら切断する */\r
        if(CmdCtrlSocket != INVALID_SOCKET)\r
                DisconnectProc();\r
 \r
        SetTaskMsg("----------------------------");\r
 \r
        InitPWDcommand();\r
-       if(SplitUNCpath(unc, Host, Path, File, User, Pass, &Port) == SUCCESS)\r
+       if(SplitUNCpath(unc, Host, Path, File, User, Pass, &Port) == FFFTP_SUCCESS)\r
        {\r
                if(strlen(User) == 0)\r
                {\r
@@ -393,7 +484,11 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                CurHost.KanjiCode = Kanji;\r
                CurHost.KanaCnv = Kana;\r
                CurHost.NameKanjiCode = Fkanji;\r
-               CurHost.KanaCnv = YES;                  /* \82Æ\82è\82 \82¦\82¸ */\r
+               CurHost.KanaCnv = YES;                  /* とりあえず */\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                SetHostKanaCnvImm(CurHost.KanaCnv);\r
                SetHostKanjiCodeImm(CurHost.KanjiCode);\r
@@ -406,11 +501,21 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                }\r
 \r
                DisableUserOpe();\r
-               CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+               // 暗号化通信対応\r
+               // 同時接続対応\r
+//             CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+               CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                if(CmdCtrlSocket != INVALID_SOCKET)\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
                        strcpy(TitleHostName, CurHost.HostAdrs);\r
                        DispWindowTitle();\r
                        SoundPlay(SND_CONNECT);\r
@@ -422,7 +527,7 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                        EnableUserOpe();\r
 \r
                        if(strlen(File) > 0)\r
-                               DirectDownLoadProc(File);\r
+                               DirectDownloadProc(File);\r
                        else\r
                                ResetAutoExitFlg();\r
                }\r
@@ -436,13 +541,13 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82Ì\83q\83X\83g\83\8a\82Å\8ew\92è\82³\82ê\82½\83z\83X\83g\82Ö\90Ú\91± ------------------------------\r
+/*----- ホストのヒストリで指定されたホストへ接続 ------------------------------\r
 *\r
 *      Parameter\r
-*              int MenuCmd : \8eæ\82è\8fo\82·\83q\83X\83g\83\8a\82É\8a\84\82è\93\96\82Ä\82ç\82ê\82½\83\81\83j\83\85\81[\83R\83}\83\93\83h\r
+*              int MenuCmd : 取り出すヒストリに割り当てられたメニューコマンド\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void HistoryConnectProc(int MenuCmd)\r
@@ -453,12 +558,12 @@ void HistoryConnectProc(int MenuCmd)
        int RFSort;\r
        int RDSort;\r
 \r
-       if(GetHistoryByCmd(MenuCmd, &Hist) == SUCCESS)\r
+       if(GetHistoryByCmd(MenuCmd, &Hist) == FFFTP_SUCCESS)\r
        {\r
                SaveBookMark();\r
                SaveCurrentSetToHost();\r
 \r
-               /* \90Ú\91±\92\86\82È\82ç\90Ø\92f\82·\82é */\r
+               /* 接続中なら切断する */\r
                if(CmdCtrlSocket != INVALID_SOCKET)\r
                        DisconnectProc();\r
 \r
@@ -466,8 +571,12 @@ void HistoryConnectProc(int MenuCmd)
 \r
                InitPWDcommand();\r
                CopyHistoryToHost(&Hist, &CurHost);\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
-               if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == SUCCESS)\r
+               if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
                        SetCurrentHost(HOSTNUM_NOENTRY);\r
                        SetHostKanaCnvImm(CurHost.KanaCnv);\r
@@ -482,16 +591,26 @@ void HistoryConnectProc(int MenuCmd)
                        DispTransferType();\r
 \r
                        DisableUserOpe();\r
-                       CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       // 暗号化通信対応\r
+                       // 同時接続対応\r
+//                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\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
                                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
@@ -516,21 +635,23 @@ void HistoryConnectProc(int MenuCmd)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82Ì\8f\89\8aú\89»\83R\83}\83\93\83h\82ð\91\97\82é ------------------------------------------\r
+/*----- ホストの初期化コマンドを送る ------------------------------------------\r
 *\r
 *      Parameter\r
-*              int Cmd : \8f\89\8aú\89»\83R\83}\83\93\83h\83X\r
+*              int Cmd : 初期化コマンドス\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      NOte\r
-*              \8f\89\8aú\89»\83R\83}\83\93\83h\82Í\88È\89º\82Ì\82æ\82¤\82È\83t\83H\81[\83}\83b\83g\82Å\82 \82é\82±\82Æ\r
+*              初期化コマンドは以下のようなフォーマットであること\r
 *                      cmd1\0\r
 *                      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
@@ -541,7 +662,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
@@ -552,16 +674,16 @@ static int SendInitCommand(char *Cmd)
 }\r
 \r
 \r
-/*----- \8ew\92è\82Ì\83z\83X\83g\82ÍFireWall\82ð\8eg\82¤\90Ý\92è\82©\82Ç\82¤\82©\82ð\95Ô\82· ------------------------\r
+/*----- 指定のホストはFireWallを使う設定かどうかを返す ------------------------\r
 *\r
 *      Parameter\r
-*              char *Hots : \83z\83X\83g\96¼\r
-*              int *Fire : FireWall\82ð\8eg\82¤\82©\82Ç\82¤\82©\82ð\95Ô\82·\83\8f\81[\83N\r
-*              int *Pasv : PASV\83\82\81[\83h\82ð\95Ô\82·\83\8f\81[\83N\r
-*              int *List : LIST\83R\83}\83\93\83h\82Ì\82Ý\8eg\97p\83t\83\89\83O\r
+*              char *Hots : ホスト名\r
+*              int *Fire : FireWallを使うかどうかを返すワーク\r
+*              int *Pasv : PASVモードを返すワーク\r
+*              int *List : LISTコマンドのみ使用フラグ\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List)\r
@@ -571,10 +693,11 @@ static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List)
 \r
        *Fire = FwallDefault;\r
        *Pasv = PasvDefault;\r
-       *List = NO;\r
+       // NLSTを送ってしまうバグ修正(ただしNLSTを使うべきホストへクイック接続できなくなる)\r
+//     *List = NO;\r
 \r
        i = 0;\r
-       while(CopyHostFromList(i, &Tmp) == SUCCESS)\r
+       while(CopyHostFromList(i, &Tmp) == FFFTP_SUCCESS)\r
        {\r
                if(strcmp(Host, Tmp.HostAdrs) == 0)\r
                {\r
@@ -589,13 +712,13 @@ static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83A\83h\83\8c\83X\82ð\95Ô\82· ------------------------------------\r
+/*----- 接続しているホストのアドレスを返す ------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83z\83X\83g\82Ì\83A\83h\83\8c\83X\r
+*              char *ホストのアドレス\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskHostAdrs(void)\r
@@ -604,13 +727,13 @@ char *AskHostAdrs(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83|\81[\83g\82ð\95Ô\82· --------------------------------------\r
+/*----- 接続しているホストのポートを返す --------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83z\83X\83g\82Ì\83|\81[\83g\r
+*              int ホストのポート\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostPort(void)\r
@@ -618,31 +741,33 @@ int AskHostPort(void)
        return(CurHost.Port);\r
 }\r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83t\83@\83C\83\8b\96¼\82Ì\8a¿\8e\9a\83R\81[\83h\82ð\95Ô\82· ----------------------\r
+/*----- 接続しているホストのファイル名の漢字コードを返す ----------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \8a¿\8e\9a\83R\81[\83h (KANJI_xxx)\r
+*              int 漢字コード (KANJI_xxx)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostNameKanji(void)\r
 {\r
-       if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
-               CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
-\r
-       return(CurHost.NameKanjiCode);\r
+       // UTF-8対応\r
+//     if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
+//             CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+//\r
+//     return(CurHost.NameKanjiCode);\r
+       return(CurHost.CurNameKanjiCode);\r
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83t\83@\83C\83\8b\96¼\82Ì\94¼\8ap\83J\83i\95Ï\8a·\83t\83\89\83O\82ð\95Ô\82· --------------\r
+/*----- 接続しているホストのファイル名の半角カナ変換フラグを返す --------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \94¼\8ap\83J\83i\82ð\91S\8ap\82É\95Ï\8a·\82·\82é\82©\82Ç\82¤\82© (YES/NO)\r
+*              int 半角カナを全角に変換するかどうか (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostNameKana(void)\r
@@ -654,13 +779,13 @@ int AskHostNameKana(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÌLIST\83R\83}\83\93\83h\83\82\81[\83h\82ð\95Ô\82· --------------------------\r
+/*----- 接続しているホストのLISTコマンドモードを返す --------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int LIST\83R\83}\83\93\83h\83\82\81[\83h (YES/NO)\r
+*              int LISTコマンドモード (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskListCmdMode(void)\r
@@ -676,13 +801,13 @@ int AskListCmdMode(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÅNLST -R\82ð\8eg\82¤\82©\82Ç\82¤\82©\82ð\95Ô\82· ------------------------\r
+/*----- 接続しているホストでNLST -Rを使うかどうかを返す ------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int NLST -R\82ð\8eg\82¤\82©\82Ç\82¤\82© (YES/NO)\r
+*              int NLST -Rを使うかどうか (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskUseNLST_R(void)\r
@@ -694,13 +819,13 @@ int AskUseNLST_R(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÌChmod\83R\83}\83\93\83h\82ð\95Ô\82· -------------------------------\r
+/*----- 接続しているホストのChmodコマンドを返す -------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *Chmod\83R\83}\83\93\83h\r
+*              char *Chmodコマンド\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskHostChmodCmd(void)\r
@@ -712,13 +837,13 @@ char *AskHostChmodCmd(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83^\83C\83\80\83]\81[\83\93\82ð\95Ô\82· --------------------------------\r
+/*----- 接続しているホストのタイムゾーンを返す --------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83^\83C\83\80\83]\81[\83\93\r
+*              int タイムゾーン\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostTimeZone(void)\r
@@ -730,13 +855,13 @@ int AskHostTimeZone(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÌPASV\83\82\81[\83h\82ð\95Ô\82· ----------------------------------\r
+/*----- 接続しているホストのPASVモードを返す ----------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int PASV\83\82\81[\83h\82©\82Ç\82¤\82© (YES/NO)\r
+*              int PASVモードかどうか (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskPasvMode(void)\r
@@ -745,13 +870,13 @@ int AskPasvMode(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÌLNST\83t\83@\83C\83\8b\96¼\82ð\95Ô\82· ------------------------------\r
+/*----- 接続しているホストのLNSTファイル名を返す ------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83t\83@\83C\83\8b\96¼\81^\83I\83v\83V\83\87\83\93\r
+*              char *ファイル名/オプション\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskHostLsName(void)\r
@@ -763,13 +888,13 @@ char *AskHostLsName(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Ì\83z\83X\83g\83^\83C\83v\82ð\95Ô\82· --------------------------------\r
+/*----- 接続しているホストのホストタイプを返す --------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83t\83@\83C\83\8b\96¼\81^\83I\83v\83V\83\87\83\93\r
+*              char *ファイル名/オプション\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostType(void)\r
@@ -777,17 +902,25 @@ 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
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82ÍFireWall\82ð\8eg\82¤\83z\83X\83g\82©\82Ç\82¤\82©\82ð\95Ô\82· ----------------\r
+/*----- 接続しているホストはFireWallを使うホストかどうかを返す ----------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int FireWall\82ð\8eg\82¤\82©\82Ç\82¤\82© (YES/NO)\r
+*              int FireWallを使うかどうか (YES/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskHostFireWall(void)\r
@@ -796,13 +929,13 @@ int AskHostFireWall(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83z\83X\83g\82Å\83t\83\8b\83p\83X\82Å\83t\83@\83C\83\8b\83A\83N\83Z\83X\82µ\82È\82¢\82©\82Ç\82¤\82©\82ð\95Ô\82· ----\r
+/*----- 接続しているホストでフルパスでファイルアクセスしないかどうかを返す ----\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83t\83\8b\83p\83X\82Å\83A\83N\83Z\83X\82µ\82È\82¢ (YES=\83t\83\8b\83p\83X\8bÖ\8e~/NO)\r
+*              int フルパスでアクセスしない (YES=フルパス禁止/NO)\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskNoFullPathMode(void)\r
@@ -814,13 +947,13 @@ int AskNoFullPathMode(void)
 }\r
 \r
 \r
-/*----- \90Ú\91±\82µ\82Ä\82¢\82é\83\86\81[\83U\96¼\82ð\95Ô\82· --------------------------------------------\r
+/*----- 接続しているユーザ名を返す --------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              char *\83\86\81[\83U\96¼\r
+*              char *ユーザ名\r
 *----------------------------------------------------------------------------*/\r
 \r
 char *AskHostUserName(void)\r
@@ -829,16 +962,16 @@ char *AskHostUserName(void)
 }\r
 \r
 \r
-/*----- \8c»\8dÝ\82Ì\90Ý\92è\82ð\83z\83X\83g\82Ì\90Ý\92è\82É\83Z\83b\83g\82·\82é ----------------------------------\r
+/*----- 現在の設定をホストの設定にセットする ----------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Note\r
-*              \83J\83\8c\83\93\83g\83f\83B\83\8c\83N\83g\83\8a\81A\83\\81[\83g\95û\96@\82ð\83z\83X\83g\82Ì\90Ý\92è\82É\83Z\83b\83g\82·\82é\r
+*              カレントディレクトリ、ソート方法をホストの設定にセットする\r
 *----------------------------------------------------------------------------*/\r
 \r
 void SaveCurrentSetToHost(void)\r
@@ -865,13 +998,13 @@ void SaveCurrentSetToHost(void)
 }\r
 \r
 \r
-/*----- \8c»\8dÝ\82Ì\90Ý\92è\82ð\83q\83X\83g\83\8a\82É\83Z\83b\83g\82·\82é --------------------------------------\r
+/*----- 現在の設定をヒストリにセットする --------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 static void SaveCurrentSetToHistory(void)\r
@@ -898,20 +1031,21 @@ static void SaveCurrentSetToHistory(void)
 }\r
 \r
 \r
-/*----- \83R\83}\83\93\83h\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82Ì\8dÄ\90Ú\91± ----------------------------------\r
+/*----- コマンドコントロールソケットの再接続 ----------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
 int ReConnectCmdSkt(void)\r
 {\r
        int Sts;\r
 \r
+\r
        if(CmdCtrlSocket != TrnCtrlSocket)\r
                do_closesocket(TrnCtrlSocket);\r
        TrnCtrlSocket = INVALID_SOCKET;\r
@@ -924,30 +1058,79 @@ int ReConnectCmdSkt(void)
 }\r
 \r
 \r
-/*----- \93]\91\97\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82Ì\8dÄ\90Ú\91± --------------------------------------\r
+/*----- 転送コントロールソケットの再接続 --------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
 //int ReConnectTrnSkt(void)\r
 //{\r
 //     return(ReConnectSkt(&TrnCtrlSocket));\r
 //}\r
+// 同時接続対応\r
+int ReConnectTrnSkt(SOCKET *Skt, int *CancelCheckWork)\r
+{\r
+//     char Path[FMAX_PATH+1];\r
+       int Sts;\r
+       // 暗号化通信対応\r
+       HOSTDATA HostData;\r
+\r
+       Sts = FFFTP_FAIL;\r
+\r
+       SetTaskMsg(MSGJPN003);\r
+\r
+//     DisableUserOpe();\r
+       /* 現在のソケットは切断 */\r
+       if(*Skt != INVALID_SOCKET)\r
+               do_closesocket(*Skt);\r
+       /* 再接続 */\r
+       // 暗号化通信対応\r
+       HostData = CurHost;\r
+       if(HostData.CryptMode != CRYPT_NONE)\r
+               HostData.UseNoEncryption = NO;\r
+       if(HostData.CryptMode != CRYPT_FTPES)\r
+               HostData.UseFTPES = NO;\r
+       if(HostData.CryptMode != CRYPT_FTPIS)\r
+               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
+       }\r
+       else\r
+               SoundPlay(SND_ERROR);\r
 \r
+//     EnableUserOpe();\r
+       return(Sts);\r
+}\r
 \r
-/*----- \89ñ\90ü\82Ì\8dÄ\90Ú\91± ----------------------------------------------------------\r
+\r
+/*----- 回線の再接続 ----------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              SOCKET *Skt : \90Ú\91±\82µ\82½\83\\83P\83b\83g\82ð\95Ô\82·\83\8f\81[\83N\r
+*              SOCKET *Skt : 接続したソケットを返すワーク\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 ReConnectSkt(SOCKET *Skt)\r
@@ -955,20 +1138,24 @@ static int ReConnectSkt(SOCKET *Skt)
        char Path[FMAX_PATH+1];\r
        int Sts;\r
 \r
-       Sts = FAIL;\r
+       Sts = FFFTP_FAIL;\r
 \r
        SetTaskMsg(MSGJPN003);\r
 \r
        DisableUserOpe();\r
-       /* \8c»\8dÝ\82Ì\83\\83P\83b\83g\82Í\90Ø\92f */\r
+       /* 現在のソケットは切断 */\r
        if(*Skt != INVALID_SOCKET)\r
                do_closesocket(*Skt);\r
-       /* \8dÄ\90Ú\91± */\r
-       if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
+       /* 再接続 */\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(&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 = SUCCESS;\r
+               Sts = FFFTP_SUCCESS;\r
        }\r
        else\r
                SoundPlay(SND_ERROR);\r
@@ -978,13 +1165,13 @@ static int ReConnectSkt(SOCKET *Skt)
 }\r
 \r
 \r
-/*----- \83R\83}\83\93\83h\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82ð\95Ô\82· ------------------------------------\r
+/*----- コマンドコントロールソケットを返す ------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              SOCKET \83R\83}\83\93\83h\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\r
+*              SOCKET コマンドコントロールソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
 SOCKET AskCmdCtrlSkt(void)\r
@@ -993,13 +1180,13 @@ SOCKET AskCmdCtrlSkt(void)
 }\r
 \r
 \r
-/*----- \93]\91\97\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82ð\95Ô\82· ----------------------------------------\r
+/*----- 転送コントロールソケットを返す ----------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              SOCKET \93]\91\97\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\r
+*              SOCKET 転送コントロールソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
 SOCKET AskTrnCtrlSkt(void)\r
@@ -1008,13 +1195,13 @@ SOCKET AskTrnCtrlSkt(void)
 }\r
 \r
 \r
-/*----- \83R\83}\83\93\83h\81^\93]\91\97\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82Ì\8b¤\97L\82ð\89ð\8f\9c ------------------------\r
+/*----- コマンド/転送コントロールソケットの共有を解除 ------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void SktShareProh(void)\r
@@ -1024,21 +1211,27 @@ void SktShareProh(void)
 \r
 //SetTaskMsg("############### SktShareProh");\r
 \r
-               CmdCtrlSocket = INVALID_SOCKET;\r
-               ReConnectSkt(&CmdCtrlSocket);\r
+               // 同時接続対応\r
+//             CmdCtrlSocket = INVALID_SOCKET;\r
+//             ReConnectSkt(&CmdCtrlSocket);\r
+               if(CurHost.ReuseCmdSkt == YES)\r
+               {\r
+                       CmdCtrlSocket = INVALID_SOCKET;\r
+                       ReConnectSkt(&CmdCtrlSocket);\r
+               }\r
        }\r
        return;\r
 }\r
 \r
 \r
-/*----- \83R\83}\83\93\83h\81^\93]\91\97\83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\82Ì\8b¤\97L\82ª\89ð\8f\9c\82³\82ê\82Ä\82¢\82é\82©\83`\83F\83b\83N ----\r
+/*----- コマンド/転送コントロールソケットの共有が解除されているかチェック ----\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      YES=\8b¤\97L\89ð\8f\9c/NO=\8b¤\97L\r
+*              int ステータス\r
+*                      YES=共有解除/NO=共有\r
 *----------------------------------------------------------------------------*/\r
 \r
 int AskShareProh(void)\r
@@ -1046,20 +1239,22 @@ int AskShareProh(void)
        int Sts;\r
 \r
        Sts = YES;\r
-       if(CmdCtrlSocket == TrnCtrlSocket)\r
+       // 同時接続対応\r
+//     if(CmdCtrlSocket == TrnCtrlSocket)\r
+       if(CmdCtrlSocket == TrnCtrlSocket || TrnCtrlSocket == INVALID_SOCKET)\r
                Sts = NO;\r
 \r
        return(Sts);\r
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82©\82ç\90Ø\92f --------------------------------------------------------\r
+/*----- ホストから切断 --------------------------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void DisconnectProc(void)\r
@@ -1069,13 +1264,17 @@ void DisconnectProc(void)
 \r
        if((CmdCtrlSocket != INVALID_SOCKET) && (CmdCtrlSocket != TrnCtrlSocket))\r
        {\r
-               DoQUIT(CmdCtrlSocket);\r
+               // 同時接続対応\r
+//             DoQUIT(CmdCtrlSocket);\r
+               DoQUIT(CmdCtrlSocket, &CancelFlg);\r
                DoClose(CmdCtrlSocket);\r
        }\r
 \r
        if(TrnCtrlSocket != INVALID_SOCKET)\r
        {\r
-               DoQUIT(TrnCtrlSocket);\r
+               // 同時接続対応\r
+//             DoQUIT(TrnCtrlSocket);\r
+               DoQUIT(TrnCtrlSocket, &CancelFlg);\r
                DoClose(TrnCtrlSocket);\r
 \r
                SaveCurrentSetToHistory();\r
@@ -1095,13 +1294,13 @@ void DisconnectProc(void)
 }\r
 \r
 \r
-/*----- \83\\83P\83b\83g\82ª\8b­\90§\90Ø\92f\82³\82ê\82½\82Æ\82«\82Ì\8f\88\97\9d ------------------------------------\r
+/*----- ソケットが強制切断されたときの処理 ------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              \82È\82µ\r
+*              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
 void DisconnectSet(void)\r
@@ -1117,13 +1316,13 @@ void DisconnectSet(void)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82É\90Ú\91±\92\86\82©\82Ç\82¤\82©\82ð\95Ô\82· ------------------------------------------\r
+/*----- ホストに接続中かどうかを返す ------------------------------------------\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 AskConnecting(void)\r
@@ -1138,39 +1337,96 @@ int AskConnecting(void)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82Ö\90Ú\91±\82·\82é ------------------------------------------------------\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
-*              char *Host : \83z\83X\83g\96¼\r
-*              char *User : \83\86\81[\83U\96¼\r
-*              char *Pass : \83p\83X\83\8f\81[\83h\r
-*              char *Acct : \83A\83J\83E\83\93\83g\r
-*              int Port : \83|\81[\83g\r
-*              int Fwall : FireWall\82ð\8eg\82¤\82©\82Ç\82¤\82© (YES/NO)\r
-*              int SavePass : \83p\83X\83\8f\81[\83h\82ð\8dÄ\93ü\97Í\82µ\82½\8e\9e\82É\95Û\91\82·\82é\82©\82Ç\82¤\82© (YES/NO)\r
-*              int Security : \83Z\83L\83\85\83\8a\83e\83B (SECURITY_xxx, MDx)\r
+*              char *Host : ホスト名\r
+*              char *User : ユーザ名\r
+*              char *Pass : パスワード\r
+*              char *Acct : アカウント\r
+*              int Port : ポート\r
+*              int Fwall : FireWallを使うかどうか (YES/NO)\r
+*              int SavePass : パスワードを再入力した時に保存するかどうか (YES/NO)\r
+*              int Security : セキュリティ (SECURITY_xxx, MDx)\r
 *\r
 *      Return Value\r
-*              SOCKET \83\\83P\83b\83g\r
+*              SOCKET ソケット\r
 *\r
 *      Note\r
-*              \83z\83X\83g\96¼\81A\83\86\81[\83U\96¼\81A\83p\83X\83\8f\81[\83h\82ª\8ew\92è\82³\82ê\82Ä\82¢\82È\82©\82Á\82½\82Æ\82«\82Í\81A\90Ú\91±\82É\8eg\97p\r
-*              \82µ\82½\82à\82Ì\82ð\83R\83s\81[\82µ\82Ä\82©\82¦\82·\r
-*                      char *Host : \83z\83X\83g\96¼\r
-*                      char *User : \83\86\81[\83U\96¼\r
-*                      char *Pass : \83p\83X\83\8f\81[\83h\r
-*                      char *Acct : \83A\83J\83E\83\93\83g\r
-*\r
-*              FireWall\82Í\8e\9f\82Ì\82æ\82¤\82É\93®\8dì\82·\82é\r
-*                      TYPE1   Connect fire \81¨ USER user(f) \81¨ PASS pass(f) \81¨ SITE host \81¨ USER user(h) \81¨      PASS pass(h) \81¨ ACCT acct\r
-*                      TYPE2   Connect fire \81¨ USER user(f) \81¨ PASS pass(f) \81¨              USER user(h)@host \81¨ PASS pass(h) \81¨ ACCT acct\r
-*                      TYPE3   Connect fire \81¨                                              USER user(h)@host \81¨ PASS pass(h) \81¨ ACCT acct\r
-*                      TYPE4   Connect fire \81¨                                 OPEN host \81¨ USER user(h) \81¨      PASS pass(h) \81¨ ACCT acct\r
+*              ホスト名、ユーザ名、パスワードが指定されていなかったときは、接続に使用\r
+*              したものをコピーしてかえす\r
+*                      char *Host : ホスト名\r
+*                      char *User : ユーザ名\r
+*                      char *Pass : パスワード\r
+*                      char *Acct : アカウント\r
+*\r
+*              FireWallは次のように動作する\r
+*                      TYPE1   Connect fire → USER user(f) → PASS pass(f) → SITE host → USER user(h) →      PASS pass(h) → ACCT acct\r
+*                      TYPE2   Connect fire → USER user(f) → PASS pass(f) →              USER user(h)@host → PASS pass(h) → ACCT acct\r
+*                      TYPE3   Connect fire →                                              USER user(h)@host → PASS pass(h) → ACCT acct\r
+*                      TYPE4   Connect fire →                                 OPEN host → USER user(h) →      PASS pass(h) → ACCT acct\r
 *                      TYPE5   SOCKS4\r
-*                      none    Connect host \81¨                                              USER user(h) \81¨      PASS pass(h) \81¨ ACCT acct\r
+*                      none    Connect host →                                              USER user(h) →      PASS pass(h) → ACCT acct\r
 *----------------------------------------------------------------------------*/\r
 \r
-static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)\r
+// 暗号化通信対応\r
+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork)\r
 {\r
        int Sts;\r
        int Flg;\r
@@ -1185,227 +1441,403 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
        static const char *SiteTbl[4] = { "SITE", "site", "OPEN", "open" };\r
        char TmpBuf[ONELINE_BUF_SIZE];\r
        struct linger LingerOpt;\r
+       struct tcp_keepalive KeepAlive;\r
+       DWORD dwTmp;\r
 \r
-       if(Fwall == YES)\r
-               Fwall = FwallType;\r
-       else\r
-               Fwall = FWALL_NONE;\r
+       // 暗号化通信対応\r
+       ContSock = INVALID_SOCKET;\r
+\r
+       if(CryptMode == CRYPT_NONE || CryptMode == CRYPT_FTPES || CryptMode == CRYPT_FTPIS)\r
+       {\r
+               if(Fwall == YES)\r
+                       Fwall = FwallType;\r
+               else\r
+                       Fwall = FWALL_NONE;\r
 \r
-       TryConnect = YES;\r
-       CancelFlg = NO;\r
+               TryConnect = YES;\r
+               // 暗号化通信対応\r
+//             CancelFlg = NO;\r
 #if 0\r
-//     WSASetBlockingHook(BlkHookFnc);\r
+//             WSASetBlockingHook(BlkHookFnc);\r
 #endif\r
 \r
-       ContSock = INVALID_SOCKET;\r
-\r
-       HostPort = Port;\r
-       Tmp = Host;\r
-       if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||\r
-          (Fwall == FWALL_SIDEWINDER) ||\r
-          (Fwall == FWALL_FU_FP))\r
-       {\r
-               Tmp = FwallHost;\r
-               Port = FwallPort;\r
-       }\r
+               ContSock = INVALID_SOCKET;\r
 \r
-       if(strlen(Tmp) != 0)\r
-       {\r
-               if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)\r
+               HostPort = Port;\r
+               Tmp = Host;\r
+               if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||\r
+                  (Fwall == FWALL_SIDEWINDER) ||\r
+                  (Fwall == FWALL_FU_FP))\r
                {\r
-                       while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
-                               ;\r
+                       Tmp = FwallHost;\r
+                       Port = FwallPort;\r
+               }\r
 \r
-                       if(Sts == FTP_COMPLETE)\r
+               if(strlen(Tmp) != 0)\r
+               {\r
+                       // 同時接続対応\r
+//                     if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)\r
+                       if((ContSock = connectsock(Tmp, Port, "", CancelCheckWork)) != INVALID_SOCKET)\r
                        {\r
-                               Flg = 1;\r
-                               if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
-                                       ReportWSError("setsockopt", WSAGetLastError());\r
-#pragma aaa\r
-                               Flg = 1;\r
-                               if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
-                                       ReportWSError("setsockopt", WSAGetLastError());\r
-                               LingerOpt.l_onoff = 1;\r
-                               LingerOpt.l_linger = 90;\r
-                               if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)\r
-                                       ReportWSError("setsockopt", WSAGetLastError());\r
-///////\r
-\r
-\r
-                               /*===== \94F\8fØ\82ð\8ds\82È\82¤ =====*/\r
-\r
-                               Sts = FTP_COMPLETE;\r
-                               if((Fwall == FWALL_FU_FP_SITE) ||\r
-                                  (Fwall == FWALL_FU_FP_USER) ||\r
-                                  (Fwall == FWALL_FU_FP))\r
+                               // バッファを無効\r
+#ifdef DISABLE_CONTROL_NETWORK_BUFFERS\r
+                               int BufferSize = 0;\r
+                               setsockopt(ContSock, SOL_SOCKET, SO_SNDBUF, (char*)&BufferSize, sizeof(int));\r
+                               setsockopt(ContSock, SOL_SOCKET, SO_RCVBUF, (char*)&BufferSize, sizeof(int));\r
+#endif\r
+                               // FTPIS対応\r
+//                             while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
+//                                     ;\r
+                               if(CryptMode == CRYPT_FTPIS)\r
                                {\r
-                                       if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
+                                       if(AttachSSL(ContSock, INVALID_SOCKET, CancelCheckWork))\r
                                        {\r
-                                               CheckOneTimePassword(FwallPass, Reply, FwallSecurity);\r
-                                               Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                               while((Sts = ReadReplyMessage(ContSock, Buf, 1024, CancelCheckWork, TmpBuf) / 100) == FTP_PRELIM)\r
+                                                       ;\r
                                        }\r
+                                       else\r
+                                               Sts = FTP_ERROR;\r
                                }\r
-                               else if(Fwall == FWALL_SIDEWINDER)\r
-                               {\r
-                                       Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
-                               }\r
-                               if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
+                               else\r
                                {\r
-                                       SetTaskMsg(MSGJPN006);\r
-                                       DoClose(ContSock);\r
-                                       ContSock = INVALID_SOCKET;\r
+                                       while((Sts = ReadReplyMessage(ContSock, Buf, 1024, CancelCheckWork, TmpBuf) / 100) == FTP_PRELIM)\r
+                                               ;\r
                                }\r
-                               else\r
+\r
+                               if(Sts == FTP_COMPLETE)\r
                                {\r
-                                       if((Fwall == FWALL_FU_FP_SITE) || (Fwall == FWALL_OPEN))\r
+                                       Flg = 1;\r
+                                       if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
+                                               ReportWSError("setsockopt", WSAGetLastError());\r
+                                       // データ転送用ソケットのTCP遅延転送が無効されているので念のため\r
+                                       if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
+                                               ReportWSError("setsockopt", WSAGetLastError());\r
+//#pragma aaa\r
+                                       Flg = 1;\r
+                                       if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
+                                               ReportWSError("setsockopt", WSAGetLastError());\r
+                                       // 切断対策\r
+                                       if(TimeOut > 0)\r
                                        {\r
-                                               Flg = 0;\r
-                                               if(Fwall == FWALL_OPEN)\r
-                                                       Flg = 2;\r
-                                               if(FwallLower == YES)\r
-                                                       Flg++;\r
-\r
-                                               if(HostPort == PORT_NOR)\r
-                                                       Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;\r
-                                               else\r
-                                                       Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
+                                               KeepAlive.onoff = 1;\r
+                                               KeepAlive.keepalivetime = TimeOut * 1000;\r
+                                               KeepAlive.keepaliveinterval = 1000;\r
+                                               if(WSAIoctl(ContSock, SIO_KEEPALIVE_VALS, &KeepAlive, sizeof(struct tcp_keepalive), NULL, 0, &dwTmp, NULL, NULL) == SOCKET_ERROR)\r
+                                                       ReportWSError("WSAIoctl", WSAGetLastError());\r
                                        }\r
+                                       LingerOpt.l_onoff = 1;\r
+                                       LingerOpt.l_linger = 90;\r
+                                       if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)\r
+                                               ReportWSError("setsockopt", WSAGetLastError());\r
+///////\r
 \r
+\r
+                                       /*===== 認証を行なう =====*/\r
+\r
+                                       Sts = FTP_COMPLETE;\r
+                                       if((Fwall == FWALL_FU_FP_SITE) ||\r
+                                          (Fwall == FWALL_FU_FP_USER) ||\r
+                                          (Fwall == FWALL_FU_FP))\r
+                                       {\r
+                                               // 同時接続対応\r
+//                                             if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
+                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
+                                               {\r
+                                                       CheckOneTimePassword(FwallPass, Reply, FwallSecurity);\r
+                                                       // 同時接続対応\r
+//                                                     Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                       Sts = command(ContSock, NULL, CancelCheckWork, "PASS %s", Reply) / 100;\r
+                                               }\r
+                                       }\r
+                                       else if(Fwall == FWALL_SIDEWINDER)\r
+                                       {\r
+                                               // 同時接続対応\r
+//                                             Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
+                                               Sts = command(ContSock, Reply, CancelCheckWork, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
+                                       }\r
                                        if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
                                        {\r
-                                               SetTaskMsg(MSGJPN007, Host);\r
+                                               SetTaskMsg(MSGJPN006);\r
                                                DoClose(ContSock);\r
                                                ContSock = INVALID_SOCKET;\r
                                        }\r
                                        else\r
                                        {\r
-                                               Anony = NO;\r
-                                               if((strlen(User) != 0) || \r
-                                                  (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                               if((Fwall == FWALL_FU_FP_SITE) || (Fwall == FWALL_OPEN))\r
                                                {\r
-                                                       if(Anony == YES)\r
-                                                       {\r
-                                                               strcpy(User, "anonymous");\r
-                                                               strcpy(Pass, UserMailAdrs);\r
-                                                       }\r
-\r
-                                                       if((Fwall == FWALL_FU_FP_USER) || (Fwall == FWALL_USER))\r
-                                                       {\r
-                                                               if(HostPort == PORT_NOR)\r
-                                                                       sprintf(Buf, "%s%c%s", User, FwallDelimiter, Host);\r
-                                                               else\r
-                                                                       sprintf(Buf, "%s%c%s %d", User, FwallDelimiter, Host, HostPort);\r
-                                                       }\r
+                                                       Flg = 0;\r
+                                                       if(Fwall == FWALL_OPEN)\r
+                                                               Flg = 2;\r
+                                                       if(FwallLower == YES)\r
+                                                               Flg++;\r
+\r
+                                                       if(HostPort == PORT_NOR)\r
+                                                               // 同時接続対応\r
+//                                                             Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;\r
+                                                               Sts = command(ContSock, NULL, CancelCheckWork, "%s %s", SiteTbl[Flg], Host) / 100;\r
                                                        else\r
-                                                               strcpy(Buf, User);\r
+                                                               // 同時接続対応\r
+//                                                             Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
+                                                               Sts = command(ContSock, NULL, CancelCheckWork, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
+                                               }\r
 \r
-                                                       ReInPass = NO;\r
-                                                       do\r
+                                               if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
+                                               {\r
+                                                       SetTaskMsg(MSGJPN007, Host);\r
+                                                       DoClose(ContSock);\r
+                                                       ContSock = INVALID_SOCKET;\r
+                                               }\r
+                                               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
+                                                          ((HostData->NoDisplayUI == NO) && (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                        {\r
-                                                               Continue = NO;\r
-                                                               if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
+                                                               if(Anony == YES)\r
                                                                {\r
-                                                                       if((strlen(Pass) != 0) || \r
-                                                                          (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
-                                                                       {\r
-                                                                               CheckOneTimePassword(Pass, Reply, Security);\r
+                                                                       strcpy(User, "anonymous");\r
+                                                                       strcpy(Pass, UserMailAdrs);\r
+                                                               }\r
 \r
-                                                                               /* \83p\83X\83\8f\81[\83h\82ª\83X\83y\81[\83X1\8cÂ\82Ì\8e\9e\82Í\83p\83X\83\8f\81[\83h\82Ì\8eÀ\91Ì\82È\82µ\82Æ\82·\82é */\r
-                                                                               if(strcmp(Reply, " ") == 0)\r
-                                                                                       strcpy(Reply, "");\r
+                                                               if((Fwall == FWALL_FU_FP_USER) || (Fwall == FWALL_USER))\r
+                                                               {\r
+                                                                       if(HostPort == PORT_NOR)\r
+                                                                               sprintf(Buf, "%s%c%s", User, FwallDelimiter, Host);\r
+                                                                       else\r
+                                                                               sprintf(Buf, "%s%c%s %d", User, FwallDelimiter, Host, HostPort);\r
+                                                               }\r
+                                                               else\r
+                                                                       strcpy(Buf, User);\r
 \r
-                                                                               Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
-                                                                               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
-                                                                                               Continue = YES;\r
-                                                                                       else\r
-                                                                                               DoPrintf("No password specified.");\r
-                                                                                       ReInPass = YES;\r
-                                                                               }\r
-                                                                               else if(Sts == FTP_CONTINUE)\r
+                                                               // FTPES対応\r
+                                                               if(CryptMode == CRYPT_FTPES)\r
+                                                               {\r
+                                                                       if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, CancelCheckWork, "AUTH TLS")) == 234)\r
+                                                                       {\r
+                                                                               if(AttachSSL(ContSock, INVALID_SOCKET, CancelCheckWork))\r
                                                                                {\r
-                                                                                       if((strlen(Acct) != 0) || \r
-                                                                                          (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                                                       if((Sts = command(ContSock, Reply, CancelCheckWork, "PBSZ 0")) == 200)\r
                                                                                        {\r
-                                                                                               Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;\r
+                                                                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "PROT P")) == 200)\r
+                                                                                               {\r
+                                                                                               }\r
+                                                                                               else\r
+                                                                                                       Sts = FTP_ERROR;\r
                                                                                        }\r
                                                                                        else\r
-                                                                                               DoPrintf("No account specified");\r
+                                                                                               Sts = FTP_ERROR;\r
                                                                                }\r
+                                                                               else\r
+                                                                                       Sts = FTP_ERROR;\r
                                                                        }\r
                                                                        else\r
-                                                                       {\r
                                                                                Sts = FTP_ERROR;\r
-                                                                               DoPrintf("No password specified.");\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
+                                                                       // FTPES対応\r
+                                                                       if(Sts == FTP_ERROR)\r
+                                                                               break;\r
+                                                                       Continue = NO;\r
+                                                                       // 同時接続対応\r
+//                                                                     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
+                                                                                  ((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
+                                                                                       /* パスワードがスペース1個の時はパスワードの実体なしとする */\r
+                                                                                       if(strcmp(Reply, " ") == 0)\r
+                                                                                               strcpy(Reply, "");\r
+\r
+                                                                                       // 同時接続対応\r
+//                                                                                     Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                                                       Sts = command(ContSock, NULL, CancelCheckWork, "PASS %s", Reply) / 100;\r
+                                                                                       if(Sts == FTP_ERROR)\r
+                                                                                       {\r
+                                                                                               strcpy(Pass, "");\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
+                                                                                               ReInPass = YES;\r
+                                                                                       }\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
+                                                                                                  ((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
+                                                                                                       Sts = command(ContSock, NULL, CancelCheckWork, "ACCT %s", Acct) / 100;\r
+                                                                                               }\r
+                                                                                               else\r
+                                                                                                       DoPrintf("No account specified");\r
+                                                                                       }\r
+                                                                               }\r
+                                                                               else\r
+                                                                               {\r
+                                                                                       Sts = FTP_ERROR;\r
+                                                                                       DoPrintf("No password specified.");\r
+                                                                               }\r
                                                                        }\r
+                                                                       // FTPES対応\r
+                                                                       if(Continue == YES)\r
+                                                                               Sts = FTP_COMPLETE;\r
                                                                }\r
+                                                               while(Continue == YES);\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               Sts = FTP_ERROR;\r
+                                                               DoPrintf("No user name specified");\r
                                                        }\r
-                                                       while(Continue == YES);\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       Sts = FTP_ERROR;\r
-                                                       DoPrintf("No user name specified");\r
-                                               }\r
 \r
-                                               if(Sts != FTP_COMPLETE)\r
-                                               {\r
-                                                       SetTaskMsg(MSGJPN008, Host);\r
-                                                       DoClose(ContSock);\r
-                                                       ContSock = INVALID_SOCKET;\r
-                                               }\r
-                                               else if((SavePass == YES) && (ReInPass == YES))\r
-                                               {\r
-                                                       if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
-                                                               SetHostPassword(AskCurrentHost(), Pass);\r
+                                                       if(Sts != FTP_COMPLETE)\r
+                                                       {\r
+                                                               SetTaskMsg(MSGJPN008, Host);\r
+                                                               DoClose(ContSock);\r
+                                                               ContSock = INVALID_SOCKET;\r
+                                                       }\r
+                                                       else if((SavePass == YES) && (ReInPass == YES))\r
+                                                       {\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
                                        }\r
                                }\r
-                       }\r
-                       else\r
-                       {\r
+                               else\r
+                               {\r
 //#pragma aaa\r
-                               SetTaskMsg(MSGJPN009/*"\90Ú\91±\82Å\82«\82Ü\82¹\82ñ(1) %x", ContSock*/);\r
-                               DoClose(ContSock);\r
-                               ContSock = INVALID_SOCKET;\r
+                                       SetTaskMsg(MSGJPN009/*"接続できません(1) %x", ContSock*/);\r
+                                       DoClose(ContSock);\r
+                                       ContSock = INVALID_SOCKET;\r
+                               }\r
                        }\r
                }\r
-       }\r
-       else\r
-       {\r
-\r
-               if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||\r
-                  (Fwall == FWALL_FU_FP))\r
-                       SetTaskMsg(MSGJPN010);\r
                else\r
-                       SetTaskMsg(MSGJPN011);\r
-       }\r
+               {\r
+\r
+                       if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||\r
+                          (Fwall == FWALL_FU_FP))\r
+                               SetTaskMsg(MSGJPN010);\r
+                       else\r
+                               SetTaskMsg(MSGJPN011);\r
+               }\r
 \r
 #if 0\r
-//     WSAUnhookBlockingHook();\r
+//             WSAUnhookBlockingHook();\r
 #endif\r
-       TryConnect = NO;\r
+               TryConnect = NO;\r
+\r
+               // FEAT対応\r
+               // ホストの機能を確認\r
+               if(ContSock != INVALID_SOCKET)\r
+               {\r
+                       if((Sts = command(ContSock, Reply, CancelCheckWork, "FEAT")) == 211)\r
+                       {\r
+                               // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用\r
+                               // UTF-8対応\r
+                               if(strstr(Reply, " UTF8 "))\r
+                                       HostData->Feature |= FEATURE_UTF8;\r
+                               // MLST対応\r
+                               if(strstr(Reply, " MLST ") || strstr(Reply, " MLSD "))\r
+                                       HostData->Feature |= FEATURE_MLSD;\r
+                               // IPv6対応\r
+                               if(strstr(Reply, " EPRT ") || strstr(Reply, " EPSV "))\r
+                                       HostData->Feature |= FEATURE_EPRT | FEATURE_EPSV;\r
+                               // ホスト側の日時取得\r
+                               if(strstr(Reply, " MDTM "))\r
+                                       HostData->Feature |= FEATURE_MDTM;\r
+                               // ホスト側の日時設定\r
+                               if(strstr(Reply, " MFMT "))\r
+                                       HostData->Feature |= FEATURE_MFMT;\r
+                       }\r
+                       // UTF-8対応\r
+                       if(HostData->CurNameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
+                       {\r
+                               if((Sts = command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON")) == 200)\r
+                                       HostData->CurNameKanjiCode = KANJI_UTF8N;\r
+                       }\r
+               }\r
+       }\r
 \r
        return(ContSock);\r
 }\r
 \r
+// 同時接続対応\r
+//static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)\r
+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork)\r
+{\r
+       SOCKET ContSock;\r
+       ContSock = INVALID_SOCKET;\r
+       *CancelCheckWork = NO;\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)\r
+       {\r
+               SetTaskMsg(MSGJPN316);\r
+               if((ContSock = DoConnectCrypt(CRYPT_FTPIS, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
+                       HostData->CryptMode = CRYPT_FTPIS;\r
+       }\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseFTPES == YES)\r
+       {\r
+               SetTaskMsg(MSGJPN315);\r
+               if((ContSock = DoConnectCrypt(CRYPT_FTPES, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
+                       HostData->CryptMode = CRYPT_FTPES;\r
+       }\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)\r
+       {\r
+               SetTaskMsg(MSGJPN314);\r
+               if((ContSock = DoConnectCrypt(CRYPT_NONE, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
+                       HostData->CryptMode = CRYPT_NONE;\r
+       }\r
+       return ContSock;\r
+}\r
+\r
 \r
-/*----- \83\8f\83\93\83^\83C\83\80\83p\83X\83\8f\81[\83h\82Ì\83`\83F\83b\83N ----------------------------------------\r
+/*----- ワンタイムパスワードのチェック ----------------------------------------\r
 *\r
 *      Parameter\r
-*              chat *Pass : \83p\83X\83\8f\81[\83h\81^\83p\83X\83t\83\8c\81[\83Y\r
-*              char *Reply : USER\83R\83}\83\93\83h\82ð\91\97\82Á\82½\82 \82Æ\82Ì\83\8a\83v\83\89\83C\95\8e\9a\97ñ\r
-*                                              \81^PASS\83R\83}\83\93\83h\82Å\91\97\82é\83p\83X\83\8f\81[\83h\82ð\95Ô\82·\83o\83b\83t\83@\r
-*              int Type : \83^\83C\83v (SECURITY_xxx, MDx)\r
+*              chat *Pass : パスワード/パスフレーズ\r
+*              char *Reply : USERコマンドを送ったあとのリプライ文字列\r
+*                                              /PASSコマンドで送るパスワードを返すバッファ\r
+*              int Type : タイプ (SECURITY_xxx, MDx)\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *\r
 *      Note\r
-*              \83\8f\83\93\83^\83C\83\80\83p\83X\83\8f\81[\83h\82Å\82È\82¢\8e\9e\82ÍPass\82ð\82»\82Ì\82Ü\82ÜReply\82É\83R\83s\81[\r
+*              ワンタイムパスワードでない時はPassをそのままReplyにコピー\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int CheckOneTimePassword(char *Pass, char *Reply, int Type)\r
@@ -1416,7 +1848,7 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
        char Seed[MAX_SEED_LEN+1];\r
        int i;\r
 \r
-       Sts = SUCCESS;\r
+       Sts = FFFTP_SUCCESS;\r
        Pos = NULL;\r
 \r
        if(Type == SECURITY_AUTO)\r
@@ -1442,10 +1874,10 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
 \r
        if((Type == MD4) || (Type == MD5) || (Type == SHA1))\r
        {\r
-               /* \83V\81[\83P\83\93\83X\94Ô\8d\86\82ð\8c©\82Â\82¯\82é\83\8b\81[\83v */\r
+               /* シーケンス番号を見つけるループ */\r
                DoPrintf("Analize OTP");\r
                DoPrintf("%s", Pos);\r
-               Sts = FAIL;\r
+               Sts = FFFTP_FAIL;\r
                while((Pos = GetNextField(Pos)) != NULL)\r
                {\r
                        if(IsDigit(*Pos))\r
@@ -1456,9 +1888,9 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
                                /* Seed */\r
                                if((Pos = GetNextField(Pos)) != NULL)\r
                                {\r
-                                       if(GetOneField(Pos, Seed, MAX_SEED_LEN) == SUCCESS)\r
+                                       if(GetOneField(Pos, Seed, MAX_SEED_LEN) == FFFTP_SUCCESS)\r
                                        {\r
-                                               /* Seed\82Í\89p\90\94\8e\9a\82Ì\82Ý\97L\8cø\82Æ\82·\82é */\r
+                                               /* Seedは英数字のみ有効とする */\r
                                                for(i = strlen(Seed)-1; i >= 0; i--)\r
                                                {\r
                                                        if((IsAlpha(Seed[i]) == 0) && (IsDigit(Seed[i]) == 0))\r
@@ -1470,11 +1902,11 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
                                                        Make6WordPass(Seq, Seed, Pass, Type, Reply);\r
                                                        DoPrintf("Response=%s", Reply);\r
 \r
-                                                       /* \83V\81[\83P\83\93\83X\94Ô\8d\86\82Ì\83`\83F\83b\83N\82Æ\8cx\8d\90 */\r
+                                                       /* シーケンス番号のチェックと警告 */\r
                                                        if(Seq <= 10)\r
                                                                DialogBox(GetFtpInst(), MAKEINTRESOURCE(otp_notify_dlg), GetMainHwnd(), ExeEscDialogProc);\r
 \r
-                                                       Sts = SUCCESS;\r
+                                                       Sts = FFFTP_SUCCESS;\r
                                                }\r
                                        }\r
                                }\r
@@ -1482,7 +1914,7 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
                        }\r
                }\r
 \r
-               if(Sts == FAIL)\r
+               if(Sts == FFFTP_FAIL)\r
                        SetTaskMsg(MSGJPN015);\r
        }\r
        else\r
@@ -1506,88 +1938,223 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
 \r
 \r
 \r
-/*----- \83\\83P\83b\83g\82ð\90Ú\91±\82·\82é ----------------------------------------------------\r
+/*----- ソケットを接続する ----------------------------------------------------\r
 *\r
 *      Parameter\r
-*              char *host : \83z\83X\83g\96¼\r
-*              int port : \83|\81[\83g\94Ô\8d\86\r
-*              char *PreMsg : \83\81\83b\83Z\81[\83W\82Ì\91O\94¼\95\94\95ª\r
+*              char *host : ホスト名\r
+*              int port : ポート番号\r
+*              char *PreMsg : メッセージの前半部分\r
 *\r
 *      Return Value\r
-*              SOCKET \83\\83P\83b\83g\r
+*              SOCKET ソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
-SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
-{\r
-       struct sockaddr_in saSockAddr;\r
-       char HostEntry[MAXGETHOSTSTRUCT];\r
-       struct hostent *pHostEntry;\r
-       SOCKET sSocket;\r
-       int Len;\r
-       int Fwall;\r
-       SOCKS4CMD Socks4Cmd;\r
-       SOCKS4REPLY Socks4Reply;\r
-       SOCKS5REQUEST Socks5Cmd;\r
-       SOCKS5REPLY Socks5Reply;\r
-\r
-       //////////////////////////////\r
-       // \83z\83X\83g\96¼\89ð\8c\88\82Æ\90Ú\91±\82Ì\8f\80\94õ\r
-       //////////////////////////////\r
-\r
-       Fwall = FWALL_NONE;\r
-       if(AskHostFireWall() == YES)\r
-               Fwall = FwallType;\r
+// IPv6対応\r
+typedef SOCKET (__cdecl* LPCONNECTSOCK)(char*, int, char*, int*);\r
 \r
-       sSocket = INVALID_SOCKET;\r
+typedef struct\r
+{\r
+       HANDLE h;\r
+       DWORD ExitCode;\r
+       char *host;\r
+       int port;\r
+       char *PreMsg;\r
+       int CancelCheckWork;\r
+       LPCONNECTSOCK f;\r
+       SOCKET s;\r
+} CONNECTSOCKDATA;\r
+\r
+DWORD WINAPI connectsockThreadProc(LPVOID lpParameter)\r
+{\r
+       CONNECTSOCKDATA* pData;\r
+       pData = (CONNECTSOCKDATA*)lpParameter;\r
+       pData->s = pData->f(pData->host, pData->port, pData->PreMsg, &pData->CancelCheckWork);\r
+       return 0;\r
+}\r
 \r
-       UseIPadrs = YES;\r
-       strcpy(DomainName, host);\r
-       memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
-       CurSockAddr.sin_port = htons((u_short)port);\r
-       CurSockAddr.sin_family = AF_INET;\r
+// IPv6対応\r
+SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+{\r
+       SOCKET Result;\r
+       CONNECTSOCKDATA DataIPv4;\r
+       CONNECTSOCKDATA DataIPv6;\r
+       Result = INVALID_SOCKET;\r
+       switch(CurHost.CurNetType)\r
+       {\r
+       case NTYPE_AUTO:\r
+//             if((Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
+//                     CurHost.CurNetType = NTYPE_IPV4;\r
+//             else if((Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
+//                     CurHost.CurNetType = NTYPE_IPV6;\r
+               DataIPv4.host = host;\r
+               DataIPv4.port = port;\r
+               DataIPv4.PreMsg = PreMsg;\r
+               DataIPv4.CancelCheckWork = *CancelCheckWork;\r
+               DataIPv4.f = connectsockIPv4;\r
+               DataIPv4.h = CreateThread(NULL, 0, connectsockThreadProc, &DataIPv4, 0, NULL);\r
+               DataIPv6.host = host;\r
+               DataIPv6.port = port;\r
+               DataIPv6.PreMsg = PreMsg;\r
+               DataIPv6.CancelCheckWork = *CancelCheckWork;\r
+               DataIPv6.f = connectsockIPv6;\r
+               DataIPv6.h = CreateThread(NULL, 0, connectsockThreadProc, &DataIPv6, 0, NULL);\r
+               while(1)\r
+               {\r
+                       if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode))\r
+                       {\r
+                               if(DataIPv4.ExitCode != STILL_ACTIVE)\r
+                               {\r
+                                       if(DataIPv4.s != INVALID_SOCKET)\r
+                                       {\r
+                                               Result = DataIPv4.s;\r
+                                               CurHost.CurNetType = NTYPE_IPV4;\r
+                                               break;\r
+                                       }\r
+                               }\r
+                       }\r
+                       if(GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+                       {\r
+                               if(DataIPv6.ExitCode != STILL_ACTIVE)\r
+                               {\r
+                                       if(DataIPv6.s != INVALID_SOCKET)\r
+                                       {\r
+                                               Result = DataIPv6.s;\r
+                                               CurHost.CurNetType = NTYPE_IPV6;\r
+                                               break;\r
+                                       }\r
+                               }\r
+                       }\r
+                       if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode) && GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+                       {\r
+                               if(DataIPv4.ExitCode != STILL_ACTIVE && DataIPv6.ExitCode != STILL_ACTIVE)\r
+                               {\r
+                                       if(DataIPv4.s == INVALID_SOCKET && DataIPv6.s == INVALID_SOCKET)\r
+                                               break;\r
+                               }\r
+                       }\r
+                       DataIPv4.CancelCheckWork = *CancelCheckWork;\r
+                       DataIPv6.CancelCheckWork = *CancelCheckWork;\r
+                       BackgrndMessageProc();\r
+                       Sleep(1);\r
+               }\r
+               while(1)\r
+               {\r
+                       if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode) && GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+                       {\r
+                               if(DataIPv4.ExitCode != STILL_ACTIVE && DataIPv6.ExitCode != STILL_ACTIVE)\r
+                               {\r
+                                       CloseHandle(DataIPv4.h);\r
+                                       CloseHandle(DataIPv6.h);\r
+                                       break;\r
+                               }\r
+                       }\r
+                       DataIPv4.CancelCheckWork = YES;\r
+                       DataIPv6.CancelCheckWork = YES;\r
+                       BackgrndMessageProc();\r
+                       Sleep(1);\r
+               }\r
+               break;\r
+       case NTYPE_IPV4:\r
+               Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV4;\r
+               break;\r
+       case NTYPE_IPV6:\r
+               Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV6;\r
+               break;\r
+       }\r
+       return Result;\r
+}\r
+\r
+\r
+// IPv6対応\r
+//SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+SOCKET connectsockIPv4(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+{\r
+       // IPv6対応\r
+       struct sockaddr_in SocksSockAddr;       /* SOCKSサーバのアドレス情報 */\r
+       struct sockaddr_in CurSockAddr;         /* 接続先ホストのアドレス情報 */\r
+       struct sockaddr_in saSockAddr;\r
+       char HostEntry[MAXGETHOSTSTRUCT];\r
+       struct hostent *pHostEntry;\r
+       SOCKET sSocket;\r
+       int Len;\r
+       int Fwall;\r
+       SOCKS4CMD Socks4Cmd;\r
+       SOCKS4REPLY Socks4Reply;\r
+       SOCKS5REQUEST Socks5Cmd;\r
+       SOCKS5REPLY Socks5Reply;\r
+\r
+       //////////////////////////////\r
+       // ホスト名解決と接続の準備\r
+       //////////////////////////////\r
+\r
+       Fwall = FWALL_NONE;\r
+       if(AskHostFireWall() == YES)\r
+               Fwall = FwallType;\r
+\r
+       sSocket = INVALID_SOCKET;\r
+\r
+       UseIPadrs = YES;\r
+       strcpy(DomainName, host);\r
+       memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
+       CurSockAddr.sin_port = htons((u_short)port);\r
+       CurSockAddr.sin_family = AF_INET;\r
        if((CurSockAddr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)\r
        {\r
-               // \83z\83X\83g\96¼\82ª\8ew\92è\82³\82ê\82½\r
-               // \83z\83X\83g\96¼\82©\82ç\83A\83h\83\8c\83X\82ð\8b\81\82ß\82é\r
+               // ホスト名が指定された\r
+               // ホスト名からアドレスを求める\r
                if(((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER)) &&\r
                   (FwallResolv == YES))\r
                {\r
-                       // \83z\83X\83g\96¼\89ð\8c\88\82ÍSOCKS\83T\81[\83o\82É\94C\82¹\82é\r
+                       // ホスト名解決はSOCKSサーバに任せる\r
                        pHostEntry = NULL;\r
                }\r
                else\r
                {\r
-                       // \83A\83h\83\8c\83X\82ð\8eæ\93¾\r
-                       SetTaskMsg(MSGJPN016, DomainName);\r
-                       pHostEntry = do_gethostbyname(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+                       // アドレスを取得\r
+                       // IPv6対応\r
+//                     SetTaskMsg(MSGJPN016, DomainName);\r
+                       SetTaskMsg(MSGJPN016, DomainName, MSGJPN333);\r
+                       // IPv6対応\r
+//                     pHostEntry = do_gethostbyname(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+                       pHostEntry = do_gethostbynameIPv4(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
                }\r
 \r
                if(pHostEntry != NULL)\r
                {\r
                        memcpy((char *)&CurSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
-                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+                       // IPv6対応\r
+//                     SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port), MSGJPN333);\r
                }\r
                else\r
                {\r
                        if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
                        {\r
                                UseIPadrs = NO;\r
-                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port));\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port));\r
+                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port), MSGJPN333);\r
                        }\r
                        else\r
                        {\r
-                               SetTaskMsg(MSGJPN019, host);\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN019, host);\r
+                               SetTaskMsg(MSGJPN019, host, MSGJPN333);\r
                                return(INVALID_SOCKET);\r
                        }\r
                }\r
        }\r
        else\r
-               SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+               // IPv6対応\r
+//             SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+               SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port), MSGJPN333);\r
 \r
        if((Fwall == FWALL_SOCKS4) || (Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
        {\r
-               // SOCKS\82ð\8eg\82¤\r
-               // SOCKS\82É\90Ú\91±\82·\82é\8f\80\94õ\r
+               // SOCKSを使う\r
+               // SOCKSに接続する準備\r
                if(Fwall == FWALL_SOCKS4)\r
                {\r
                        Socks4Cmd.Ver = SOCKS4_VER;\r
@@ -1605,60 +2172,80 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
                if((SocksSockAddr.sin_addr.s_addr = inet_addr(FwallHost)) == INADDR_NONE)\r
                {\r
-                       if((pHostEntry = do_gethostbyname(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+                       // IPv6対応\r
+//                     if((pHostEntry = do_gethostbyname(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+                       if((pHostEntry = do_gethostbynameIPv4(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
                                memcpy((char *)&SocksSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
                        else\r
                        {\r
-                               SetTaskMsg(MSGJPN021, FwallHost);\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN021, FwallHost);\r
+                               SetTaskMsg(MSGJPN021, FwallHost, MSGJPN333);\r
                                return INVALID_SOCKET;\r
                        }\r
                }\r
                SocksSockAddr.sin_port = htons((u_short)FwallPort);\r
                SocksSockAddr.sin_family = AF_INET;\r
-               SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port));\r
-               // connect\82Å\90Ú\91±\82·\82é\90æ\82ÍSOCKS\83T\81[\83o\r
+               // IPv6対応\r
+//             SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port));\r
+               SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port), MSGJPN333);\r
+               // connectで接続する先はSOCKSサーバ\r
                memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
        }\r
        else\r
        {\r
-               // connect\82Å\90Ú\91±\82·\82é\82Ì\82Í\90Ú\91±\90æ\82Ì\83z\83X\83g\r
+               // connectで接続するのは接続先のホスト\r
                memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
        }\r
 \r
        /////////////\r
-       // \90Ú\91±\8eÀ\8ds\r
+       // 接続実行\r
        /////////////\r
 \r
        if((sSocket = do_socket(AF_INET, SOCK_STREAM, TCP_PORT)) != INVALID_SOCKET)\r
        {\r
+               // ソケットにデータを付与\r
+               SetAsyncTableDataIPv4(sSocket, &CurSockAddr, &SocksSockAddr);\r
                if(do_connect(sSocket, (struct sockaddr *)&saSockAddr, sizeof(saSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
                {\r
                        if(Fwall == FWALL_SOCKS4)\r
                        {\r
                                Socks4Reply.Result = -1;\r
-                               if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != SUCCESS) ||\r
-                                  (Socks4GetCmdReply(sSocket, &Socks4Reply) != SUCCESS) || \r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks4GetCmdReply(sSocket, &Socks4Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks4Reply.Result != SOCKS4_RES_OK))\r
+                               if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks4GetCmdReply(sSocket, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
-                                       SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
+                                       // IPv6対応\r
+//                                     SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
+                                       SetTaskMsg(MSGJPN023, Socks4Reply.Result, MSGJPN333);\r
                                        DoClose(sSocket);\r
                                        sSocket = INVALID_SOCKET;\r
                                }\r
                        }\r
                        else if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
                        {\r
-                               if(Socks5SelMethod(sSocket, CancelCheckWork) == FAIL)\r
+                               if(Socks5SelMethod(sSocket, CancelCheckWork) == FFFTP_FAIL)\r
                                {\r
                                        DoClose(sSocket);\r
                                        sSocket = INVALID_SOCKET;\r
                                }\r
 \r
                                Socks5Reply.Result = -1;\r
-                               if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != SUCCESS) ||\r
-                                  (Socks5GetCmdReply(sSocket, &Socks5Reply) != SUCCESS) || \r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(sSocket, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
-                                       SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+                                       // IPv6対応\r
+//                                     SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+                                       SetTaskMsg(MSGJPN024, Socks5Reply.Result, MSGJPN333);\r
                                        DoClose(sSocket);\r
                                        sSocket = INVALID_SOCKET;\r
                                }\r
@@ -1666,34 +2253,215 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                        }\r
 \r
                        if(sSocket != INVALID_SOCKET)\r
-                               SetTaskMsg(MSGJPN025);\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN025);\r
+                               SetTaskMsg(MSGJPN025, MSGJPN333);\r
                }\r
                else\r
                {\r
 //#pragma aaa\r
-                       SetTaskMsg(MSGJPN026/*"\90Ú\91±\82Å\82«\82Ü\82¹\82ñ(2) %x", sSocket*/);\r
+                       // IPv6対応\r
+//                     SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/);\r
+                       SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/, MSGJPN333);\r
                        DoClose(sSocket);\r
                        sSocket = INVALID_SOCKET;\r
                }\r
        }\r
        else\r
-               SetTaskMsg(MSGJPN027);\r
+               // IPv6対応\r
+//             SetTaskMsg(MSGJPN027);\r
+               SetTaskMsg(MSGJPN027, MSGJPN333);\r
 \r
        return(sSocket);\r
 }\r
 \r
 \r
-/*----- \83\8a\83b\83X\83\93\83\\83P\83b\83g\82ð\8eæ\93¾ ------------------------------------------------\r
+SOCKET connectsockIPv6(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+{\r
+       struct sockaddr_in6 SocksSockAddr;      /* SOCKSサーバのアドレス情報 */\r
+       struct sockaddr_in6 CurSockAddr;                /* 接続先ホストのアドレス情報 */\r
+       struct sockaddr_in6 saSockAddr;\r
+       char HostEntry[MAXGETHOSTSTRUCT];\r
+       struct hostent *pHostEntry;\r
+       SOCKET sSocket;\r
+       int Len;\r
+       int Fwall;\r
+       SOCKS5REQUEST Socks5Cmd;\r
+       SOCKS5REPLY Socks5Reply;\r
+\r
+       //////////////////////////////\r
+       // ホスト名解決と接続の準備\r
+       //////////////////////////////\r
+\r
+       Fwall = FWALL_NONE;\r
+       if(AskHostFireWall() == YES)\r
+               Fwall = FwallType;\r
+\r
+       sSocket = INVALID_SOCKET;\r
+\r
+       UseIPadrs = YES;\r
+       strcpy(DomainName, host);\r
+       memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
+       CurSockAddr.sin6_port = htons((u_short)port);\r
+       CurSockAddr.sin6_family = AF_INET6;\r
+       CurSockAddr.sin6_addr = inet6_addr(host);\r
+       if(memcmp(&CurSockAddr.sin6_addr, &IN6ADDR_NONE, sizeof(struct in6_addr)) == 0)\r
+       {\r
+               // ホスト名が指定された\r
+               // ホスト名からアドレスを求める\r
+               if(((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER)) &&\r
+                  (FwallResolv == YES))\r
+               {\r
+                       // ホスト名解決はSOCKSサーバに任せる\r
+                       pHostEntry = NULL;\r
+               }\r
+               else\r
+               {\r
+                       // アドレスを取得\r
+                       SetTaskMsg(MSGJPN016, DomainName, MSGJPN334);\r
+                       pHostEntry = do_gethostbynameIPv6(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+               }\r
+\r
+               if(pHostEntry != NULL)\r
+               {\r
+                       memcpy((char *)&CurSockAddr.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet6_ntoa(CurSockAddr.sin6_addr), ntohs(CurSockAddr.sin6_port), MSGJPN334);\r
+               }\r
+               else\r
+               {\r
+                       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+                       {\r
+                               UseIPadrs = NO;\r
+                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin6_port), MSGJPN334);\r
+                       }\r
+                       else\r
+                       {\r
+                               SetTaskMsg(MSGJPN019, host, MSGJPN334);\r
+                               return(INVALID_SOCKET);\r
+                       }\r
+               }\r
+       }\r
+       else\r
+               SetTaskMsg(MSGJPN020, PreMsg, inet6_ntoa(CurSockAddr.sin6_addr), ntohs(CurSockAddr.sin6_port), MSGJPN334);\r
+\r
+       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+       {\r
+               // SOCKSを使う\r
+               // SOCKSに接続する準備\r
+               {\r
+                       Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, (char*)&CurSockAddr.sin6_addr, DomainName, CurSockAddr.sin6_port);\r
+               }\r
+\r
+               memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
+               SocksSockAddr.sin6_addr = inet6_addr(FwallHost);\r
+               if(memcmp(&SocksSockAddr.sin6_addr, &IN6ADDR_NONE, sizeof(struct in6_addr)) == 0)\r
+               {\r
+                       if((pHostEntry = do_gethostbynameIPv6(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+                               memcpy((char *)&SocksSockAddr.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       else\r
+                       {\r
+                               SetTaskMsg(MSGJPN021, FwallHost, MSGJPN334);\r
+                               return INVALID_SOCKET;\r
+                       }\r
+               }\r
+               SocksSockAddr.sin6_port = htons((u_short)FwallPort);\r
+               SocksSockAddr.sin6_family = AF_INET6;\r
+               SetTaskMsg(MSGJPN022, inet6_ntoa(SocksSockAddr.sin6_addr), ntohs(SocksSockAddr.sin6_port), MSGJPN334);\r
+               // connectで接続する先はSOCKSサーバ\r
+               memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
+       }\r
+       else\r
+       {\r
+               // connectで接続するのは接続先のホスト\r
+               memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
+       }\r
+\r
+       /////////////\r
+       // 接続実行\r
+       /////////////\r
+\r
+       if((sSocket = do_socket(AF_INET6, SOCK_STREAM, TCP_PORT)) != INVALID_SOCKET)\r
+       {\r
+               // ソケットにデータを付与\r
+               SetAsyncTableDataIPv6(sSocket, &CurSockAddr, &SocksSockAddr);\r
+               if(do_connect(sSocket, (struct sockaddr *)&saSockAddr, sizeof(saSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+               {\r
+                       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+                       {\r
+                               if(Socks5SelMethod(sSocket, CancelCheckWork) == FFFTP_FAIL)\r
+                               {\r
+                                       DoClose(sSocket);\r
+                                       sSocket = INVALID_SOCKET;\r
+                               }\r
+\r
+                               Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(sSocket, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
+                                  (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               {\r
+                                       SetTaskMsg(MSGJPN024, Socks5Reply.Result, MSGJPN334);\r
+                                       DoClose(sSocket);\r
+                                       sSocket = INVALID_SOCKET;\r
+                               }\r
+\r
+                       }\r
+\r
+                       if(sSocket != INVALID_SOCKET)\r
+                               SetTaskMsg(MSGJPN025, MSGJPN334);\r
+               }\r
+               else\r
+               {\r
+//#pragma aaa\r
+                       SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/, MSGJPN334);\r
+                       DoClose(sSocket);\r
+                       sSocket = INVALID_SOCKET;\r
+               }\r
+       }\r
+       else\r
+               SetTaskMsg(MSGJPN027, MSGJPN334);\r
+\r
+       return(sSocket);\r
+}\r
+\r
+\r
+/*----- リッスンソケットを取得 ------------------------------------------------\r
 *\r
 *      Parameter\r
-*              SOCKET ctrl_skt : \83R\83\93\83g\83\8d\81[\83\8b\83\\83P\83b\83g\r
+*              SOCKET ctrl_skt : コントロールソケット\r
 *\r
 *      Return Value\r
-*              SOCKET \83\8a\83b\83X\83\93\83\\83P\83b\83g\r
+*              SOCKET リッスンソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
+// IPv6対応\r
 SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
 {\r
+       SOCKET Result;\r
+       Result = INVALID_SOCKET;\r
+       switch(CurHost.CurNetType)\r
+       {\r
+       case NTYPE_IPV4:\r
+               Result = GetFTPListenSocketIPv4(ctrl_skt, CancelCheckWork);\r
+               break;\r
+       case NTYPE_IPV6:\r
+               Result = GetFTPListenSocketIPv6(ctrl_skt, CancelCheckWork);\r
+               break;\r
+       }\r
+       return Result;\r
+}\r
+\r
+\r
+// IPv6対応\r
+//SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
+SOCKET GetFTPListenSocketIPv4(SOCKET ctrl_skt, int *CancelCheckWork)\r
+{\r
+       // IPv6対応\r
+       struct sockaddr_in SocksSockAddr;       /* SOCKSサーバのアドレス情報 */\r
+       struct sockaddr_in CurSockAddr;         /* 接続先ホストのアドレス情報 */\r
     SOCKET listen_skt;\r
     int iLength;\r
     char *a,*p;\r
@@ -1707,6 +2475,9 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
        int Len;\r
        int Fwall;\r
 \r
+       // ソケットにデータを付与\r
+       GetAsyncTableDataIPv4(ctrl_skt, &CurSockAddr, &SocksSockAddr);\r
+\r
        Fwall = FWALL_NONE;\r
        if(AskHostFireWall() == YES)\r
                Fwall = FwallType;\r
@@ -1715,7 +2486,7 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
        {\r
                if(Fwall == FWALL_SOCKS4)\r
                {\r
-                       /*===== SOCKS4\82ð\8eg\82¤ =====*/\r
+                       /*===== SOCKS4を使う =====*/\r
                        DoPrintf("Use SOCKS4 BIND");\r
                        if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
                        {\r
@@ -1727,11 +2498,17 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                                Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
 \r
                                Socks4Reply.Result = -1;\r
-                               if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != SUCCESS) ||\r
-                                  (Socks4GetCmdReply(listen_skt, &Socks4Reply) != SUCCESS) || \r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks4GetCmdReply(listen_skt, &Socks4Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks4Reply.Result != SOCKS4_RES_OK))\r
+                               if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks4GetCmdReply(listen_skt, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
-                                       SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
+                                       // IPv6対応\r
+//                                     SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
+                                       SetTaskMsg(MSGJPN028, Socks4Reply.Result, MSGJPN333);\r
                                        DoClose(listen_skt);\r
                                        listen_skt = INVALID_SOCKET;\r
                                }\r
@@ -1745,11 +2522,11 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                }\r
                else if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
                {\r
-                       /*===== SOCKS5\82ð\8eg\82¤ =====*/\r
+                       /*===== SOCKS5を使う =====*/\r
                        DoPrintf("Use SOCKS5 BIND");\r
                        if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
                        {\r
-                               if(Socks5SelMethod(listen_skt, CancelCheckWork) == FAIL)\r
+                               if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
                                {\r
                                        DoClose(listen_skt);\r
                                        listen_skt = INVALID_SOCKET;\r
@@ -1759,25 +2536,35 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                                Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
 \r
                                Socks5Reply.Result = -1;\r
-                               if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != SUCCESS) ||\r
-                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply) != SUCCESS) || \r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(listen_skt, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
-                                       SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+                                       // IPv6対応\r
+//                                     SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+                                       SetTaskMsg(MSGJPN029, Socks5Reply.Result, MSGJPN333);\r
                                        DoClose(listen_skt);\r
                                        listen_skt = INVALID_SOCKET;\r
                                }\r
 \r
-                               if(Socks5Reply.AdrsInt == 0)\r
-                                       Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+                               // IPv6対応\r
+//                             if(Socks5Reply.AdrsInt == 0)\r
+//                                     Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
 \r
-                               a = (char *)&Socks5Reply.AdrsInt;\r
-                               p = (char *)&Socks5Reply.Port;\r
+                               // IPv6対応\r
+//                             a = (char *)&Socks5Reply.AdrsInt;\r
+//                             p = (char *)&Socks5Reply.Port;\r
+                               a = (char *)&Socks5Reply._dummy[0];\r
+                               p = (char *)&Socks5Reply._dummy[4];\r
                        }\r
                }\r
                else\r
                {\r
-                       /*===== SOCKS\82ð\8eg\82í\82È\82¢ =====*/\r
+                       /*===== SOCKSを使わない =====*/\r
                        DoPrintf("Use normal BIND");\r
                        saCtrlAddr.sin_port = htons(0);\r
                        saCtrlAddr.sin_family = AF_INET;\r
@@ -1819,7 +2606,9 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                        }\r
 \r
                        if(listen_skt == INVALID_SOCKET)\r
-                               SetTaskMsg(MSGJPN030);\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN030);\r
+                               SetTaskMsg(MSGJPN030, MSGJPN333);\r
                }\r
        }\r
        else\r
@@ -1828,11 +2617,17 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
        if(listen_skt != INVALID_SOCKET)\r
        {\r
 #define  UC(b)  (((int)b)&0xff)\r
-               if((command(ctrl_skt,NULL, &CancelFlg, "PORT %d,%d,%d,%d,%d,%d",\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, "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
                {\r
-                       SetTaskMsg(MSGJPN031);\r
+                       // IPv6対応\r
+//                     SetTaskMsg(MSGJPN031);\r
+                       SetTaskMsg(MSGJPN031, MSGJPN333);\r
                        do_closesocket(listen_skt);\r
                        listen_skt = INVALID_SOCKET;\r
                }\r
@@ -1844,13 +2639,152 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
 }\r
 \r
 \r
-/*----- \83z\83X\83g\82Ö\90Ú\91±\8f\88\97\9d\92\86\82©\82Ç\82¤\82©\82ð\95Ô\82·---------------------------------------\r
+SOCKET GetFTPListenSocketIPv6(SOCKET ctrl_skt, int *CancelCheckWork)\r
+{\r
+       struct sockaddr_in6 SocksSockAddr;      /* SOCKSサーバのアドレス情報 */\r
+       struct sockaddr_in6 CurSockAddr;                /* 接続先ホストのアドレス情報 */\r
+    SOCKET listen_skt;\r
+    int iLength;\r
+    char *a,*p;\r
+       struct sockaddr_in6 saCtrlAddr;\r
+       struct sockaddr_in6 saTmpAddr;\r
+       SOCKS5REQUEST Socks5Cmd;\r
+       SOCKS5REPLY Socks5Reply;\r
+\r
+       int Len;\r
+       int Fwall;\r
+\r
+       char Adrs[40];\r
+\r
+       // ソケットにデータを付与\r
+       GetAsyncTableDataIPv6(ctrl_skt, &CurSockAddr, &SocksSockAddr);\r
+\r
+       Fwall = FWALL_NONE;\r
+       if(AskHostFireWall() == YES)\r
+               Fwall = FwallType;\r
+\r
+       if((listen_skt = do_socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) != INVALID_SOCKET)\r
+       {\r
+               if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+               {\r
+                       /*===== SOCKS5を使う =====*/\r
+                       DoPrintf("Use SOCKS5 BIND");\r
+                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+                       {\r
+                               if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
+                               {\r
+                                       DoClose(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                                       return(listen_skt);\r
+                               }\r
+\r
+                               Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, (char*)&CurSockAddr.sin6_addr, DomainName, CurSockAddr.sin6_port);\r
+\r
+                               Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(listen_skt, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
+                                  (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               {\r
+                                       SetTaskMsg(MSGJPN029, Socks5Reply.Result, MSGJPN334);\r
+                                       DoClose(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                               }\r
+\r
+                               // IPv6対応\r
+//                             if(Socks5Reply.AdrsInt == 0)\r
+//                                     Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+\r
+                               // IPv6対応\r
+//                             a = (char *)&Socks5Reply.AdrsInt;\r
+//                             p = (char *)&Socks5Reply.Port;\r
+                               a = (char *)&Socks5Reply._dummy[0];\r
+                               p = (char *)&Socks5Reply._dummy[16];\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       /*===== SOCKSを使わない =====*/\r
+                       DoPrintf("Use normal BIND");\r
+                       saCtrlAddr.sin6_port = htons(0);\r
+                       saCtrlAddr.sin6_family = AF_INET6;\r
+                       memset(&saCtrlAddr.sin6_addr, 0, 16);\r
+\r
+                       if(bind(listen_skt, (struct sockaddr *)&saCtrlAddr, sizeof(struct sockaddr_in6)) != SOCKET_ERROR)\r
+                       {\r
+                               iLength = sizeof(saCtrlAddr);\r
+                               if(getsockname(listen_skt, (struct sockaddr *)&saCtrlAddr, &iLength) != SOCKET_ERROR)\r
+                               {\r
+                                       if(do_listen(listen_skt, 1) == 0)\r
+                                       {\r
+                                               iLength = sizeof(saTmpAddr);\r
+                                               if(getsockname(ctrl_skt, (struct sockaddr *)&saTmpAddr, &iLength) == SOCKET_ERROR)\r
+                                                       ReportWSError("getsockname", WSAGetLastError());\r
+\r
+                                               a = (char *)&saTmpAddr.sin6_addr;\r
+                                               p = (char *)&saCtrlAddr.sin6_port;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               ReportWSError("listen", WSAGetLastError());\r
+                                               do_closesocket(listen_skt);\r
+                                               listen_skt = INVALID_SOCKET;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       ReportWSError("getsockname", WSAGetLastError());\r
+                                       do_closesocket(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               ReportWSError("bind", WSAGetLastError());\r
+                               do_closesocket(listen_skt);\r
+                               listen_skt = INVALID_SOCKET;\r
+                       }\r
+\r
+                       if(listen_skt == INVALID_SOCKET)\r
+                               SetTaskMsg(MSGJPN030, MSGJPN334);\r
+               }\r
+       }\r
+       else\r
+               ReportWSError("socket create", WSAGetLastError());\r
+\r
+       if(listen_skt != INVALID_SOCKET)\r
+       {\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
+                               (UC(p[0]) << 8) | UC(p[1])) / 100) != FTP_COMPLETE)\r
+               {\r
+                       SetTaskMsg(MSGJPN031, MSGJPN334);\r
+                       do_closesocket(listen_skt);\r
+                       listen_skt = INVALID_SOCKET;\r
+               }\r
+//             else\r
+//                     DoPrintf("Skt=%u : listener %s port %u",listen_skt,inet_ntoa(saCtrlAddr.sin_addr),ntohs(saCtrlAddr.sin_port));\r
+       }\r
+\r
+       return(listen_skt);\r
+}\r
+\r
+\r
+/*----- ホストへ接続処理中かどうかを返す---------------------------------------\r
 *\r
 *      Parameter\r
-*              \82È\82µ\r
+*              なし\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
+*              int ステータス\r
 *                      YES/NO\r
 *----------------------------------------------------------------------------*/\r
 \r
@@ -1861,10 +2795,10 @@ int AskTryingConnect(void)
 \r
 \r
 #if 0\r
-///*----- \83u\83\8d\83b\83L\83\93\83O\83R\81[\83\8b\82Ì\83t\83b\83N\83R\81[\83\8b\83o\83b\83N --------------------------------\r
+///*----- ブロッキングコールのフックコールバック --------------------------------\r
 //*\r
 //*    Parameter\r
-//*            \82È\82µ\r
+//*            なし\r
 //*\r
 //*    Return Value\r
 //*            BOOL FALSE\r
@@ -1886,18 +2820,18 @@ int AskTryingConnect(void)
 \r
 \r
 \r
-/*----- SOCKS5\82Ì\83R\83}\83\93\83h\83p\83P\83b\83g\82ð\8dì\90¬\82·\82é ------------------------------------\r
+/*----- SOCKS5のコマンドパケットを作成する ------------------------------------\r
 *\r
 *      Parameter\r
-*              SOCKS5REQUEST *Packet : \83p\83P\83b\83g\82ð\8dì\90¬\82·\82é\83\8f\81[\83N\r
-*              char Cmd : \83R\83}\83\93\83h\r
-*              int ValidIP : IP\83A\83h\83\8c\83X\82ð\8eg\82¤\82©\82Ç\82¤\82©(YES/NO)\r
-*              ulong IP : IP\83A\83h\83\8c\83X\r
-*              char *Host : \83z\83X\83g\96¼\r
-*              ushort Port : \83|\81[\83g\r
+*              SOCKS5REQUEST *Packet : パケットを作成するワーク\r
+*              char Cmd : コマンド\r
+*              int ValidIP : IPアドレスを使うかどうか(YES/NO)\r
+*              ulong IP : IPアドレス\r
+*              char *Host : ホスト名\r
+*              ushort Port : ポート\r
 *\r
 *      Return Value\r
-*              int \83R\83}\83\93\83h\83p\83P\83b\83g\82Ì\92·\82³\r
+*              int コマンドパケットの長さ\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulong IP, char *Host, ushort Port)\r
@@ -1908,14 +2842,14 @@ static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulo
 \r
        Pos = (uchar *)Packet;\r
        Pos += SOCKS5REQUEST_SIZE;\r
-       TotalLen = SOCKS5REQUEST_SIZE + 2;      /* +2\82Í\83|\81[\83g\82Ì\95ª */\r
+       TotalLen = SOCKS5REQUEST_SIZE + 2;      /* +2はポートの分 */\r
 \r
        Packet->Ver = SOCKS5_VER;\r
        Packet->Cmd = Cmd;\r
        Packet->Rsv = 0;\r
        if(ValidIP == YES)\r
        {\r
-               /* IP\83A\83h\83\8c\83X\82ð\8ew\92è */\r
+               /* IPアドレスを指定 */\r
                Packet->Type = SOCKS5_ADRS_IPV4;\r
                *((ulong *)Pos) = IP;\r
                Pos += 4;\r
@@ -1923,7 +2857,45 @@ static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulo
        }\r
        else\r
        {\r
-               /* \83z\83X\83g\96¼\82ð\8ew\92è */\r
+               /* ホスト名を指定 */\r
+               Packet->Type = SOCKS5_ADRS_NAME;\r
+               Len = strlen(Host);\r
+               *Pos++ = Len;\r
+               strcpy(Pos, Host);\r
+               Pos += Len;\r
+               TotalLen += Len + 1;\r
+       }\r
+       *((ushort *)Pos) = Port;\r
+\r
+       return(TotalLen);\r
+}\r
+\r
+\r
+// IPv6対応\r
+static int Socks5MakeCmdPacketIPv6(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, char *IP, char *Host, ushort Port)\r
+{\r
+       uchar *Pos;\r
+       int Len;\r
+       int TotalLen;\r
+\r
+       Pos = (uchar *)Packet;\r
+       Pos += SOCKS5REQUEST_SIZE;\r
+       TotalLen = SOCKS5REQUEST_SIZE + 2;      /* +2はポートの分 */\r
+\r
+       Packet->Ver = SOCKS5_VER;\r
+       Packet->Cmd = Cmd;\r
+       Packet->Rsv = 0;\r
+       if(ValidIP == YES)\r
+       {\r
+               /* IPアドレスを指定 */\r
+               Packet->Type = SOCKS5_ADRS_IPV6;\r
+               memcpy(Pos, IP, 16);\r
+               Pos += 16;\r
+               TotalLen += 16;\r
+       }\r
+       else\r
+       {\r
+               /* ホスト名を指定 */\r
                Packet->Type = SOCKS5_ADRS_NAME;\r
                Len = strlen(Host);\r
                *Pos++ = Len;\r
@@ -1937,15 +2909,15 @@ static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulo
 }\r
 \r
 \r
-/*----- SOCKS\82Ì\83R\83}\83\93\83h\82ð\91\97\82é -------------------------------------------------\r
+/*----- SOCKSのコマンドを送る -------------------------------------------------\r
 *\r
 *      Parameter\r
-*              SOCKET Socket : \83\\83P\83b\83g\r
-*              void *Data : \91\97\82é\83f\81[\83^\r
-*              int Size : \83T\83C\83Y\r
+*              SOCKET Socket : ソケット\r
+*              void *Data : 送るデータ\r
+*              int Size : サイズ\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X (SUCCESS/FAIL)\r
+*              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWork)\r
@@ -1954,24 +2926,26 @@ static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWor
 \r
        Ret = SendData(Socket, (char *)Data, Size, 0, CancelCheckWork);\r
 \r
-       if(Ret != SUCCESS)\r
+       if(Ret != FFFTP_SUCCESS)\r
                SetTaskMsg(MSGJPN033, *((short *)Data));\r
 \r
        return(Ret);\r
 }\r
 \r
 \r
-/*----- SOCKS5\82Ì\83R\83}\83\93\83h\82É\91Î\82·\82é\83\8a\83v\83\89\83C\83p\83P\83b\83g\82ð\8eó\90M\82·\82é --------------------\r
+/*----- SOCKS5のコマンドに対するリプライパケットを受信する --------------------\r
 *\r
 *      Parameter\r
-*              SOCKET Socket : \83\\83P\83b\83g\r
-*              SOCKS5REPLY *Packet : \83p\83P\83b\83g\r
+*              SOCKET Socket : ソケット\r
+*              SOCKS5REPLY *Packet : パケット\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X (SUCCESS/FAIL)\r
+*              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)\r
+// 同時接続対応\r
+//static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)\r
+static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet, int *CancelCheckWork)\r
 {\r
        uchar *Pos;\r
        int Len;\r
@@ -1980,62 +2954,72 @@ static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)
        Pos = (uchar *)Packet;\r
        Pos += SOCKS5REPLY_SIZE;\r
 \r
-       if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, &CancelFlg)) == SUCCESS)\r
+       // 同時接続対応\r
+//     if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, &CancelFlg)) == FFFTP_SUCCESS)\r
+       if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, CancelCheckWork)) == FFFTP_SUCCESS)\r
        {\r
                if(Packet->Type == SOCKS5_ADRS_IPV4)\r
                        Len = 4 + 2;\r
                else if(Packet->Type == SOCKS5_ADRS_IPV6)\r
-                       Len = 6 + 2;\r
+                       Len = 16 + 2;\r
                else\r
                {\r
-                       if((Ret = ReadNchar(Socket, (char *)Pos, 1, &CancelFlg)) == SUCCESS)\r
+                       // 同時接続対応\r
+//                     if((Ret = ReadNchar(Socket, (char *)Pos, 1, &CancelFlg)) == FFFTP_SUCCESS)\r
+                       if((Ret = ReadNchar(Socket, (char *)Pos, 1, CancelCheckWork)) == FFFTP_SUCCESS)\r
                        {\r
                                Len = *Pos + 2;\r
                                Pos++;\r
                        }\r
                }\r
 \r
-               if(Ret == SUCCESS)\r
-                       Ret = ReadNchar(Socket, (char *)Pos, Len, &CancelFlg);\r
+               if(Ret == FFFTP_SUCCESS)\r
+                       // 同時接続対応\r
+//                     Ret = ReadNchar(Socket, (char *)Pos, Len, &CancelFlg);\r
+                       Ret = ReadNchar(Socket, (char *)Pos, Len, CancelCheckWork);\r
        }\r
 \r
-       if(Ret != SUCCESS)\r
+       if(Ret != FFFTP_SUCCESS)\r
                SetTaskMsg(MSGJPN034);\r
 \r
        return(Ret);\r
 }\r
 \r
 \r
-/*----- SOCKS4\82Ì\83R\83}\83\93\83h\82É\91Î\82·\82é\83\8a\83v\83\89\83C\83p\83P\83b\83g\82ð\8eó\90M\82·\82é --------------------\r
+/*----- SOCKS4のコマンドに対するリプライパケットを受信する --------------------\r
 *\r
 *      Parameter\r
-*              SOCKET Socket : \83\\83P\83b\83g\r
-*              SOCKS5REPLY *Packet : \83p\83P\83b\83g\r
+*              SOCKET Socket : ソケット\r
+*              SOCKS5REPLY *Packet : パケット\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X (SUCCESS/FAIL)\r
+*              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet)\r
+// 同時接続対応\r
+//static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet)\r
+static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet, int *CancelCheckWork)\r
 {\r
        int Ret;\r
 \r
-       Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, &CancelFlg);\r
+       // 同時接続対応\r
+//     Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, &CancelFlg);\r
+       Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, CancelCheckWork);\r
 \r
-       if(Ret != SUCCESS)\r
+       if(Ret != FFFTP_SUCCESS)\r
                DoPrintf(MSGJPN035);\r
 \r
        return(Ret);\r
 }\r
 \r
 \r
-/*----- SOCKS5\82Ì\94F\8fØ\82ð\8ds\82¤ ----------------------------------------------------\r
+/*----- SOCKS5の認証を行う ----------------------------------------------------\r
 *\r
 *      Parameter\r
-*              SOCKET Socket : \83\\83P\83b\83g\r
+*              SOCKET Socket : ソケット\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X (SUCCESS/FAIL)\r
+*              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)\r
@@ -2048,7 +3032,7 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
        int Len;\r
        int Len2;\r
 \r
-       Ret = SUCCESS;\r
+       Ret = FFFTP_SUCCESS;\r
        Socks5Method.Ver = SOCKS5_VER;\r
        Socks5Method.Num = 1;\r
        if(FwallType == FWALL_SOCKS5_NOAUTH)\r
@@ -2056,12 +3040,16 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
        else\r
                Socks5Method.Methods[0] = SOCKS5_AUTH_USER;\r
 \r
-       if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != SUCCESS) ||\r
-          (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, &CancelFlg) != SUCCESS) ||\r
+       // 同時接続対応\r
+//     if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//        (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+//        (Socks5MethodReply.Method == (uchar)0xFF))\r
+       if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+          (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
           (Socks5MethodReply.Method == (uchar)0xFF))\r
        {\r
                SetTaskMsg(MSGJPN036);\r
-               Ret = FAIL;\r
+               Ret = FFFTP_FAIL;\r
        }\r
        else if(Socks5MethodReply.Method == SOCKS5_AUTH_USER)\r
        {\r
@@ -2074,12 +3062,16 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
                Buf[2 + Len] = Len2;\r
                strcpy(Buf+3+Len, FwallPass);\r
 \r
-               if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != SUCCESS) ||\r
-                  (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, &CancelFlg) != SUCCESS) ||\r
+               // 同時接続対応\r
+//             if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+//                (Socks5Status.Status != 0))\r
+               if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                  (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                   (Socks5Status.Status != 0))\r
                {\r
                        SetTaskMsg(MSGJPN037);\r
-                       Ret = FAIL;\r
+                       Ret = FFFTP_FAIL;\r
                }\r
        }\r
        else\r
@@ -2089,37 +3081,120 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
 }\r
 \r
 \r
-/*----- SOCKS\82ÌBIND\82Ì\91æ\82Q\83\8a\83v\83\89\83C\83\81\83b\83Z\81[\83W\82ð\8eó\82¯\8eæ\82é -------------------------\r
+/*----- SOCKSのBINDの第2リプライメッセージを受け取る -------------------------\r
 *\r
 *      Parameter\r
-*              SOCKET Socket : \83\\83P\83b\83g\r
-*              SOCKET *Data : \83f\81[\83^\83\\83P\83b\83g\82ð\95Ô\82·\83\8f\81[\83N\r
+*              SOCKET Socket : ソケット\r
+*              SOCKET *Data : データソケットを返すワーク\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X (SUCCESS/FAIL)\r
+*              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)\r
+// 同時接続対応\r
+//int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)\r
+int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data, int *CancelCheckWork)\r
 {\r
        int Ret;\r
        char Buf[300];\r
 \r
-       Ret = FAIL;\r
+       Ret = FFFTP_FAIL;\r
        if((AskHostFireWall() == YES) && (FwallType == FWALL_SOCKS4))\r
        {\r
-               Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf);\r
+               // 同時接続対応\r
+//             Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf);\r
+               Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf, CancelCheckWork);\r
                *Data = Socket;\r
-               Ret = SUCCESS;\r
+               Ret = FFFTP_SUCCESS;\r
        }\r
        else if((AskHostFireWall() == YES) &&\r
                        ((FwallType == FWALL_SOCKS5_NOAUTH) || (FwallType == FWALL_SOCKS5_USER)))\r
        {\r
-               Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf);\r
+               // 同時接続対応\r
+//             Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf);\r
+               Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf, CancelCheckWork);\r
                *Data = Socket;\r
-               Ret = SUCCESS;\r
+               Ret = FFFTP_SUCCESS;\r
        }\r
        return(Ret);\r
 }\r
 \r
 \r
 \r
+// 暗号化通信対応\r
+int AskCryptMode(void)\r
+{\r
+       return(CurHost.CryptMode);\r
+}\r
+\r
+int AskUseNoEncryption(void)\r
+{\r
+       return(CurHost.UseNoEncryption);\r
+}\r
+\r
+int AskUseFTPES(void)\r
+{\r
+       return(CurHost.UseFTPES);\r
+}\r
+\r
+int AskUseFTPIS(void)\r
+{\r
+       return(CurHost.UseFTPIS);\r
+}\r
+\r
+int AskUseSFTP(void)\r
+{\r
+       return(CurHost.UseSFTP);\r
+}\r
+\r
+char *AskPrivateKey(void)\r
+{\r
+       return(CurHost.PrivateKey);\r
+}\r
+\r
+// 同時接続対応\r
+int AskMaxThreadCount(void)\r
+{\r
+       return(CurHost.MaxThreadCount);\r
+}\r
+\r
+int AskReuseCmdSkt(void)\r
+{\r
+       return(CurHost.ReuseCmdSkt);\r
+}\r
+\r
+// FEAT対応\r
+int AskHostFeature(void)\r
+{\r
+       return(CurHost.Feature);\r
+}\r
+\r
+// MLSD対応\r
+int AskUseMLSD(void)\r
+{\r
+       return(CurHost.UseMLSD);\r
+}\r
+\r
+// IPv6対応\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.TransferErrorMode);\r
+}\r
+\r
+int AskTransferErrorNotify(void)\r
+{\r
+       return(CurHost.TransferErrorNotify);\r
+}\r
+\r