OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / getput.c
index 0fce875..28c2471 100644 (file)
--- a/getput.c
+++ b/getput.c
@@ -43,7 +43,7 @@
 #include <time.h>\r
 // IPv6対応\r
 //#include <winsock.h>\r
-#include <ws2tcpip.h>\r
+#include <winsock2.h>\r
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 #include <process.h>\r
@@ -88,10 +88,16 @@ 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
@@ -111,7 +117,9 @@ static int GetAdrsAndPortIPv4(SOCKET Skt, char *Str, char *Adrs, int *Port, int
 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
@@ -159,6 +167,9 @@ static HANDLE hErrMsgMutex;
 \r
 // 同時接続対応\r
 static int WaitForMainThread = NO;\r
+// 再転送対応\r
+static int TransferErrorMode = EXIST_OVW;\r
+static int TransferErrorNotify = NO;\r
 \r
 /*===== 外部参照 =====*/\r
 \r
@@ -377,6 +388,9 @@ int RemoveTmpTransFileListItem(TRANSPACKET **Base, int Num)
 \r
 void AddTransFileList(TRANSPACKET *Pkt)\r
 {\r
+       // 同時接続対応\r
+       TRANSPACKET *Pos;\r
+\r
        DispTransPacket(Pkt);\r
 \r
        // 同時接続対応\r
@@ -388,6 +402,13 @@ void AddTransFileList(TRANSPACKET *Pkt)
                Sleep(1);\r
        }\r
 \r
+       // 同時接続対応\r
+       Pos = TransPacketBase;\r
+       if(Pos != NULL)\r
+       {\r
+               while(Pos->Next != NULL)\r
+                       Pos = Pos->Next;\r
+       }\r
        if(AddTmpTransFileList(Pkt, &TransPacketBase) == FFFTP_SUCCESS)\r
        {\r
                if((strncmp(Pkt->Cmd, "RETR", 4) == 0) ||\r
@@ -399,7 +420,12 @@ void AddTransFileList(TRANSPACKET *Pkt)
        }\r
        // 同時接続対応\r
        if(NextTransPacketBase == NULL)\r
-               NextTransPacketBase = TransPacketBase;\r
+       {\r
+               if(Pos)\r
+                       NextTransPacketBase = Pos->Next;\r
+               else\r
+                       NextTransPacketBase = TransPacketBase;\r
+       }\r
        ReleaseMutex(hListAccMutex);\r
        // 同時接続対応\r
        WaitForMainThread = NO;\r
@@ -445,7 +471,7 @@ void AppendTransFileList(TRANSPACKET *Pkt)
        }\r
        // 同時接続対応\r
        if(NextTransPacketBase == NULL)\r
-               NextTransPacketBase = TransPacketBase;\r
+               NextTransPacketBase = Pkt;\r
 \r
        while(Pkt != NULL)\r
        {\r
@@ -549,7 +575,7 @@ static void EraseTransFileList(void)
        }\r
        TransPacketBase = NotDel;\r
        // 同時接続対応\r
-       NextTransPacketBase = TransPacketBase;\r
+       NextTransPacketBase = NotDel;\r
        TransFiles = 0;\r
        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
        ReleaseMutex(hListAccMutex);\r
@@ -671,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
@@ -730,10 +757,13 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                {\r
                                        ReleaseMutex(hListAccMutex);\r
                                        ReConnectTrnSkt(&TrnSkt, &Canceled[ThreadCount]);\r
-                                       // 同時ログイン数制限に引っかかった可能性あり\r
-                                       // 負荷を下げるためにしばらく待機\r
-                                       if(TrnSkt == INVALID_SOCKET)\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
@@ -754,15 +784,20 @@ static ULONG WINAPI TransferThread(void *Dummy)
                        {\r
                                if(TrnSkt != INVALID_SOCKET)\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
+                                       // 10秒間は再利用を許可\r
+                                       if(timeGetTime() - LastUsed > 10000)\r
                                        {\r
-                                               BackgrndMessageProc();\r
-                                               Sleep(1);\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
@@ -771,6 +806,13 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //             if(TransPacketBase != NULL)\r
                if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)\r
                {\r
+                       if(strcmp(NextTransPacketBase->Cmd, "GOQUIT") == 0 && NextTransPacketBase != TransPacketBase)\r
+                       {\r
+                               ReleaseMutex(hListAccMutex);\r
+                               BackgrndMessageProc();\r
+                               Sleep(1);\r
+                               continue;\r
+                       }\r
                        Pos = NextTransPacketBase;\r
                        NextTransPacketBase = NextTransPacketBase->Next;\r
                        // ディレクトリ操作は非同期で行わない\r
@@ -1124,6 +1166,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);\r
                        if(Pos != NULL)\r
                                strcpy(Pos->Cmd, "");\r
+                       LastUsed = timeGetTime();\r
                }\r
 //             else\r
                else if(TransPacketBase == NULL)\r
@@ -1173,6 +1216,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0);\r
                                GoExit = NO;\r
                        }\r
+\r
+                       // 再転送対応\r
+                       TransferErrorMode = AskTransferErrorMode();\r
+                       TransferErrorNotify = AskTransferErrorNotify();\r
                }\r
                else\r
                {\r
@@ -1280,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
@@ -1341,13 +1394,13 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                                        // IPv6対応\r
 //                                     iLength = sizeof(saSockAddr1);\r
 //                                     data_socket = do_accept(listen_socket, (struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
-                                       switch(AskInetFamily())\r
+                                       switch(AskCurNetType())\r
                                        {\r
-                                       case AF_INET:\r
+                                       case NTYPE_IPV4:\r
                                                iLength=sizeof(saSockAddrIPv4);\r
                                                data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv4, (int *)&iLength);\r
                                                break;\r
-                                       case AF_INET6:\r
+                                       case NTYPE_IPV6:\r
                                                iLength=sizeof(saSockAddrIPv6);\r
                                                data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv6, (int *)&iLength);\r
                                                break;\r
@@ -1367,12 +1420,12 @@ static int DownLoadNonPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
                                                // IPv6対応\r
 //                                             DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
                                        {\r
-                                               switch(AskInetFamily())\r
+                                               switch(AskCurNetType())\r
                                                {\r
-                                               case AF_INET:\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 AF_INET6:\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
@@ -1443,12 +1496,12 @@ static int DownLoadPassive(TRANSPACKET *Pkt, int *CancelCheckWork)
 \r
        // IPv6対応\r
 //     iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "PASV");\r
-       switch(AskInetFamily())\r
+       switch(AskCurNetType())\r
        {\r
-       case AF_INET:\r
+       case NTYPE_IPV4:\r
                iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "PASV");\r
                break;\r
-       case AF_INET6:\r
+       case NTYPE_IPV6:\r
                iRetCode = command(Pkt->ctrl_skt, Buf, CancelCheckWork, "EPSV");\r
                break;\r
        }\r
@@ -1669,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
@@ -2235,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
@@ -2253,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
@@ -2288,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
@@ -2310,31 +2385,57 @@ static int DispUpDownErrDialog(int ResID, HWND hWnd, char *Fname)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK UpDownErrorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
+       static TRANSPACKET *Pkt;\r
+       static const RADIOBUTTON DownExistButton[] = {\r
+               { DOWN_EXIST_OVW, EXIST_OVW },\r
+               { DOWN_EXIST_RESUME, EXIST_RESUME },\r
+               { DOWN_EXIST_IGNORE, EXIST_IGNORE }\r
+       };\r
+       #define DOWNEXISTBUTTONS        (sizeof(DownExistButton)/sizeof(RADIOBUTTON))\r
+\r
        switch (message)\r
        {\r
                case WM_INITDIALOG :\r
-                       SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)lParam);\r
+                       Pkt = (TRANSPACKET *)lParam;\r
+//                     SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)lParam);\r
+                       SendDlgItemMessage(hDlg, UPDOWN_ERR_FNAME, WM_SETTEXT, 0, (LPARAM)Pkt->RemoteFile);\r
                        // 同時接続対応\r
 //                     SendDlgItemMessage(hDlg, UPDOWN_ERR_MSG, WM_SETTEXT, 0, (LPARAM)ErrMsg);\r
                        SendDlgItemMessage(hDlg, UPDOWN_ERR_MSG, WM_SETTEXT, 0, (LPARAM)GetErrMsg());\r
+\r
+                       if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
+                               EnableWindow(GetDlgItem(hDlg, DOWN_EXIST_RESUME), FALSE);\r
+\r
+                       SetRadioButtonByValue(hDlg, TransferErrorMode, DownExistButton, DOWNEXISTBUTTONS);\r
                        return(TRUE);\r
 \r
                case WM_COMMAND :\r
                        switch(GET_WM_COMMAND_ID(wParam, lParam))\r
                        {\r
+                               case IDOK_ALL :\r
+                                       TransferErrorNotify = NO;\r
+                                       /* ここに break はない */\r
+\r
                                case IDOK :\r
+                                       TransferErrorMode = AskRadioButtonValue(hDlg, DownExistButton, DOWNEXISTBUTTONS);\r
                                        EndDialog(hDlg, YES);\r
                                        break;\r
 \r
                                case IDCANCEL :\r
                                        EndDialog(hDlg, NO);\r
                                        break;\r
+\r
+                               case IDHELP :\r
+//                                     hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000009);\r
+                                       break;\r
                        }\r
-                       return(TRUE);\r
+            return(TRUE);\r
        }\r
-    return(FALSE);\r
+       return(FALSE);\r
 }\r
 \r
 \r
@@ -2402,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
@@ -2466,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
@@ -2533,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
@@ -2549,13 +2668,13 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
                                // IPv6対応\r
 //                             iLength=sizeof(saSockAddr1);\r
 //                             data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddr1, (int *)&iLength);\r
-                               switch(AskInetFamily())\r
+                               switch(AskCurNetType())\r
                                {\r
-                               case AF_INET:\r
+                               case NTYPE_IPV4:\r
                                        iLength=sizeof(saSockAddrIPv4);\r
                                        data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv4, (int *)&iLength);\r
                                        break;\r
-                               case AF_INET6:\r
+                               case NTYPE_IPV6:\r
                                        iLength=sizeof(saSockAddrIPv6);\r
                                        data_socket = do_accept(listen_socket,(struct sockaddr *)&saSockAddrIPv6, (int *)&iLength);\r
                                        break;\r
@@ -2575,12 +2694,12 @@ static int UpLoadNonPassive(TRANSPACKET *Pkt)
                                        // IPv6対応\r
 //                                     DoPrintf("Skt=%u : accept from %s port %u", data_socket, inet_ntoa(saSockAddr1.sin_addr), ntohs(saSockAddr1.sin_port));\r
                                {\r
-                                       switch(AskInetFamily())\r
+                                       switch(AskCurNetType())\r
                                        {\r
-                                       case AF_INET:\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 AF_INET6:\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
@@ -2650,12 +2769,12 @@ static int UpLoadPassive(TRANSPACKET *Pkt)
 //     iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled, "PASV");\r
        // IPv6対応\r
 //     iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "PASV");\r
-       switch(AskInetFamily())\r
+       switch(AskCurNetType())\r
        {\r
-       case AF_INET:\r
+       case NTYPE_IPV4:\r
                iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "PASV");\r
                break;\r
-       case AF_INET6:\r
+       case NTYPE_IPV6:\r
                iRetCode = command(Pkt->ctrl_skt, Buf, &Canceled[Pkt->ThreadCount], "EPSV");\r
                break;\r
        }\r
@@ -2676,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
@@ -3452,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
@@ -3559,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
@@ -3575,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
@@ -3586,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
@@ -3765,12 +3914,12 @@ static int GetAdrsAndPort(SOCKET Skt, char *Str, char *Adrs, int *Port, int Max)
 {\r
        int Result;\r
        Result = FFFTP_FAIL;\r
-       switch(AskInetFamily())\r
+       switch(AskCurNetType())\r
        {\r
-       case AF_INET:\r
+       case NTYPE_IPV4:\r
                Result = GetAdrsAndPortIPv4(Skt, Str, Adrs, Port, Max);\r
                break;\r
-       case AF_INET6:\r
+       case NTYPE_IPV6:\r
                Result = GetAdrsAndPortIPv6(Skt, Str, Adrs, Port, Max);\r
                break;\r
        }\r
@@ -3784,6 +3933,8 @@ static int GetAdrsAndPortIPv4(SOCKET Skt, char *Str, char *Adrs, int *Port, int
 {\r
        char *Pos;\r
        char *Btm;\r
+       // コンマではなくドットを返すホストがあるため\r
+       char *OldBtm;\r
        int Sts;\r
 \r
        Sts = FFFTP_FAIL;\r
@@ -3799,24 +3950,30 @@ static int GetAdrsAndPortIPv4(SOCKET Skt, char *Str, char *Adrs, int *Port, int
                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(Btm, '.');\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(Btm, '.');\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(Btm, '.');\r
+                                               Btm = strchr(OldBtm, '.');\r
                                        if(Btm != NULL)\r
                                        {\r
                                                if((Btm - Pos) <= Max)\r
@@ -3993,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