OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / getput.c
index fdcfffa..28c2471 100644 (file)
--- a/getput.c
+++ b/getput.c
@@ -41,7 +41,9 @@
 #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
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 #include <process.h>\r
@@ -86,26 +88,38 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork);
 static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork);\r
 static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *CancelCheckWork);\r
 static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode);\r
-static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname);\r
-static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
+// 再転送対応\r
+//static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname);\r
+static int DispUpDownErrDialog(int ResID, HWND hWnd, TRANSPACKET *Pkt);\r
+// 64ビット対応\r
+//static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
 static int SetDownloadResume(TRANSPACKET *Pkt, int ProcMode, LONGLONG Size, int *Mode, int *CancelCheckWork);\r
-static BOOL CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+// 64ビット対応\r
+//static BOOL CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
 static int DoUpLoad(SOCKET cSkt, TRANSPACKET *Pkt);\r
 static int UpLoadNonPassive(TRANSPACKET *Pkt);\r
 static int UpLoadPassive(TRANSPACKET *Pkt);\r
 static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt);\r
 // 同時接続対応\r
 //static int TermCodeConvAndSend(TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii);\r
-static int TermCodeConvAndSend(int ThreadCount, TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii);\r
+static int TermCodeConvAndSend(TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii, int *CancelCheckWork);\r
 static void DispUploadFinishMsg(TRANSPACKET *Pkt, int iRetCode);\r
 static int SetUploadResume(TRANSPACKET *Pkt, int ProcMode, LONGLONG Size, int *Mode);\r
 static LRESULT CALLBACK TransDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);\r
 static void DispTransferStatus(HWND hWnd, int End, TRANSPACKET *Pkt);\r
 static void DispTransFileInfo(TRANSPACKET *Pkt, char *Title, int SkipButton, int Info);\r
-static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max);\r
+// IPv6対応\r
+//static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max);\r
+static int GetAdrsAndPort(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max);\r
+static int GetAdrsAndPortIPv4(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max);\r
+static int GetAdrsAndPortIPv6(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max);\r
 static int IsSpecialDevice(char *Fname);\r
 static int MirrorDelNotify(int Cur, int Notify, TRANSPACKET *Pkt);\r
-static BOOL CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+// 64ビット対応\r
+//static BOOL CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
 static void SetErrorMsg(char *fmt, ...);\r
 // 同時接続対応\r
 static char* GetErrMsg();\r
@@ -142,7 +156,9 @@ static time_t TimeStart[MAX_DATA_CONNECTION];       /* 転送開始時間 */
 static int KeepDlg = NO;       /* 転送中ダイアログを消さないかどうか (YES/NO) */\r
 static int MoveToForeground = NO;              /* ウインドウを前面に移動するかどうか (YES/NO) */\r
 \r
-static char CurDir[FMAX_PATH+1] = { "" };\r
+// 同時接続対応\r
+//static char CurDir[FMAX_PATH+1] = { "" };\r
+static char CurDir[MAX_DATA_CONNECTION][FMAX_PATH+1];\r
 // 同時接続対応\r
 //static char ErrMsg[ERR_MSG_LEN+7];\r
 static char ErrMsg[MAX_DATA_CONNECTION+1][ERR_MSG_LEN+7];\r
@@ -151,6 +167,9 @@ static HANDLE hErrMsgMutex;
 \r
 // 同時接続対応\r
 static int WaitForMainThread = NO;\r
+// 再転送対応\r
+static int TransferErrorMode = EXIST_OVW;\r
+static int TransferErrorNotify = NO;\r
 \r
 /*===== 外部参照 =====*/\r
 \r
@@ -369,6 +388,9 @@ int RemoveTmpTransFileListItem(TRANSPACKET **Base, int Num)
 \r
 void AddTransFileList(TRANSPACKET *Pkt)\r
 {\r
+       // 同時接続対応\r
+       TRANSPACKET *Pos;\r
+\r
        DispTransPacket(Pkt);\r
 \r
        // 同時接続対応\r
@@ -380,6 +402,13 @@ void AddTransFileList(TRANSPACKET *Pkt)
                Sleep(1);\r
        }\r
 \r
+       // 同時接続対応\r
+       Pos = TransPacketBase;\r
+       if(Pos != NULL)\r
+       {\r
+               while(Pos->Next != NULL)\r
+                       Pos = Pos->Next;\r
+       }\r
        if(AddTmpTransFileList(Pkt, &TransPacketBase) == FFFTP_SUCCESS)\r
        {\r
                if((strncmp(Pkt->Cmd, "RETR", 4) == 0) ||\r
@@ -391,7 +420,12 @@ void AddTransFileList(TRANSPACKET *Pkt)
        }\r
        // 同時接続対応\r
        if(NextTransPacketBase == NULL)\r
-               NextTransPacketBase = TransPacketBase;\r
+       {\r
+               if(Pos)\r
+                       NextTransPacketBase = Pos->Next;\r
+               else\r
+                       NextTransPacketBase = TransPacketBase;\r
+       }\r
        ReleaseMutex(hListAccMutex);\r
        // 同時接続対応\r
        WaitForMainThread = NO;\r
@@ -437,7 +471,7 @@ void AppendTransFileList(TRANSPACKET *Pkt)
        }\r
        // 同時接続対応\r
        if(NextTransPacketBase == NULL)\r
-               NextTransPacketBase = TransPacketBase;\r
+               NextTransPacketBase = Pkt;\r
 \r
        while(Pkt != NULL)\r
        {\r
@@ -541,7 +575,7 @@ static void EraseTransFileList(void)
        }\r
        TransPacketBase = NotDel;\r
        // 同時接続対応\r
-       NextTransPacketBase = TransPacketBase;\r
+       NextTransPacketBase = NotDel;\r
        TransFiles = 0;\r
        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
        ReleaseMutex(hListAccMutex);\r
@@ -627,7 +661,11 @@ void GoForwardTransWindow(void)
 \r
 void InitTransCurDir(void)\r
 {\r
-       strcpy(CurDir, "");\r
+       // 同時接続対応\r
+//     strcpy(CurDir, "");\r
+       int i;\r
+       for(i = 0; i < MAX_DATA_CONNECTION; i++)\r
+               strcpy(CurDir[i], "");\r
        return;\r
 }\r
 \r
@@ -659,6 +697,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
        SOCKET TrnSkt;\r
        RECT WndRect;\r
        int i;\r
+       DWORD LastUsed;\r
 \r
        hWndTrans = NULL;\r
        Down = NO;\r
@@ -705,32 +744,61 @@ static ULONG WINAPI TransferThread(void *Dummy)
                        free(Pos);\r
                }\r
                NewCmdSkt = AskCmdCtrlSkt();\r
-               if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())\r
+               if(AskReuseCmdSkt() == YES && ThreadCount == 0)\r
+               {\r
+                       if(TransPacketBase && ThreadCount < AskMaxThreadCount())\r
+                               TrnSkt = AskTrnCtrlSkt();\r
+               }\r
+               else\r
                {\r
-                       if(TrnSkt == INVALID_SOCKET || NewCmdSkt != CmdSkt)\r
+                       if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())\r
                        {\r
-                               ReleaseMutex(hListAccMutex);\r
-                               ReConnectTrnSkt(&TrnSkt);\r
-//                             WaitForSingleObject(hListAccMutex, INFINITE);\r
-                               while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+                               if(TrnSkt == INVALID_SOCKET || NewCmdSkt != CmdSkt)\r
                                {\r
-                                       BackgrndMessageProc();\r
-                                       Sleep(1);\r
+                                       ReleaseMutex(hListAccMutex);\r
+                                       ReConnectTrnSkt(&TrnSkt, &Canceled[ThreadCount]);\r
+                                       // 同時ログイン数制限対策\r
+                                       if(TrnSkt != INVALID_SOCKET)\r
+                                               LastUsed = timeGetTime();\r
+                                       else\r
+                                       {\r
+                                               // 同時ログイン数制限に引っかかった可能性あり\r
+                                               // 負荷を下げるために約10秒間待機\r
+                                               i = 10000;\r
+                                               while(NewCmdSkt != CmdSkt && i > 0)\r
+                                               {\r
+                                                       BackgrndMessageProc();\r
+                                                       Sleep(1);\r
+                                                       i--;\r
+                                               }\r
+                                       }\r
+//                                     WaitForSingleObject(hListAccMutex, INFINITE);\r
+                                       while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+                                       {\r
+                                               BackgrndMessageProc();\r
+                                               Sleep(1);\r
+                                       }\r
                                }\r
                        }\r
-               }\r
-               else\r
-               {\r
-                       if(TrnSkt != INVALID_SOCKET)\r
+                       else\r
                        {\r
-                               ReleaseMutex(hListAccMutex);\r
-                               DoClose(TrnSkt);\r
-                               TrnSkt = INVALID_SOCKET;\r
-//                             WaitForSingleObject(hListAccMutex, INFINITE);\r
-                               while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+                               if(TrnSkt != INVALID_SOCKET)\r
                                {\r
-                                       BackgrndMessageProc();\r
-                                       Sleep(1);\r
+                                       // 同時ログイン数制限対策\r
+                                       // 10秒間は再利用を許可\r
+                                       if(timeGetTime() - LastUsed > 10000)\r
+                                       {\r
+                                               ReleaseMutex(hListAccMutex);\r
+                                               SendData(TrnSkt, "QUIT\r\n", 6, 0, &Canceled[ThreadCount]);\r
+                                               DoClose(TrnSkt);\r
+                                               TrnSkt = INVALID_SOCKET;\r
+//                                             WaitForSingleObject(hListAccMutex, INFINITE);\r
+                                               while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+                                               {\r
+                                                       BackgrndMessageProc();\r
+                                                       Sleep(1);\r
+                                               }\r
+                                       }\r
                                }\r
                        }\r
                }\r
@@ -738,6 +806,13 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //             if(TransPacketBase != NULL)\r
                if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)\r
                {\r
+                       if(strcmp(NextTransPacketBase->Cmd, "GOQUIT") == 0 && NextTransPacketBase != TransPacketBase)\r
+                       {\r
+                               ReleaseMutex(hListAccMutex);\r
+                               BackgrndMessageProc();\r
+                               Sleep(1);\r
+                               continue;\r
+                       }\r
                        Pos = NextTransPacketBase;\r
                        NextTransPacketBase = NextTransPacketBase->Next;\r
                        // ディレクトリ操作は非同期で行わない\r
@@ -793,7 +868,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                {\r
                                        /* フルパスを使わないための処理 */\r
 //                                     if(MakeNonFullPath(TransPacketBase, CurDir, Tmp) == FFFTP_SUCCESS)\r
-                                       if(MakeNonFullPath(Pos, CurDir, Tmp) == FFFTP_SUCCESS)\r
+                                       if(MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)\r
                                        {\r
 //                                             if(strncmp(TransPacketBase->Cmd, "RETR-S", 6) == 0)\r
                                                if(strncmp(Pos->Cmd, "RETR-S", 6) == 0)\r
@@ -802,8 +877,8 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //                                                     DoSIZE(TransPacketBase->RemoteFile, &TransPacketBase->Size);\r
 //                                                     DoMDTM(TransPacketBase->RemoteFile, &TransPacketBase->Time);\r
 //                                                     strcpy(TransPacketBase->Cmd, "RETR ");\r
-                                                       DoSIZE(TrnSkt, Pos->RemoteFile, &Pos->Size);\r
-                                                       DoMDTM(TrnSkt, Pos->RemoteFile, &Pos->Time);\r
+                                                       DoSIZE(TrnSkt, Pos->RemoteFile, &Pos->Size, &Canceled[Pos->ThreadCount]);\r
+                                                       DoMDTM(TrnSkt, Pos->RemoteFile, &Pos->Time, &Canceled[Pos->ThreadCount]);\r
                                                        strcpy(Pos->Cmd, "RETR ");\r
                                                }\r
 \r
@@ -827,7 +902,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //                             ReleaseMutex(hListAccMutex);\r
                                /* フルパスを使わないための処理 */\r
 //                             if(MakeNonFullPath(TransPacketBase, CurDir, Tmp) == FFFTP_SUCCESS)\r
-                               if(MakeNonFullPath(Pos, CurDir, Tmp) == FFFTP_SUCCESS)\r
+                               if(MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)\r
                                {\r
                                        Up = YES;\r
 //                                     if(DoUpLoad(AskTrnCtrlSkt(), TransPacketBase) == 429)\r
@@ -856,7 +931,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //                                     strcpy(Tmp, TransPacketBase->RemoteFile);\r
                                        strcpy(Tmp, Pos->RemoteFile);\r
 //                                     if(ProcForNonFullpath(Tmp, CurDir, hWndTrans, 1) == FFFTP_FAIL)\r
-                                       if(ProcForNonFullpath(Tmp, CurDir, hWndTrans, (int)TrnSkt + 1) == FFFTP_FAIL)\r
+                                       if(ProcForNonFullpath(TrnSkt, Tmp, CurDir[Pos->ThreadCount], hWndTrans, &Canceled[Pos->ThreadCount]) == FFFTP_FAIL)\r
                                        {\r
                                                ClearAll = YES;\r
                                                CwdSts = FTP_ERROR;\r
@@ -866,13 +941,13 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                        {\r
                                                Up = YES;\r
 //                                             CommandProcTrn(NULL, "MKD %s", Tmp);\r
-                                               CommandProcTrn(TrnSkt, NULL, "MKD %s", Tmp);\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "MKD %s", Tmp);\r
                                                /* すでにフォルダがある場合もあるので、 */\r
                                                /* ここではエラーチェックはしない */\r
 \r
                                        if(FolderAttr)\r
 //                                             CommandProcTrn(NULL, "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Tmp);\r
-                                               CommandProcTrn(TrnSkt, NULL, "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Tmp);\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Tmp);\r
                                        }\r
                                }\r
 //                             else if(strlen(TransPacketBase->LocalFile) > 0)\r
@@ -893,15 +968,15 @@ static ULONG WINAPI TransferThread(void *Dummy)
 \r
                                /* フルパスを使わないための処理 */\r
 //                             if(MakeNonFullPath(TransPacketBase, CurDir, Tmp) == FFFTP_SUCCESS)\r
-                               if(MakeNonFullPath(Pos, CurDir, Tmp) == FFFTP_SUCCESS)\r
+                               if(MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)\r
                                {\r
                                        Up = YES;\r
 //                                     CommandProcTrn(NULL, "%s%s", TransPacketBase->Cmd+2, TransPacketBase->RemoteFile);\r
-                                       CommandProcTrn(TrnSkt, NULL, "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
+                                       CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
 \r
                                        if(FolderAttr)\r
 //                                             CommandProcTrn(NULL, "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, TransPacketBase->RemoteFile);\r
-                                               CommandProcTrn(TrnSkt, NULL, "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Pos->RemoteFile);\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Pos->RemoteFile);\r
                                }\r
                                ReleaseMutex(hListAccMutex);\r
                        }\r
@@ -918,11 +993,11 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                {\r
                                        /* フルパスを使わないための処理 */\r
 //                                     if(MakeNonFullPath(TransPacketBase, CurDir, Tmp) == FFFTP_SUCCESS)\r
-                                       if(MakeNonFullPath(Pos, CurDir, Tmp) == FFFTP_SUCCESS)\r
+                                       if(MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)\r
                                        {\r
                                                Up = YES;\r
 //                                             CommandProcTrn(NULL, "%s%s", TransPacketBase->Cmd+2, TransPacketBase->RemoteFile);\r
-                                               CommandProcTrn(TrnSkt, NULL, "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
                                        }\r
                                }\r
                                ReleaseMutex(hListAccMutex);\r
@@ -940,11 +1015,11 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                {\r
                                        /* フルパスを使わないための処理 */\r
 //                                     if(MakeNonFullPath(TransPacketBase, CurDir, Tmp) == FFFTP_SUCCESS)\r
-                                       if(MakeNonFullPath(Pos, CurDir, Tmp) == FFFTP_SUCCESS)\r
+                                       if(MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)\r
                                        {\r
                                                Up = YES;\r
 //                                             CommandProcTrn(NULL, "%s%s", TransPacketBase->Cmd+2, TransPacketBase->RemoteFile);\r
-                                               CommandProcTrn(TrnSkt, NULL, "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd+2, Pos->RemoteFile);\r
                                        }\r
                                }\r
                                ReleaseMutex(hListAccMutex);\r
@@ -999,13 +1074,14 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //                     else if(strcmp(TransPacketBase->Cmd, "SETCUR") == 0)\r
                        else if(strcmp(Pos->Cmd, "SETCUR") == 0)\r
                        {\r
-                               if(AskShareProh() == YES)\r
+//                             if(AskShareProh() == YES)\r
+                               if(AskReuseCmdSkt() == NO || AskShareProh() == YES)\r
                                {\r
 //                                     if(strcmp(CurDir, TransPacketBase->RemoteFile) != 0)\r
-                                       if(strcmp(CurDir, Pos->RemoteFile) != 0)\r
+                                       if(strcmp(CurDir[Pos->ThreadCount], Pos->RemoteFile) != 0)\r
                                        {\r
 //                                             if(CommandProcTrn(NULL, "CWD %s", TransPacketBase->RemoteFile)/100 != FTP_COMPLETE)\r
-                                               if(CommandProcTrn(TrnSkt, NULL, "CWD %s", Pos->RemoteFile)/100 != FTP_COMPLETE)\r
+                                               if(CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "CWD %s", Pos->RemoteFile)/100 != FTP_COMPLETE)\r
                                                {\r
                                                        DispCWDerror(hWndTrans);\r
                                                        ClearAll = YES;\r
@@ -1013,21 +1089,22 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                        }\r
                                }\r
 //                             strcpy(CurDir, TransPacketBase->RemoteFile);\r
-                               strcpy(CurDir, Pos->RemoteFile);\r
+                               strcpy(CurDir[Pos->ThreadCount], Pos->RemoteFile);\r
                                ReleaseMutex(hListAccMutex);\r
                        }\r
                        /* カレントディレクトリを戻す */\r
 //                     else if(strcmp(TransPacketBase->Cmd, "BACKCUR") == 0)\r
                        else if(strcmp(Pos->Cmd, "BACKCUR") == 0)\r
                        {\r
-                               if(AskShareProh() == NO)\r
+//                             if(AskShareProh() == NO)\r
+                               if(AskReuseCmdSkt() == YES && AskShareProh() == NO)\r
                                {\r
 //                                     if(strcmp(CurDir, TransPacketBase->RemoteFile) != 0)\r
 //                                             CommandProcTrn(NULL, "CWD %s", TransPacketBase->RemoteFile);\r
 //                                     strcpy(CurDir, TransPacketBase->RemoteFile);\r
-                                       if(strcmp(CurDir, Pos->RemoteFile) != 0)\r
-                                               CommandProcTrn(TrnSkt, NULL, "CWD %s", Pos->RemoteFile);\r
-                                       strcpy(CurDir, Pos->RemoteFile);\r
+                                       if(strcmp(CurDir[Pos->ThreadCount], Pos->RemoteFile) != 0)\r
+                                               CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "CWD %s", Pos->RemoteFile);\r
+                                       strcpy(CurDir[Pos->ThreadCount], Pos->RemoteFile);\r
                                }\r
                                ReleaseMutex(hListAccMutex);\r
                        }\r
@@ -1089,6 +1166,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);\r
                        if(Pos != NULL)\r
                                strcpy(Pos->Cmd, "");\r
+                       LastUsed = timeGetTime();\r
                }\r
 //             else\r
                else if(TransPacketBase == NULL)\r
@@ -1138,6 +1216,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0);\r
                                GoExit = NO;\r
                        }\r
+\r
+                       // 再転送対応\r
+                       TransferErrorMode = AskTransferErrorMode();\r
+                       TransferErrorNotify = AskTransferErrorNotify();\r
                }\r
                else\r
                {\r
@@ -1154,8 +1236,14 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                Sleep(100);\r
                }\r
        }\r
-       if(TrnSkt != INVALID_SOCKET)\r
-               DoClose(TrnSkt);\r
+       if(AskReuseCmdSkt() == NO || ThreadCount > 0)\r
+       {\r
+               if(TrnSkt != INVALID_SOCKET)\r
+               {\r
+                       SendData(TrnSkt, "QUIT\r\n", 6, 0, &Canceled[ThreadCount]);\r
+                       DoClose(TrnSkt);\r
+               }\r
+       }\r
        return 0;\r
 }\r
 \r
@@ -1182,7 +1270,7 @@ static int MakeNonFullPath(TRANSPACKET *Pkt, char *Cur, char *Tmp)
        int Sts;\r
 \r
 //     Sts = ProcForNonFullpath(Pkt->RemoteFile, Cur, Pkt->hWndTrans, 1);\r
-       Sts = ProcForNonFullpath(Pkt->RemoteFile, Cur, Pkt->hWndTrans, (int)Pkt->ctrl_skt + 1);\r
+       Sts = ProcForNonFullpath(Pkt->ctrl_skt, Pkt->RemoteFile, Cur, Pkt->hWndTrans, &Canceled[Pkt->ThreadCount]);\r
        if(Sts == FFFTP_FAIL)\r
                ClearAll = YES;\r
 \r
@@ -1239,7 +1327,13 @@ int DoDownLoad(SOCKET cSkt, TRANSPACKET *Pkt, int DirList, int *CancelCheckWork)
                                        DispTransFileInfo(Pkt, MSGJPN087, FALSE, NO);\r
                        }\r
 \r
-                       if(BackgrndMessageProc() == NO)\r
+                       // SFTP対応\r
+//                     if(BackgrndMessageProc() == NO)\r
+                       if(IsSFTPAttached(Pkt->ctrl_skt))\r
+                       {\r
+                               // TODO:\r
+                       }\r
+                       else if(BackgrndMessageProc() == NO)\r
                        {\r
                                if(AskPasvMode() != YES)\r
                                        iRetCode = DownLoadNonPassive(Pkt, CancelCheckWork);\r
@@ -1279,7 +1373,10 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
        SOCKET listen_socket = INVALID_SOCKET; // data listen socket\r
        char Buf[1024];\r
        int CreateMode;\r
-       struct sockaddr_in saSockAddr1;\r
+       // IPv6対応\r
+//     struct sockaddr_in saSockAddr1;\r
+       struct sockaddr_in saSockAddrIPv4;\r
+       struct sockaddr_in6 saSockAddrIPv6;\r
        char Reply[ERR_MSG_LEN+7];\r
 \r
        if((listen_socket = GetFTPListenSocket(Pkt->ctrl_skt, CancelCheckWork)) != INVALID_SOCKET)\r
@@ -1290,10 +1387,24 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                        iRetCode = command(Pkt->ctrl_skt, Reply, CancelCheckWork, "%s", Buf);\r
                        if(iRetCode/100 == FTP_PRELIM)\r
                        {\r
-                               if(SocksGet2ndBindReply(listen_socket, &data_socket) == FFFTP_FAIL)\r
+                               // 同時接続対応\r
+//                             if(SocksGet2ndBindReply(listen_socket, &data_socket) == FFFTP_FAIL)\r
+                               if(SocksGet2ndBindReply(listen_socket, &data_socket, CancelCheckWork) == FFFTP_FAIL)\r
                                {\r
-                                       iLength = sizeof(saSockAddr1);\r
-                                       data_socket = do_accept(listen_socket, (struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
+                                       // IPv6対応\r
+//                                     iLength = sizeof(saSockAddr1);\r
+//                                     data_socket = do_accept(listen_socket, (struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
+                                       switch(AskCurNetType())\r
+                                       {\r
+                                       case NTYPE_IPV4:\r
+                                               iLength=sizeof(saSockAddrIPv4);\r
+                                               data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv4, (int *)&iLength);\r
+                                               break;\r
+                                       case NTYPE_IPV6:\r
+                                               iLength=sizeof(saSockAddrIPv6);\r
+                                               data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv6, (int *)&iLength);\r
+                                               break;\r
+                                       }\r
 \r
                                        if(shutdown(listen_socket, 1) != 0)\r
                                                ReportWSError("shutdown listen", WSAGetLastError());\r
@@ -1306,7 +1417,19 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                                                iRetCode = 500;\r
                                        }\r
                                        else\r
-                                               DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
+                                               // IPv6対応\r
+//                                             DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
+                                       {\r
+                                               switch(AskCurNetType())\r
+                                               {\r
+                                               case NTYPE_IPV4:\r
+                                                       DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddrIPv4.sin_addr), ntohs(saSockAddrIPv4.sin_port));\r
+                                                       break;\r
+                                               case NTYPE_IPV6:\r
+                                                       DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet6_ntoa(saSockAddrIPv6.sin6_addr), ntohs(saSockAddrIPv6.sin6_port));\r
+                                                       break;\r
+                                               }\r
+                                       }\r
                                }\r
 \r
                                if(data_socket != INVALID_SOCKET)\r
@@ -1317,7 +1440,7 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
 //                                     iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                        if(IsSSLAttached(Pkt->ctrl_skt))\r
                                        {\r
-                                               if(AttachSSL(data_socket, Pkt->ctrl_skt))\r
+                                               if(AttachSSL(data_socket, Pkt->ctrl_skt, CancelCheckWork))\r
                                                        iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                                else\r
                                                        iRetCode = 500;\r
@@ -1364,15 +1487,29 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
        SOCKET data_socket = INVALID_SOCKET;   // data channel socket\r
        char Buf[1024];\r
        int CreateMode;\r
-       char Adrs[20];\r
+       // IPv6対応\r
+//     char Adrs[20];\r
+       char Adrs[40];\r
        int Port;\r
        int Flg;\r
        char Reply[ERR_MSG_LEN+7];\r
 \r
-       iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "PASV");\r
+       // IPv6対応\r
+//     iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "PASV");\r
+       switch(AskCurNetType())\r
+       {\r
+       case NTYPE_IPV4:\r
+               iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "PASV");\r
+               break;\r
+       case NTYPE_IPV6:\r
+               iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "EPSV");\r
+               break;\r
+       }\r
        if(iRetCode/100 == FTP_COMPLETE)\r
        {\r
-               if(GetAdrsAndPort(Buf, Adrs, &Port, 19) == FFFTP_SUCCESS)\r
+               // IPv6対応\r
+//             if(GetAdrsAndPort(Buf, Adrs, &Port, 19) == FFFTP_SUCCESS)\r
+               if(GetAdrsAndPort(Pkt->ctrl_skt, Buf, Adrs, &Port, 39) == FFFTP_SUCCESS)\r
                {\r
                        if((data_socket = connectsock(Adrs, Port, MSGJPN091, CancelCheckWork)) != INVALID_SOCKET)\r
                        {\r
@@ -1393,7 +1530,7 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
 //                                             iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                                if(IsSSLAttached(Pkt->ctrl_skt))\r
                                                {\r
-                                                       if(AttachSSL(data_socket, Pkt->ctrl_skt))\r
+                                                       if(AttachSSL(data_socket, Pkt->ctrl_skt, CancelCheckWork))\r
                                                                iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                                        else\r
                                                                iRetCode = 500;\r
@@ -1585,8 +1722,6 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
 //                                             Continue = ConvJIStoSJIS(&cInfo);\r
 //                                     else\r
 //                                             Continue = ConvEUCtoSJIS(&cInfo);\r
-                                       char Buf3[(BUFSIZE + 3) * 4];\r
-                                       CODECONVINFO cInfo2;\r
                                        switch(Pkt->KanjiCode)\r
                                        {\r
                                        case KANJI_SJIS:\r
@@ -1615,6 +1750,11 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                        cInfo2.OutLen = cInfo.OutLen;\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvSJIStoUTF8N(&cInfo);\r
+                                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -1658,6 +1798,14 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                        ConvSJIStoEUC(&cInfo2);\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvJIStoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -1704,6 +1852,14 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                        ConvSJIStoEUC(&cInfo2);\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvEUCtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -1722,6 +1878,50 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                }\r
                                                break;\r
                                        case KANJI_UTF8N:\r
+                                               switch(Pkt->KanjiCodeDesired)\r
+                                               {\r
+                                               case KANJI_SJIS:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                                       break;\r
+                                               case KANJI_JIS:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoJIS(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_EUC:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoEUC(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8N:\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
+                                                       if(ProcessedBOM == NO)\r
+                                                       {\r
+                                                               memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
+                                                               cInfo2.OutLen = 3;\r
+                                                               Continue = YES;\r
+                                                               ProcessedBOM = YES;\r
+                                                               break;\r
+                                                       }\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
+                                               }\r
+                                               break;\r
+                                       case KANJI_UTF8BOM:\r
                                                if(ProcessedBOM == NO)\r
                                                {\r
                                                        if(memcmp(Buf, "\xEF\xBB\xBF", 3) == 0)\r
@@ -1732,7 +1932,7 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                        cInfo2.OutLen = 0;\r
                                                        switch(Pkt->KanjiCodeDesired)\r
                                                        {\r
-                                                       case KANJI_UTF8N:\r
+                                                       case KANJI_UTF8BOM:\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
                                                                cInfo2.OutLen = 3;\r
                                                                break;\r
@@ -1769,6 +1969,11 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                                        cInfo2.OutLen = cInfo.StrLen;\r
                                                        Continue = NO;\r
                                                        break;\r
+                                               case KANJI_UTF8BOM:\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
                                                }\r
                                                break;\r
                                        }\r
@@ -1830,6 +2035,10 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                        memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
                                        cInfo2.OutLen = cInfo.OutLen;\r
                                        break;\r
+                               case KANJI_UTF8BOM:\r
+                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                       break;\r
                                }\r
                                break;\r
                        case KANJI_JIS:\r
@@ -1861,6 +2070,13 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                        cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
                                        ConvSJIStoUTF8N(&cInfo2);\r
                                        break;\r
+                               case KANJI_UTF8BOM:\r
+                                       cInfo2.Str = cInfo.Buf;\r
+                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                       cInfo2.Buf = Buf3;\r
+                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                       break;\r
                                }\r
                                break;\r
                        case KANJI_EUC:\r
@@ -1892,6 +2108,13 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                        cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
                                        ConvSJIStoUTF8N(&cInfo2);\r
                                        break;\r
+                               case KANJI_UTF8BOM:\r
+                                       cInfo2.Str = cInfo.Buf;\r
+                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                       cInfo2.Buf = Buf3;\r
+                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                       break;\r
                                }\r
                                break;\r
                        case KANJI_UTF8N:\r
@@ -1919,6 +2142,41 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                                        memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
                                        cInfo2.OutLen = cInfo.OutLen;\r
                                        break;\r
+                               case KANJI_UTF8BOM:\r
+                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                       break;\r
+                               }\r
+                               break;\r
+                       case KANJI_UTF8BOM:\r
+                               switch(Pkt->KanjiCodeDesired)\r
+                               {\r
+                               case KANJI_SJIS:\r
+                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                       break;\r
+                               case KANJI_JIS:\r
+                                       cInfo2.Str = cInfo.Buf;\r
+                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                       cInfo2.Buf = Buf3;\r
+                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                       ConvSJIStoJIS(&cInfo2);\r
+                                       break;\r
+                               case KANJI_EUC:\r
+                                       cInfo2.Str = cInfo.Buf;\r
+                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                       cInfo2.Buf = Buf3;\r
+                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                       ConvSJIStoEUC(&cInfo2);\r
+                                       break;\r
+                               case KANJI_UTF8N:\r
+                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                       break;\r
+                               case KANJI_UTF8BOM:\r
+                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                       break;\r
                                }\r
                                break;\r
                        }\r
@@ -2028,6 +2286,12 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
                        if (AskHostType() == HTYPE_VMS)\r
                                return;\r
 #endif\r
+#if defined(HAVE_TANDEM)\r
+                       /* HP Nonstop Server の場合、ファイルのない subvol へ移動すると550 File not found\r
+                        * になるが問題ないのでエラーダイアログやエラーメッセージを出さないため */\r
+                       if (AskHostType() == HTYPE_TANDEM)\r
+                               return;\r
+#endif\r
 \r
                        if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0))\r
                        {\r
@@ -2046,8 +2310,22 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
                        {\r
                                // 全て中止を選択後にダイアログが表示されるバグ対策\r
 //                             if(DispUpDownErrDialog(downerr_dlg, Pkt->hWndTrans, Fname) == NO)\r
-                               if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO && DispUpDownErrDialog(downerr_dlg, Pkt->hWndTrans, Fname) == NO)\r
-                                       ClearAll = YES;\r
+                               // 再転送対応\r
+//                             if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO && DispUpDownErrDialog(downerr_dlg, Pkt->hWndTrans, Fname) == NO)\r
+//                                     ClearAll = YES;\r
+                               if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO)\r
+                               {\r
+                                       if(strncmp(Pkt->Cmd, "RETR", 4) == 0 || strncmp(Pkt->Cmd, "STOR", 4) == 0)\r
+                                       {\r
+                                               if(TransferErrorNotify == YES && DispUpDownErrDialog(downerr_dlg, Pkt->hWndTrans, Pkt) == NO)\r
+                                                       ClearAll = YES;\r
+                                               else\r
+                                               {\r
+                                                       Pkt->Mode = TransferErrorMode;\r
+                                                       AddTransFileList(Pkt);\r
+                                               }\r
+                                       }\r
+                               }\r
                        }\r
                }\r
                else\r
@@ -2081,13 +2359,17 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
 *              int ステータス (YES=中止/NO=全て中止)\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname)\r
+// 再転送対応\r
+//static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname)\r
+static int DispUpDownErrDialog(int ResID, HWND hWnd, TRANSPACKET *Pkt)\r
 {\r
        if(hWnd == NULL)\r
                hWnd = GetMainHwnd();\r
 \r
        SoundPlay(SND_ERROR);\r
-       return(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(ResID), hWnd, UpDownErrorDialogProc, (LPARAM)Fname));\r
+       // 再転送対応\r
+//     return(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(ResID), hWnd, UpDownErrorDialogProc, (LPARAM)Fname));\r
+       return(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(ResID), hWnd, UpDownErrorDialogProc, (LPARAM)Pkt));\r
 }\r
 \r
 \r
@@ -2103,31 +2385,57 @@ static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
+       static TRANSPACKET *Pkt;\r
+       static const RADIOBUTTON DownExistButton[] = {\r
+               { DOWN_EXIST_OVW, EXIST_OVW },\r
+               { DOWN_EXIST_RESUME, EXIST_RESUME },\r
+               { DOWN_EXIST_IGNORE, EXIST_IGNORE }\r
+       };\r
+       #define DOWNEXISTBUTTONS        (sizeof(DownExistButton)/sizeof(RADIOBUTTON))\r
+\r
        switch (message)\r
        {\r
                case WM_INITDIALOG :\r
-                       SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)lParam);\r
+                       Pkt = (TRANSPACKET *)lParam;\r
+//                     SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)lParam);\r
+                       SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)Pkt->RemoteFile);\r
                        // 同時接続対応\r
 //                     SendDlgItemMessage(hDlg, UPDOWN_ERR_MSG, WM_SETTEXT, 0, (LPARAM)ErrMsg);\r
                        SendDlgItemMessage(hDlg, UPDOWN_ERR_MSG, WM_SETTEXT, 0, (LPARAM)GetErrMsg());\r
+\r
+                       if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
+                               EnableWindow(GetDlgItem(hDlg, DOWN_EXIST_RESUME), FALSE);\r
+\r
+                       SetRadioButtonByValue(hDlg, TransferErrorMode, DownExistButton, DOWNEXISTBUTTONS);\r
                        return(TRUE);\r
 \r
                case WM_COMMAND :\r
                        switch(GET_WM_COMMAND_ID(wParam, lParam))\r
                        {\r
+                               case IDOK_ALL :\r
+                                       TransferErrorNotify = NO;\r
+                                       /* ここに break はない */\r
+\r
                                case IDOK :\r
+                                       TransferErrorMode = AskRadioButtonValue(hDlg, DownExistButton, DOWNEXISTBUTTONS);\r
                                        EndDialog(hDlg, YES);\r
                                        break;\r
 \r
                                case IDCANCEL :\r
                                        EndDialog(hDlg, NO);\r
                                        break;\r
+\r
+                               case IDHELP :\r
+//                                     hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000009);\r
+                                       break;\r
                        }\r
-                       return(TRUE);\r
+            return(TRUE);\r
        }\r
-    return(FALSE);\r
+       return(FALSE);\r
 }\r
 \r
 \r
@@ -2195,7 +2503,9 @@ static int SetDownloadResume(TRANSPACKET *Pkt, int ProcMode, LONGLONG Size, int
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK NoResumeWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
 {\r
        switch (iMessage)\r
        {\r
@@ -2259,7 +2569,13 @@ static int DoUpLoad(SOCKET cSkt, TRANSPACKET *Pkt)
                                if(Pkt->hWndTrans != NULL)\r
                                        DispTransFileInfo(Pkt, MSGJPN104, TRUE, YES);\r
 \r
-                               if(BackgrndMessageProc() == NO)\r
+                               // SFTP対応\r
+//                             if(BackgrndMessageProc() == NO)\r
+                               if(IsSFTPAttached(Pkt->ctrl_skt))\r
+                               {\r
+                                       // TODO:\r
+                               }\r
+                               else if(BackgrndMessageProc() == NO)\r
                                {\r
                                        if(AskPasvMode() != YES)\r
                                                iRetCode = UpLoadNonPassive(Pkt);\r
@@ -2313,7 +2629,10 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
        SOCKET data_socket = INVALID_SOCKET;   // data channel socket\r
        SOCKET listen_socket = INVALID_SOCKET; // data listen socket\r
        char Buf[1024];\r
-       struct sockaddr_in saSockAddr1;\r
+       // IPv6対応\r
+//     struct sockaddr_in saSockAddr1;\r
+       struct sockaddr_in saSockAddrIPv4;\r
+       struct sockaddr_in6 saSockAddrIPv6;\r
        int Resume;\r
        char Reply[ERR_MSG_LEN+7];\r
 \r
@@ -2323,6 +2642,16 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
        {\r
                SetUploadResume(Pkt, Pkt->Mode, Pkt->ExistSize, &Resume);\r
                if(Resume == NO)\r
+#if defined(HAVE_TANDEM)\r
+                       if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO && Pkt->Type != TYPE_A) {\r
+                               if( Pkt->PriExt == DEF_PRIEXT && Pkt->SecExt == DEF_SECEXT && Pkt->MaxExt == DEF_MAXEXT) {\r
+                                       // EXTENTがデフォルトのときはコードのみ\r
+                                       sprintf(Buf, "%s%s,%d", Pkt->Cmd, Pkt->RemoteFile, Pkt->FileCode);\r
+                               } else {\r
+                                       sprintf(Buf, "%s%s,%d,%d,%d,%d", Pkt->Cmd, Pkt->RemoteFile, Pkt->FileCode, Pkt->PriExt, Pkt->SecExt, Pkt->MaxExt);\r
+                               }\r
+                       } else\r
+#endif\r
                        sprintf(Buf, "%s%s", Pkt->Cmd, Pkt->RemoteFile);\r
                else\r
                        sprintf(Buf, "%s%s", "APPE ", Pkt->RemoteFile);\r
@@ -2332,10 +2661,24 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
                iRetCode = command(Pkt->ctrl_skt, Reply, &Canceled[Pkt->ThreadCount], "%s", Buf);\r
                if((iRetCode/100) == FTP_PRELIM)\r
                {\r
-                       if(SocksGet2ndBindReply(listen_socket, &data_socket) == FFFTP_FAIL)\r
+                       // 同時接続対応\r
+//                     if(SocksGet2ndBindReply(listen_socket, &data_socket) == FFFTP_FAIL)\r
+                       if(SocksGet2ndBindReply(listen_socket, &data_socket, &Canceled[Pkt->ThreadCount]) == FFFTP_FAIL)\r
                        {\r
-                               iLength=sizeof(saSockAddr1);\r
-                               data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
+                               // IPv6対応\r
+//                             iLength=sizeof(saSockAddr1);\r
+//                             data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
+                               switch(AskCurNetType())\r
+                               {\r
+                               case NTYPE_IPV4:\r
+                                       iLength=sizeof(saSockAddrIPv4);\r
+                                       data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv4, (int *)&iLength);\r
+                                       break;\r
+                               case NTYPE_IPV6:\r
+                                       iLength=sizeof(saSockAddrIPv6);\r
+                                       data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv6, (int *)&iLength);\r
+                                       break;\r
+                               }\r
 \r
                                if(shutdown(listen_socket, 1) != 0)\r
                                        ReportWSError("shutdown listen", WSAGetLastError());\r
@@ -2348,7 +2691,19 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
                                        iRetCode = 500;\r
                                }\r
                                else\r
-                                       DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
+                                       // IPv6対応\r
+//                                     DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
+                               {\r
+                                       switch(AskCurNetType())\r
+                                       {\r
+                                       case NTYPE_IPV4:\r
+                                               DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddrIPv4.sin_addr), ntohs(saSockAddrIPv4.sin_port));\r
+                                               break;\r
+                                       case NTYPE_IPV6:\r
+                                               DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet6_ntoa(saSockAddrIPv6.sin6_addr), ntohs(saSockAddrIPv6.sin6_port));\r
+                                               break;\r
+                                       }\r
+                               }\r
                        }\r
 \r
                        if(data_socket != INVALID_SOCKET)\r
@@ -2359,7 +2714,7 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
 //                             iRetCode = UpLoadFile(Pkt, data_socket);\r
                                if(IsSSLAttached(Pkt->ctrl_skt))\r
                                {\r
-                                       if(AttachSSL(data_socket, Pkt->ctrl_skt))\r
+                                       if(AttachSSL(data_socket, Pkt->ctrl_skt, &Canceled[Pkt->ThreadCount]))\r
                                                iRetCode = UpLoadFile(Pkt, data_socket);\r
                                        else\r
                                                iRetCode = 500;\r
@@ -2402,7 +2757,9 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
        int iRetCode;\r
        SOCKET data_socket = INVALID_SOCKET;   // data channel socket\r
        char Buf[1024];\r
-       char Adrs[20];\r
+       // IPv6対応\r
+//     char Adrs[20];\r
+       char Adrs[40];\r
        int Port;\r
        int Flg;\r
        int Resume;\r
@@ -2410,10 +2767,22 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
 \r
        // 同時接続対応\r
 //     iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled, "PASV");\r
-       iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "PASV");\r
+       // IPv6対応\r
+//     iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "PASV");\r
+       switch(AskCurNetType())\r
+       {\r
+       case NTYPE_IPV4:\r
+               iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "PASV");\r
+               break;\r
+       case NTYPE_IPV6:\r
+               iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "EPSV");\r
+               break;\r
+       }\r
        if(iRetCode/100 == FTP_COMPLETE)\r
        {\r
-               if(GetAdrsAndPort(Buf, Adrs, &Port, 19) == FFFTP_SUCCESS)\r
+               // IPv6対応\r
+//             if(GetAdrsAndPort(Buf, Adrs, &Port, 19) == FFFTP_SUCCESS)\r
+               if(GetAdrsAndPort(Pkt->ctrl_skt, Buf, Adrs, &Port, 39) == FFFTP_SUCCESS)\r
                {\r
                        // 同時接続対応\r
 //                     if((data_socket = connectsock(Adrs, Port, MSGJPN109, &Canceled)) != INVALID_SOCKET)\r
@@ -2426,6 +2795,16 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
 \r
                                SetUploadResume(Pkt, Pkt->Mode, Pkt->ExistSize, &Resume);\r
                                if(Resume == NO)\r
+#if defined(HAVE_TANDEM)\r
+                                       if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO && Pkt->Type != TYPE_A) {\r
+                                               if( Pkt->PriExt == DEF_PRIEXT && Pkt->SecExt == DEF_SECEXT && Pkt->MaxExt == DEF_MAXEXT) {\r
+                                                       // EXTENTがデフォルトのときはコードのみ\r
+                                                       sprintf(Buf, "%s%s,%d", Pkt->Cmd, Pkt->RemoteFile, Pkt->FileCode);\r
+                                               } else {\r
+                                                       sprintf(Buf, "%s%s,%d,%d,%d,%d", Pkt->Cmd, Pkt->RemoteFile, Pkt->FileCode, Pkt->PriExt, Pkt->SecExt, Pkt->MaxExt);\r
+                                               }\r
+                                       } else\r
+#endif\r
                                        sprintf(Buf, "%s%s", Pkt->Cmd, Pkt->RemoteFile);\r
                                else\r
                                        sprintf(Buf, "%s%s", "APPE ", Pkt->RemoteFile);\r
@@ -2441,7 +2820,7 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
 //                                     iRetCode = UpLoadFile(Pkt, data_socket);\r
                                        if(IsSSLAttached(Pkt->ctrl_skt))\r
                                        {\r
-                                               if(AttachSSL(data_socket, Pkt->ctrl_skt))\r
+                                               if(AttachSSL(data_socket, Pkt->ctrl_skt, &Canceled[Pkt->ThreadCount]))\r
                                                        iRetCode = UpLoadFile(Pkt, data_socket);\r
                                                else\r
                                                        iRetCode = 500;\r
@@ -2625,6 +3004,11 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                        cInfo2.OutLen = cInfo.OutLen;\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvSJIStoUTF8N(&cInfo);\r
+                                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -2668,6 +3052,14 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                        ConvSJIStoEUC(&cInfo2);\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvJIStoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -2714,6 +3106,14 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                        ConvSJIStoEUC(&cInfo2);\r
                                                        break;\r
                                                case KANJI_UTF8N:\r
+                                                       Continue = ConvEUCtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoUTF8N(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
                                                        if(ProcessedBOM == NO)\r
                                                        {\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
@@ -2732,6 +3132,50 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                }\r
                                                break;\r
                                        case KANJI_UTF8N:\r
+                                               switch(Pkt->KanjiCode)\r
+                                               {\r
+                                               case KANJI_SJIS:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                                       cInfo2.OutLen = cInfo.OutLen;\r
+                                                       break;\r
+                                               case KANJI_JIS:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoJIS(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_EUC:\r
+                                                       Continue = ConvUTF8NtoSJIS(&cInfo);\r
+                                                       cInfo2.Str = cInfo.Buf;\r
+                                                       cInfo2.StrLen = cInfo.OutLen;\r
+                                                       cInfo2.Buf = Buf3;\r
+                                                       cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                                       ConvSJIStoEUC(&cInfo2);\r
+                                                       break;\r
+                                               case KANJI_UTF8N:\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
+                                               case KANJI_UTF8BOM:\r
+                                                       if(ProcessedBOM == NO)\r
+                                                       {\r
+                                                               memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
+                                                               cInfo2.OutLen = 3;\r
+                                                               Continue = YES;\r
+                                                               ProcessedBOM = YES;\r
+                                                               break;\r
+                                                       }\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
+                                               }\r
+                                               break;\r
+                                       case KANJI_UTF8BOM:\r
                                                if(ProcessedBOM == NO)\r
                                                {\r
                                                        if(memcmp(Buf, "\xEF\xBB\xBF", 3) == 0)\r
@@ -2742,7 +3186,7 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                        cInfo2.OutLen = 0;\r
                                                        switch(Pkt->KanjiCode)\r
                                                        {\r
-                                                       case KANJI_UTF8N:\r
+                                                       case KANJI_UTF8BOM:\r
                                                                memcpy(Buf3, "\xEF\xBB\xBF", 3);\r
                                                                cInfo2.OutLen = 3;\r
                                                                break;\r
@@ -2779,12 +3223,17 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                        cInfo2.OutLen = cInfo.StrLen;\r
                                                        Continue = NO;\r
                                                        break;\r
+                                               case KANJI_UTF8BOM:\r
+                                                       memcpy(Buf3, cInfo.Str, cInfo.StrLen);\r
+                                                       cInfo2.OutLen = cInfo.StrLen;\r
+                                                       Continue = NO;\r
+                                                       break;\r
                                                }\r
                                                break;\r
                                        }\r
 \r
 //                                     if(TermCodeConvAndSend(&tInfo, dSkt, Buf2, cInfo.OutLen, Pkt->Type) == FFFTP_FAIL)\r
-                                       if(TermCodeConvAndSend(Pkt->ThreadCount, &tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type) == FFFTP_FAIL)\r
+                                       if(TermCodeConvAndSend(&tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type, &Canceled[Pkt->ThreadCount]) == FFFTP_FAIL)\r
                                        {\r
                                                Pkt->Abort = ABORT_ERROR;\r
                                                        break;\r
@@ -2796,7 +3245,7 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                        {\r
                                // 同時接続対応\r
 //                             if(TermCodeConvAndSend(&tInfo, dSkt, Buf, iNumBytes, Pkt->Type) == FFFTP_FAIL)\r
-                               if(TermCodeConvAndSend(Pkt->ThreadCount, &tInfo, dSkt, Buf, iNumBytes, Pkt->Type) == FFFTP_FAIL)\r
+                               if(TermCodeConvAndSend(&tInfo, dSkt, Buf, iNumBytes, Pkt->Type, &Canceled[Pkt->ThreadCount]) == FFFTP_FAIL)\r
                                        Pkt->Abort = ABORT_ERROR;\r
                        }\r
 \r
@@ -2846,6 +3295,10 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
                                                cInfo2.OutLen = cInfo.OutLen;\r
                                                break;\r
+                                       case KANJI_UTF8BOM:\r
+                                               memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                               cInfo2.OutLen = cInfo.OutLen;\r
+                                               break;\r
                                        }\r
                                        break;\r
                                case KANJI_JIS:\r
@@ -2877,6 +3330,13 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
                                                ConvSJIStoUTF8N(&cInfo2);\r
                                                break;\r
+                                       case KANJI_UTF8BOM:\r
+                                               cInfo2.Str = cInfo.Buf;\r
+                                               cInfo2.StrLen = cInfo.OutLen;\r
+                                               cInfo2.Buf = Buf3;\r
+                                               cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                               ConvSJIStoUTF8N(&cInfo2);\r
+                                               break;\r
                                        }\r
                                        break;\r
                                case KANJI_EUC:\r
@@ -2908,6 +3368,13 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
                                                ConvSJIStoUTF8N(&cInfo2);\r
                                                break;\r
+                                       case KANJI_UTF8BOM:\r
+                                               cInfo2.Str = cInfo.Buf;\r
+                                               cInfo2.StrLen = cInfo.OutLen;\r
+                                               cInfo2.Buf = Buf3;\r
+                                               cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                               ConvSJIStoUTF8N(&cInfo2);\r
+                                               break;\r
                                        }\r
                                        break;\r
                                case KANJI_UTF8N:\r
@@ -2935,17 +3402,52 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
                                                memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
                                                cInfo2.OutLen = cInfo.OutLen;\r
                                                break;\r
+                                       case KANJI_UTF8BOM:\r
+                                               memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                               cInfo2.OutLen = cInfo.OutLen;\r
+                                               break;\r
+                                       }\r
+                                       break;\r
+                               case KANJI_UTF8BOM:\r
+                                       switch(Pkt->KanjiCode)\r
+                                       {\r
+                                       case KANJI_SJIS:\r
+                                               memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                               cInfo2.OutLen = cInfo.OutLen;\r
+                                               break;\r
+                                       case KANJI_JIS:\r
+                                               cInfo2.Str = cInfo.Buf;\r
+                                               cInfo2.StrLen = cInfo.OutLen;\r
+                                               cInfo2.Buf = Buf3;\r
+                                               cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                               ConvSJIStoJIS(&cInfo2);\r
+                                               break;\r
+                                       case KANJI_EUC:\r
+                                               cInfo2.Str = cInfo.Buf;\r
+                                               cInfo2.StrLen = cInfo.OutLen;\r
+                                               cInfo2.Buf = Buf3;\r
+                                               cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
+                                               ConvSJIStoEUC(&cInfo2);\r
+                                               break;\r
+                                       case KANJI_UTF8N:\r
+                                               memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                               cInfo2.OutLen = cInfo.OutLen;\r
+                                               break;\r
+                                       case KANJI_UTF8BOM:\r
+                                               memcpy(Buf3, cInfo.Buf, cInfo.OutLen);\r
+                                               cInfo2.OutLen = cInfo.OutLen;\r
+                                               break;\r
                                        }\r
                                        break;\r
                                }\r
 \r
 //                             if(TermCodeConvAndSend(&tInfo, dSkt, Buf2, cInfo.OutLen, Pkt->Type) == FFFTP_FAIL)\r
-                               if(TermCodeConvAndSend(Pkt->ThreadCount, &tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type) == FFFTP_FAIL)\r
+                               if(TermCodeConvAndSend(&tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type, &Canceled[Pkt->ThreadCount]) == FFFTP_FAIL)\r
                                        Pkt->Abort = ABORT_ERROR;\r
                                cInfo2.Buf = Buf3;\r
                                cInfo2.BufSize = (BUFSIZE + 3) * 4;\r
                                FlushRestData(&cInfo2);\r
-                               if(TermCodeConvAndSend(Pkt->ThreadCount, &tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type) == FFFTP_FAIL)\r
+                               if(TermCodeConvAndSend(&tInfo, dSkt, Buf3, cInfo2.OutLen, Pkt->Type, &Canceled[Pkt->ThreadCount]) == FFFTP_FAIL)\r
                                        Pkt->Abort = ABORT_ERROR;\r
                        }\r
 \r
@@ -3017,7 +3519,7 @@ static int UpLoadFile(TRANSPACKET *Pkt, SOCKET dSkt)
 \r
 // 同時接続対応\r
 //static int TermCodeConvAndSend(TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii)\r
-static int TermCodeConvAndSend(int ThreadCount, TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii)\r
+static int TermCodeConvAndSend(TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, int Size, int Ascii, int *CancelCheckWork)\r
 {\r
        char Buf3[BUFSIZE*2];\r
        int Continue;\r
@@ -3037,7 +3539,7 @@ static int TermCodeConvAndSend(int ThreadCount, TERMCODECONVINFO *tInfo, SOCKET
                        Continue = ConvTermCodeToCRLF(tInfo);\r
                        // 同時接続対応\r
 //                     if((Ret = SendData(Skt, Buf3, tInfo->OutLen, 0, &Canceled)) == FFFTP_FAIL)\r
-                       if((Ret = SendData(Skt, Buf3, tInfo->OutLen, 0, &Canceled[ThreadCount])) == FFFTP_FAIL)\r
+                       if((Ret = SendData(Skt, Buf3, tInfo->OutLen, 0, CancelCheckWork)) == FFFTP_FAIL)\r
                                break;\r
                }\r
                while(Continue == YES);\r
@@ -3045,7 +3547,7 @@ static int TermCodeConvAndSend(int ThreadCount, TERMCODECONVINFO *tInfo, SOCKET
        else\r
                // 同時接続対応\r
 //             Ret = SendData(Skt, Data, Size, 0, &Canceled);\r
-               Ret = SendData(Skt, Data, Size, 0, &Canceled[ThreadCount]);\r
+               Ret = SendData(Skt, Data, Size, 0, CancelCheckWork);\r
 \r
        return(Ret);\r
 }\r
@@ -3079,8 +3581,22 @@ static void DispUploadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
                        {\r
                                // 全て中止を選択後にダイアログが表示されるバグ対策\r
 //                             if(DispUpDownErrDialog(uperr_dlg, Pkt->hWndTrans, Pkt->LocalFile) == NO)\r
-                               if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO && DispUpDownErrDialog(uperr_dlg, Pkt->hWndTrans, Pkt->LocalFile) == NO)\r
-                                       ClearAll = YES;\r
+                               // 再転送対応\r
+//                             if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO && DispUpDownErrDialog(uperr_dlg, Pkt->hWndTrans, Pkt->LocalFile) == NO)\r
+//                                     ClearAll = YES;\r
+                               if(Canceled[Pkt->ThreadCount] == NO && ClearAll == NO)\r
+                               {\r
+                                       if(strncmp(Pkt->Cmd, "RETR", 4) == 0 || strncmp(Pkt->Cmd, "STOR", 4) == 0)\r
+                                       {\r
+                                               if(TransferErrorNotify == YES && DispUpDownErrDialog(uperr_dlg, Pkt->hWndTrans, Pkt) == NO)\r
+                                                       ClearAll = YES;\r
+                                               else\r
+                                               {\r
+                                                       Pkt->Mode = TransferErrorMode;\r
+                                                       AddTransFileList(Pkt);\r
+                                               }\r
+                                       }\r
+                               }\r
                        }\r
                }\r
                else\r
@@ -3186,7 +3702,9 @@ static LRESULT CALLBACK TransDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
                                        /* ここに break はない */\r
 \r
                                case IDCANCEL :\r
-                                       if(!(Pkt = (TRANSPACKET*)GetWindowLong(hDlg, GWL_USERDATA)))\r
+                                       // 64ビット対応\r
+//                                     if(!(Pkt = (TRANSPACKET*)GetWindowLong(hDlg, GWL_USERDATA)))\r
+                                       if(!(Pkt = (TRANSPACKET*)GetWindowLongPtr(hDlg, GWLP_USERDATA)))\r
                                                break;\r
                                        Pkt->Abort = ABORT_USER;\r
 //                                     Canceled = YES;\r
@@ -3202,7 +3720,9 @@ static LRESULT CALLBACK TransDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
                                        SetForegroundWindow(hDlg);\r
                                MoveToForeground = NO;\r
                                KillTimer(hDlg, TIMER_DISPLAY);\r
-                               if(!(Pkt = (TRANSPACKET*)GetWindowLong(hDlg, GWL_USERDATA)))\r
+                               // 64ビット対応\r
+//                             if(!(Pkt = (TRANSPACKET*)GetWindowLong(hDlg, GWL_USERDATA)))\r
+                               if(!(Pkt = (TRANSPACKET*)GetWindowLongPtr(hDlg, GWLP_USERDATA)))\r
                                        break;\r
                                if(Canceled[Pkt->ThreadCount] == YES)\r
                                        Pkt->Abort = ABORT_USER;\r
@@ -3213,7 +3733,9 @@ static LRESULT CALLBACK TransDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
 \r
                case WM_SET_PACKET :\r
 //                     Pkt = (TRANSPACKET *)lParam;\r
-                       SetWindowLong(hDlg, GWL_USERDATA, (LONG)lParam);\r
+                       // 64ビット対応\r
+//                     SetWindowLong(hDlg, GWL_USERDATA, (LONG)lParam);\r
+                       SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam);\r
                        break;\r
        }\r
        return(FALSE);\r
@@ -3360,6 +3882,8 @@ static void DispTransFileInfo(TRANSPACKET *Pkt, char *Title, int SkipButton, int
                                SendDlgItemMessage(Pkt->hWndTrans, TRANS_KANJI, WM_SETTEXT, 0, (LPARAM)MSGJPN123);\r
                        else if(Pkt->KanjiCode == KANJI_UTF8N)\r
                                SendDlgItemMessage(Pkt->hWndTrans, TRANS_KANJI, WM_SETTEXT, 0, (LPARAM)MSGJPN306);\r
+                       else if(Pkt->KanjiCode == KANJI_UTF8BOM)\r
+                               SendDlgItemMessage(Pkt->hWndTrans, TRANS_KANJI, WM_SETTEXT, 0, (LPARAM)MSGJPN329);\r
                }\r
                else\r
                {\r
@@ -3386,10 +3910,31 @@ static void DispTransFileInfo(TRANSPACKET *Pkt, char *Title, int SkipButton, int
 *                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max)\r
+static int GetAdrsAndPort(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max)\r
+{\r
+       int Result;\r
+       Result = FFFTP_FAIL;\r
+       switch(AskCurNetType())\r
+       {\r
+       case NTYPE_IPV4:\r
+               Result = GetAdrsAndPortIPv4(Skt, Str, Adrs, Port, Max);\r
+               break;\r
+       case NTYPE_IPV6:\r
+               Result = GetAdrsAndPortIPv6(Skt, Str, Adrs, Port, Max);\r
+               break;\r
+       }\r
+       return Result;\r
+}\r
+\r
+\r
+// IPv6対応\r
+//static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max)\r
+static int GetAdrsAndPortIPv4(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max)\r
 {\r
        char *Pos;\r
        char *Btm;\r
+       // コンマではなくドットを返すホストがあるため\r
+       char *OldBtm;\r
        int Sts;\r
 \r
        Sts = FFFTP_FAIL;\r
@@ -3399,18 +3944,36 @@ static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max)
        {\r
                Pos++;\r
                Btm = strchr(Pos, ',');\r
+               // コンマではなくドットを返すホストがあるため\r
+               if(Btm == NULL)\r
+                       Btm = strchr(Pos, '.');\r
                if(Btm != NULL)\r
                {\r
                        Btm++;\r
-                       Btm = strchr(Btm, ',');\r
+                       // コンマではなくドットを返すホストがあるため\r
+//                     Btm = strchr(Btm, ',');\r
+                       OldBtm = Btm;\r
+                       Btm = strchr(OldBtm, ',');\r
+                       if(Btm == NULL)\r
+                               Btm = strchr(OldBtm, '.');\r
                        if(Btm != NULL)\r
                        {\r
                                Btm++;\r
-                               Btm = strchr(Btm, ',');\r
+                               // コンマではなくドットを返すホストがあるため\r
+//                             Btm = strchr(Btm, ',');\r
+                               OldBtm = Btm;\r
+                               Btm = strchr(OldBtm, ',');\r
+                               if(Btm == NULL)\r
+                                       Btm = strchr(OldBtm, '.');\r
                                if(Btm != NULL)\r
                                {\r
                                        Btm++;\r
-                                       Btm = strchr(Btm, ',');\r
+                                       // コンマではなくドットを返すホストがあるため\r
+//                                     Btm = strchr(Btm, ',');\r
+                                       OldBtm = Btm;\r
+                                       Btm = strchr(OldBtm, ',');\r
+                                       if(Btm == NULL)\r
+                                               Btm = strchr(OldBtm, '.');\r
                                        if(Btm != NULL)\r
                                        {\r
                                                if((Btm - Pos) <= Max)\r
@@ -3421,6 +3984,9 @@ static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max)
 \r
                                                        Pos = Btm + 1;\r
                                                        Btm = strchr(Pos, ',');\r
+                                                       // コンマではなくドットを返すホストがあるため\r
+                                                       if(Btm == NULL)\r
+                                                               Btm = strchr(Pos, '.');\r
                                                        if(Btm != NULL)\r
                                                        {\r
                                                                Btm++;\r
@@ -3437,6 +4003,65 @@ static int GetAdrsAndPort(char *Str, char *Adrs, int *Port, int Max)
 }\r
 \r
 \r
+// IPv6対応\r
+static int GetAdrsAndPortIPv6(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max)\r
+{\r
+       char *Pos;\r
+       char *Btm;\r
+       int Sts;\r
+       int i;\r
+       struct sockaddr_in6 SockAddr;\r
+\r
+       Sts = FFFTP_FAIL;\r
+\r
+       Btm = strchr(Str, '(');\r
+       if(Btm != NULL)\r
+       {\r
+               Btm++;\r
+               Btm = strchr(Btm, '|');\r
+               if(Btm != NULL)\r
+               {\r
+                       Pos = Btm + 1;\r
+                       Btm = strchr(Pos, '|');\r
+                       if(Btm != NULL)\r
+                       {\r
+                               Pos = Btm + 1;\r
+                               Btm = strchr(Pos, '|');\r
+                               if(Btm != NULL)\r
+                               {\r
+                                       if((Btm - Pos) <= Max)\r
+                                       {\r
+                                               if((Btm - Pos) > 0)\r
+                                               {\r
+                                                       strncpy(Adrs, Pos, Btm - Pos);\r
+                                                       *(Adrs + (Btm - Pos)) = NUL;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       i = sizeof(SockAddr);\r
+                                                       if(getpeername(Skt, (struct sockaddr*)&SockAddr, &i) != SOCKET_ERROR)\r
+                                                               AddressToStringIPv6(Adrs, &SockAddr.sin6_addr);\r
+                                               }\r
+\r
+                                               Pos = Btm + 1;\r
+                                               Btm = strchr(Pos, '|');\r
+                                               if(Btm != NULL)\r
+                                               {\r
+                                                       Btm++;\r
+                                                       *Port = atoi(Pos);\r
+                                                       Btm = strchr(Btm, ')');\r
+                                                       if(Btm != NULL)\r
+                                                               Sts = FFFTP_SUCCESS;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       return(Sts);\r
+}\r
+\r
+\r
 /*----- Windowsのスペシャルデバイスかどうかを返す -----------------------------\r
 *\r
 *      Parameter\r
@@ -3525,7 +4150,9 @@ static int MirrorDelNotify(int Cur, int Notify, TRANSPACKET *Pkt)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK MirrorDeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
 {\r
        static MIRRORDELETEINFO *DelInfo;\r
        switch (iMessage)\r