OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / getput.c
index 2ce0716..28c2471 100644 (file)
--- a/getput.c
+++ b/getput.c
@@ -697,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
@@ -756,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
@@ -780,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
@@ -797,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
@@ -1150,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
@@ -1310,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
@@ -1699,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
@@ -2265,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
@@ -2542,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
@@ -2609,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
@@ -2752,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