OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / getput.c
index 5a3b750..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,27 +88,41 @@ 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
 \r
 /*===== ローカルなワーク =====*/\r
 \r
@@ -120,6 +136,8 @@ static HANDLE hListAccMutex;                        /* 転送ファイルアクセス用ミューテ
 \r
 static int TransFiles = 0;                             /* 転送待ちファイル数 */\r
 static TRANSPACKET *TransPacketBase = NULL;    /* 転送ファイルリスト */\r
+// 同時接続対応\r
+static TRANSPACKET *NextTransPacketBase = NULL;\r
 \r
 // 同時接続対応\r
 //static int Canceled;         /* 中止フラグ YES/NO */\r
@@ -138,8 +156,20 @@ 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
-static char ErrMsg[ERR_MSG_LEN+7];\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
+static DWORD ErrMsgThreadId[MAX_DATA_CONNECTION+1];\r
+static HANDLE hErrMsgMutex;\r
+\r
+// 同時接続対応\r
+static int WaitForMainThread = NO;\r
+// 再転送対応\r
+static int TransferErrorMode = EXIST_OVW;\r
+static int TransferErrorNotify = NO;\r
 \r
 /*===== 外部参照 =====*/\r
 \r
@@ -170,6 +200,8 @@ int MakeTransferThread(void)
 \r
        hListAccMutex = CreateMutex( NULL, FALSE, NULL );\r
        hRunMutex = CreateMutex( NULL, TRUE, NULL );\r
+       // 同時接続対応\r
+       hErrMsgMutex = CreateMutex( NULL, FALSE, NULL );\r
 \r
        ClearAll = NO;\r
        ForceAbort = NO;\r
@@ -231,6 +263,8 @@ void CloseTransferThread(void)
 \r
        CloseHandle( hListAccMutex );\r
        CloseHandle( hRunMutex );\r
+       // 同時接続対応\r
+       CloseHandle( hErrMsgMutex );\r
        return;\r
 }\r
 \r
@@ -354,10 +388,27 @@ int RemoveTmpTransFileListItem(TRANSPACKET **Base, int Num)
 \r
 void AddTransFileList(TRANSPACKET *Pkt)\r
 {\r
+       // 同時接続対応\r
+       TRANSPACKET *Pos;\r
+\r
        DispTransPacket(Pkt);\r
 \r
-       WaitForSingleObject(hListAccMutex, INFINITE);\r
+       // 同時接続対応\r
+//     WaitForSingleObject(hListAccMutex, INFINITE);\r
+       while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+       {\r
+               WaitForMainThread = YES;\r
+               BackgrndMessageProc();\r
+               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
@@ -367,7 +418,17 @@ void AddTransFileList(TRANSPACKET *Pkt)
                        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
                }\r
        }\r
+       // 同時接続対応\r
+       if(NextTransPacketBase == NULL)\r
+       {\r
+               if(Pos)\r
+                       NextTransPacketBase = Pos->Next;\r
+               else\r
+                       NextTransPacketBase = TransPacketBase;\r
+       }\r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
 \r
        return;\r
 }\r
@@ -390,7 +451,14 @@ void AppendTransFileList(TRANSPACKET *Pkt)
 {\r
        TRANSPACKET *Pos;\r
 \r
-       WaitForSingleObject(hListAccMutex, INFINITE);\r
+       // 同時接続対応\r
+//     WaitForSingleObject(hListAccMutex, INFINITE);\r
+       while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+       {\r
+               WaitForMainThread = YES;\r
+               BackgrndMessageProc();\r
+               Sleep(1);\r
+       }\r
 \r
        if(TransPacketBase == NULL)\r
                TransPacketBase = Pkt;\r
@@ -401,6 +469,9 @@ void AppendTransFileList(TRANSPACKET *Pkt)
                        Pos = Pos->Next;\r
                Pos->Next = Pkt;\r
        }\r
+       // 同時接続対応\r
+       if(NextTransPacketBase == NULL)\r
+               NextTransPacketBase = Pkt;\r
 \r
        while(Pkt != NULL)\r
        {\r
@@ -416,6 +487,8 @@ void AppendTransFileList(TRANSPACKET *Pkt)
        }\r
 \r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
        return;\r
 }\r
 \r
@@ -468,7 +541,14 @@ static void EraseTransFileList(void)
 \r
        NotDel = NULL;\r
 \r
-       WaitForSingleObject(hListAccMutex, INFINITE);\r
+       // 同時接続対応\r
+//     WaitForSingleObject(hListAccMutex, INFINITE);\r
+       while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+       {\r
+               WaitForMainThread = YES;\r
+               BackgrndMessageProc();\r
+               Sleep(1);\r
+       }\r
        New = TransPacketBase;\r
        while(New != NULL)\r
        {\r
@@ -476,22 +556,31 @@ static void EraseTransFileList(void)
                if(strcmp(New->Cmd, "BACKCUR") == 0)\r
                {\r
                        if(NotDel != NULL)\r
-                               free(NotDel);\r
+                               // 同時接続対応\r
+//                             free(NotDel);\r
+                               strcpy(NotDel->Cmd, "");\r
                        NotDel = New;\r
                        New = New->Next;\r
-                       NotDel->Next = NULL;\r
+                       // 同時接続対応\r
+//                     NotDel->Next = NULL;\r
                }\r
                else\r
                {\r
                        Next = New->Next;\r
-                       free(New);\r
+                       // 同時接続対応\r
+//                     free(New);\r
+                       strcpy(New->Cmd, "");\r
                        New = Next;\r
                }\r
        }\r
        TransPacketBase = NotDel;\r
+       // 同時接続対応\r
+       NextTransPacketBase = NotDel;\r
        TransFiles = 0;\r
        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
 \r
        strcpy(Pkt.Cmd, "GOQUIT");\r
        AddTransFileList(&Pkt);\r
@@ -572,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
@@ -593,8 +686,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
        char Tmp[FMAX_PATH+1];\r
        int CwdSts;\r
        int GoExit;\r
-       int Down;\r
-       int Up;\r
+//     int Down;\r
+//     int Up;\r
+       static int Down;\r
+       static int Up;\r
        int DelNotify;\r
        int ThreadCount;\r
        SOCKET CmdSkt;\r
@@ -602,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
@@ -614,6 +710,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
        CmdSkt = INVALID_SOCKET;\r
        NewCmdSkt = INVALID_SOCKET;\r
        TrnSkt = INVALID_SOCKET;\r
+       SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);\r
 \r
        while((TransPacketBase != NULL) ||\r
                  (WaitForSingleObject(hRunMutex, 200) == WAIT_TIMEOUT))\r
@@ -621,38 +718,103 @@ static ULONG WINAPI TransferThread(void *Dummy)
                if(fTransferThreadExit == TRUE)\r
                        break;\r
 \r
-               WaitForSingleObject(hListAccMutex, INFINITE);\r
-               memset(ErrMsg, NUL, ERR_MSG_LEN+7);\r
+               if(WaitForMainThread == YES)\r
+               {\r
+                       BackgrndMessageProc();\r
+                       Sleep(100);\r
+                       continue;\r
+               }\r
+\r
+//             WaitForSingleObject(hListAccMutex, INFINITE);\r
+               while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+               {\r
+                       BackgrndMessageProc();\r
+                       Sleep(1);\r
+               }\r
+//             memset(ErrMsg, NUL, ERR_MSG_LEN+7);\r
+               memset(GetErrMsg(), NUL, ERR_MSG_LEN+7);\r
 \r
 //             Canceled = NO;\r
                Canceled[ThreadCount] = NO;\r
 \r
+               while(TransPacketBase != NULL && strcmp(TransPacketBase->Cmd, "") == 0)\r
+               {\r
+                       Pos = TransPacketBase;\r
+                       TransPacketBase = TransPacketBase->Next;\r
+                       free(Pos);\r
+               }\r
                NewCmdSkt = AskCmdCtrlSkt();\r
-               if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())\r
+               if(AskReuseCmdSkt() == YES && ThreadCount == 0)\r
                {\r
-                       if(TrnSkt == INVALID_SOCKET || NewCmdSkt != CmdSkt)\r
-                       {\r
-                               ReleaseMutex(hListAccMutex);\r
-                               ReConnectTrnSkt(&TrnSkt);\r
-                               WaitForSingleObject(hListAccMutex, INFINITE);\r
-                       }\r
+                       if(TransPacketBase && ThreadCount < AskMaxThreadCount())\r
+                               TrnSkt = AskTrnCtrlSkt();\r
                }\r
                else\r
                {\r
-                       if(TrnSkt != INVALID_SOCKET)\r
+                       if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())\r
                        {\r
-                               ReleaseMutex(hListAccMutex);\r
-                               DoClose(TrnSkt);\r
-                               TrnSkt = INVALID_SOCKET;\r
-                               WaitForSingleObject(hListAccMutex, INFINITE);\r
+                               if(TrnSkt == INVALID_SOCKET || NewCmdSkt != CmdSkt)\r
+                               {\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
+                       else\r
+                       {\r
+                               if(TrnSkt != INVALID_SOCKET)\r
+                               {\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
                CmdSkt = NewCmdSkt;\r
 //             if(TransPacketBase != NULL)\r
-               if(TrnSkt != INVALID_SOCKET && TransPacketBase != NULL)\r
+               if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)\r
                {\r
-                       Pos = TransPacketBase;\r
-                       TransPacketBase = TransPacketBase->Next;\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
 //                     ReleaseMutex(hListAccMutex);\r
                        if(hWndTrans == NULL)\r
@@ -706,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
@@ -715,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
@@ -740,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
@@ -769,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
@@ -779,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
@@ -806,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
@@ -831,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
@@ -844,7 +1006,6 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //                     else if(strncmp(TransPacketBase->Cmd, "R-DELE", 6) == 0)\r
                        else if(strncmp(Pos->Cmd, "R-DELE", 6) == 0)\r
                        {\r
-                               ReleaseMutex(hListAccMutex);\r
 //                             DispTransFileInfo(TransPacketBase, MSGJPN081, FALSE, YES);\r
                                DispTransFileInfo(Pos, MSGJPN081, FALSE, YES);\r
 \r
@@ -854,13 +1015,14 @@ 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
                        }\r
                        /* ディレクトリ作成(常にローカル側) */\r
 //                     else if(strncmp(TransPacketBase->Cmd, "L-MKD", 5) == 0)\r
@@ -912,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
@@ -926,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
@@ -958,13 +1122,19 @@ static ULONG WINAPI TransferThread(void *Dummy)
 \r
                        if(ForceAbort == NO)\r
                        {\r
-                               WaitForSingleObject(hListAccMutex, INFINITE);\r
+//                             WaitForSingleObject(hListAccMutex, INFINITE);\r
+                               while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
+                               {\r
+                                       BackgrndMessageProc();\r
+                                       Sleep(1);\r
+                               }\r
                                if(ClearAll == YES)\r
 //                                     EraseTransFileList();\r
                                {\r
                                        for(i = 0; i < MAX_DATA_CONNECTION; i++)\r
                                                Canceled[i] = YES;\r
                                        EraseTransFileList();\r
+                                       Pos = NULL;\r
                                }\r
                                else\r
                                {\r
@@ -994,7 +1164,9 @@ static ULONG WINAPI TransferThread(void *Dummy)
                        }\r
                        if(hWndTrans != NULL)\r
                                SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);\r
-                       free(Pos);\r
+                       if(Pos != NULL)\r
+                               strcpy(Pos->Cmd, "");\r
+                       LastUsed = timeGetTime();\r
                }\r
 //             else\r
                else if(TransPacketBase == NULL)\r
@@ -1009,30 +1181,45 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                        DestroyWindow(hWndTrans);\r
                                        hWndTrans = NULL;\r
 \r
-                                       if(GoExit == YES)\r
-                                       {\r
-                                               SoundPlay(SND_TRANS);\r
-\r
-                                               if(AskAutoExit() == NO)\r
-                                               {\r
-                                                       if(Down == YES)\r
-                                                               PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
-                                                       if(Up == YES)\r
-                                                               PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
-                                               }\r
-                                               Down = NO;\r
-                                               Up = NO;\r
-                                       }\r
+//                                     if(GoExit == YES)\r
+//                                     {\r
+//                                             SoundPlay(SND_TRANS);\r
+//\r
+//                                             if(AskAutoExit() == NO)\r
+//                                             {\r
+//                                                     if(Down == YES)\r
+//                                                             PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
+//                                                     if(Up == YES)\r
+//                                                             PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
+//                                             }\r
+//                                             Down = NO;\r
+//                                             Up = NO;\r
+//                                     }\r
                                }\r
                        }\r
                        BackgrndMessageProc();\r
-                       Sleep(1);\r
+//                     Sleep(1);\r
+                       Sleep(100);\r
 \r
                        if(GoExit == YES)\r
                        {\r
+                               SoundPlay(SND_TRANS);\r
+                               if(AskAutoExit() == NO)\r
+                               {\r
+                                       if(Down == YES)\r
+                                               PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
+                                       if(Up == YES)\r
+                                               PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
+                               }\r
+                               Down = NO;\r
+                               Up = NO;\r
                                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
@@ -1043,11 +1230,20 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                hWndTrans = NULL;\r
                        }\r
                        BackgrndMessageProc();\r
-                       Sleep(1);\r
+                       if(ThreadCount < AskMaxThreadCount())\r
+                               Sleep(1);\r
+                       else\r
+                               Sleep(100);\r
+               }\r
+       }\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
-       if(TrnSkt != INVALID_SOCKET)\r
-               DoClose(TrnSkt);\r
        return 0;\r
 }\r
 \r
@@ -1074,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
@@ -1131,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
@@ -1171,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
@@ -1182,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
@@ -1198,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
@@ -1207,12 +1438,12 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                                        ReleaseMutex(hListAccMutex);\r
                                        // FTPS対応\r
 //                                     iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
-                                       if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)\r
+                                       if(IsSSLAttached(Pkt->ctrl_skt))\r
                                        {\r
-                                               if(AttachSSL(data_socket))\r
+                                               if(AttachSSL(data_socket, Pkt->ctrl_skt, CancelCheckWork))\r
                                                        iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                                else\r
-                                                       iRetCode = FTP_ERROR;\r
+                                                       iRetCode = 500;\r
                                        }\r
                                        else\r
                                                iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
@@ -1256,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
@@ -1283,12 +1528,12 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                                                ReleaseMutex(hListAccMutex);\r
                                                // FTPS対応\r
 //                                             iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
-                                               if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)\r
+                                               if(IsSSLAttached(Pkt->ctrl_skt))\r
                                                {\r
-                                                       if(AttachSSL(data_socket))\r
+                                                       if(AttachSSL(data_socket, Pkt->ctrl_skt, CancelCheckWork))\r
                                                                iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
                                                        else\r
-                                                               iRetCode = FTP_ERROR;\r
+                                                               iRetCode = 500;\r
                                                }\r
                                                else\r
                                                        iRetCode = DownLoadFile(Pkt, data_socket, CreateMode, CancelCheckWork);\r
@@ -1394,8 +1639,12 @@ static int DownLoadFile(TRANSPACKET *Pkt, SOCKET dSkt, int CreateMode, int *Canc
                char Buf3[(BUFSIZE + 3) * 4];\r
                CODECONVINFO cInfo2;\r
                int ProcessedBOM = NO;\r
+               // 4GB超対応(kaokunさん提供)\r
+               DWORD High = 0;\r
                if(CreateMode == OPEN_ALWAYS)\r
-                       SetFilePointer(iFileHandle, 0, 0, FILE_END);\r
+                       // 4GB超対応(kaokunさん提供)\r
+//                     SetFilePointer(iFileHandle, 0, 0, FILE_END);\r
+                       SetFilePointer(iFileHandle, 0, &High, FILE_END);\r
 \r
                if(Pkt->hWndTrans != NULL)\r
                {\r
@@ -1473,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
@@ -1503,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
@@ -1546,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
@@ -1592,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
@@ -1610,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
@@ -1620,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
@@ -1657,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
@@ -1718,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
@@ -1749,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
@@ -1780,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
@@ -1807,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
@@ -1916,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
@@ -1934,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
@@ -1946,7 +2336,10 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
 //                     else if((Pkt->hWndTrans != NULL) && (TimeStart != 0))\r
 //                             SetTaskMsg(MSGJPN102, TimeStart, Pkt->ExistSize/TimeStart);\r
                        else if((Pkt->hWndTrans != NULL) && (TimeStart[Pkt->ThreadCount] != 0))\r
-                               SetTaskMsg(MSGJPN102, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               // "0 B/S"と表示されるバグを修正\r
+                               // 原因は%dにあたる部分に64ビット値が渡されているため\r
+//                             SetTaskMsg(MSGJPN102, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               SetTaskMsg(MSGJPN102, (LONG)TimeStart[Pkt->ThreadCount], (LONG)(Pkt->ExistSize/TimeStart[Pkt->ThreadCount]));\r
                        else\r
                                SetTaskMsg(MSGJPN103, Pkt->ExistSize);\r
                }\r
@@ -1966,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
@@ -1988,29 +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
-                       SendDlgItemMessage(hDlg, UPDOWN_ERR_MSG, WM_SETTEXT, 0, (LPARAM)ErrMsg);\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
@@ -2078,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
@@ -2142,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
@@ -2196,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
@@ -2206,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
@@ -2215,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
@@ -2231,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
@@ -2240,12 +2712,12 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
                                ReleaseMutex(hListAccMutex);\r
                                // FTPS対応\r
 //                             iRetCode = UpLoadFile(Pkt, data_socket);\r
-                               if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)\r
+                               if(IsSSLAttached(Pkt->ctrl_skt))\r
                                {\r
-                                       if(AttachSSL(data_socket))\r
+                                       if(AttachSSL(data_socket, Pkt->ctrl_skt, &Canceled[Pkt->ThreadCount]))\r
                                                iRetCode = UpLoadFile(Pkt, data_socket);\r
                                        else\r
-                                               iRetCode = FTP_ERROR;\r
+                                               iRetCode = 500;\r
                                }\r
                                else\r
                                        iRetCode = UpLoadFile(Pkt, data_socket);\r
@@ -2285,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
@@ -2293,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
@@ -2309,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
@@ -2322,12 +2818,12 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
                                        ReleaseMutex(hListAccMutex);\r
                                        // FTPS対応\r
 //                                     iRetCode = UpLoadFile(Pkt, data_socket);\r
-                                       if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)\r
+                                       if(IsSSLAttached(Pkt->ctrl_skt))\r
                                        {\r
-                                               if(AttachSSL(data_socket))\r
+                                               if(AttachSSL(data_socket, Pkt->ctrl_skt, &Canceled[Pkt->ThreadCount]))\r
                                                        iRetCode = UpLoadFile(Pkt, data_socket);\r
                                                else\r
-                                                       iRetCode = FTP_ERROR;\r
+                                                       iRetCode = 500;\r
                                        }\r
                                        else\r
                                                iRetCode = UpLoadFile(Pkt, data_socket);\r
@@ -2508,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
@@ -2551,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
@@ -2597,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
@@ -2615,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
@@ -2625,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
@@ -2662,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
@@ -2679,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
@@ -2729,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
@@ -2760,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
@@ -2791,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
@@ -2818,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
@@ -2900,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
@@ -2920,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
@@ -2928,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
@@ -2962,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
@@ -2972,7 +3605,10 @@ static void DispUploadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
 //                     if((Pkt->hWndTrans != NULL) && (TimeStart != 0))\r
 //                             SetTaskMsg(MSGJPN115, TimeStart, Pkt->ExistSize/TimeStart);\r
                        if((Pkt->hWndTrans != NULL) && (TimeStart[Pkt->ThreadCount] != 0))\r
-                               SetTaskMsg(MSGJPN115, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               // "0 B/S"と表示されるバグを修正\r
+                               // 原因は%dにあたる部分に64ビット値が渡されているため\r
+//                             SetTaskMsg(MSGJPN115, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               SetTaskMsg(MSGJPN115, (LONG)TimeStart[Pkt->ThreadCount], (LONG)(Pkt->ExistSize/TimeStart[Pkt->ThreadCount]));\r
                        else\r
                                SetTaskMsg(MSGJPN116);\r
                }\r
@@ -3066,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
@@ -3082,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
@@ -3093,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
@@ -3240,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
@@ -3266,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
@@ -3279,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
@@ -3301,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
@@ -3317,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
@@ -3405,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
@@ -3458,10 +4205,14 @@ static void SetErrorMsg(char *fmt, ...)
 {\r
        va_list Args;\r
 \r
-       if(strlen(ErrMsg) == 0)\r
+       // 同時接続対応\r
+//     if(strlen(ErrMsg) == 0)\r
+       if(strlen(GetErrMsg()) == 0)\r
        {\r
                va_start(Args, fmt);\r
-               wvsprintf(ErrMsg, fmt, Args);\r
+               // 同時接続対応\r
+//             wvsprintf(ErrMsg, fmt, Args);\r
+               wvsprintf(GetErrMsg(), fmt, Args);\r
                va_end(Args);\r
        }\r
        return;\r
@@ -3503,3 +4254,39 @@ int CheckPathViolation(TRANSPACKET *packet)
 }\r
 \r
 \r
+// 同時接続対応\r
+static char* GetErrMsg()\r
+{\r
+       char* r;\r
+       DWORD ThreadId;\r
+       int i;\r
+       r = NULL;\r
+       WaitForSingleObject(hErrMsgMutex, INFINITE);\r
+       ThreadId = GetCurrentThreadId();\r
+       i = 0;\r
+       while(i < MAX_DATA_CONNECTION + 1)\r
+       {\r
+               if(ErrMsgThreadId[i] == ThreadId)\r
+               {\r
+                       r = ErrMsg[i];\r
+                       break;\r
+               }\r
+               i++;\r
+       }\r
+       if(!r)\r
+       {\r
+               i = 0;\r
+               while(i < MAX_DATA_CONNECTION + 1)\r
+               {\r
+                       if(ErrMsgThreadId[i] == 0)\r
+                       {\r
+                               ErrMsgThreadId[i] = ThreadId;\r
+                               r = ErrMsg[i];\r
+                               break;\r
+                       }\r
+                       i++;\r
+               }\r
+       }\r
+       ReleaseMutex(hErrMsgMutex);\r
+       return r;\r
+}\r