OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / ftpproc.c
index 3e76a49..8963604 100644 (file)
--- a/ftpproc.c
+++ b/ftpproc.c
@@ -75,6 +75,9 @@ static int AskUpLoadFileAttr(char *Fname);
 // 64ビット対応\r
 //static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
 static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+#if defined(HAVE_TANDEM)\r
+static INT_PTR CALLBACK UpDownAsWithExtDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+#endif\r
 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
 // 64ビット対応\r
@@ -109,6 +112,9 @@ extern int CancelFlg;
 /*===== ローカルなワーク =====*/\r
 \r
 static char TmpString[FMAX_PATH+80];           /* テンポラリ */\r
+#if defined(HAVE_TANDEM)\r
+static char TmpFileCode[5];            /* テンポラリ */\r
+#endif\r
 static int CurWin;                                             /* ウインドウ番号 */\r
 \r
 int UpExistMode = EXIST_OVW;           /* アップロードで同じ名前のファイルがある時の扱い方 EXIST_xxx */\r
@@ -217,6 +223,19 @@ void DownLoadProc(int ChName, int ForceFile, int All)
                                }\r
 \r
                                strcpy(Pkt.Cmd, "RETR ");\r
+#if defined(HAVE_TANDEM)\r
+                               if(AskHostType() == HTYPE_TANDEM) {\r
+                                       if(AskTransferType() != TYPE_X) {\r
+                                               Pkt.Type = AskTransferType();\r
+                                       } else {\r
+                                               Pkt.Attr = Pos->Attr;\r
+                                               if (Pkt.Attr == 101)\r
+                                                       Pkt.Type = TYPE_A;\r
+                                               else\r
+                                                       Pkt.Type = TYPE_I;\r
+                                       }\r
+                               } else\r
+#endif\r
                                Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
                                Pkt.Size = Pos->Size;\r
                                Pkt.Time = Pos->Time;\r
@@ -911,12 +930,29 @@ void UpLoadListProc(int ChName, int All)
                                        _mbslwr(Cat);\r
                                else if(FnameCnv == FNAME_UPPER)\r
                                        _mbsupr(Cat);\r
+#if defined(HAVE_TANDEM)\r
+                               Pkt.FileCode = 0;\r
+                               Pkt.PriExt = DEF_PRIEXT;\r
+                               Pkt.SecExt = DEF_SECEXT;\r
+                               Pkt.MaxExt = DEF_MAXEXT;\r
+#endif\r
                        }\r
                        else\r
                        {\r
                                // 名前を変更する\r
                                strcpy(TmpString, Pos->File);\r
                                CurWin = WIN_LOCAL;\r
+#if defined(HAVE_TANDEM)\r
+                               strcpy(TmpFileCode, "0"); /* ASCII モードの場合は無視される */\r
+                               if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
+                                       if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_with_ext_dlg), GetMainHwnd(), UpDownAsWithExtDialogCallBack) == YES) {\r
+                                               strcat(Pkt.RemoteFile, TmpString);\r
+                                               Pkt.FileCode = atoi(TmpFileCode);\r
+                                       } else {\r
+                                               break;\r
+                                       }\r
+                               } else\r
+#endif\r
                                if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
                                        strcat(Pkt.RemoteFile, TmpString);\r
                                else\r
@@ -985,6 +1021,11 @@ void UpLoadListProc(int ChName, int All)
                                // UTF-8対応\r
                                Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
                                Pkt.KanaCnv = AskHostKanaCnv();\r
+#if defined(HAVE_TANDEM)\r
+                               if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
+                                       CalcExtentSize(&Pkt, Pos->Size);\r
+                               }\r
+#endif\r
                                Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
                                if(Pkt.Mode == EXIST_ABORT)\r
                                        break;\r
@@ -1079,6 +1120,12 @@ void UpLoadDragProc(WPARAM wParam)
                        else if(FnameCnv == FNAME_UPPER)\r
                                _mbsupr(Cat);\r
                        ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
+#if defined(HAVE_TANDEM)\r
+                       Pkt.FileCode = 0;\r
+                       Pkt.PriExt = DEF_PRIEXT;\r
+                       Pkt.SecExt = DEF_SECEXT;\r
+                       Pkt.MaxExt = DEF_MAXEXT;\r
+#endif\r
 \r
                        if(AskHostType() == HTYPE_ACOS)\r
                        {\r
@@ -1140,6 +1187,12 @@ void UpLoadDragProc(WPARAM wParam)
                                // UTF-8対応\r
                                Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
                                Pkt.KanaCnv = AskHostKanaCnv();\r
+#if defined(HAVE_TANDEM)\r
+                               if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
+                                       int a = Pos->InfoExist && FINFO_SIZE;\r
+                                       CalcExtentSize(&Pkt, Pos->Size);\r
+                               }\r
+#endif\r
                                Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
                                if(Pkt.Mode == EXIST_ABORT)\r
                                        break;\r
@@ -1411,6 +1464,11 @@ void MirrorUploadProc(int Notify)
                                                // UTF-8対応\r
                                                Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
                                                Pkt.KanaCnv = AskHostKanaCnv();\r
+#if defined(HAVE_TANDEM)\r
+                                               if(AskHostType() == HTYPE_TANDEM && AskOSS() == NO) {\r
+                                                       CalcExtentSize(&Pkt, LocalPos->Size);\r
+                                               }\r
+#endif\r
                                                Pkt.Mode = EXIST_OVW;\r
                                                AddTmpTransFileList(&Pkt, &Base);\r
                                        }\r
@@ -1815,13 +1873,26 @@ static int AskUpLoadFileAttr(char *Fname)
 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList)\r
 {\r
        int Ret;\r
+#if defined(HAVE_TANDEM)\r
+       int Mode;\r
+#endif\r
        FILELIST *Exist;\r
 \r
        Ret = EXIST_OVW;\r
        Pkt->ExistSize = 0;\r
        if(SendMode != TRANS_OVW)\r
        {\r
+#if defined(HAVE_TANDEM)\r
+               /* HP NonStop Server は大文字小文字の区別なし(すべて大文字) */\r
+               if(AskHostType() == HTYPE_TANDEM)\r
+                       Mode = COMP_IGNORE;\r
+               else\r
+                       Mode = COMP_STRICT;\r
+\r
+               if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, Mode)) != NULL)\r
+#else\r
                if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, COMP_STRICT)) != NULL)\r
+#endif\r
                {\r
                        Pkt->ExistSize = Exist->Size;\r
 \r
@@ -1965,6 +2036,57 @@ static INT_PTR CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM
 }\r
 \r
 \r
+#if defined(HAVE_TANDEM)\r
+/*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
+*\r
+*      Parameter\r
+*              HWND hDlg : ウインドウハンドル\r
+*              UINT message : メッセージ番号\r
+*              WPARAM wParam : メッセージの WPARAM 引数\r
+*              LPARAM lParam : メッセージの LPARAM 引数\r
+*\r
+*      Return Value\r
+*              BOOL TRUE/FALSE\r
+*----------------------------------------------------------------------------*/\r
+\r
+static INT_PTR CALLBACK UpDownAsWithExtDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+{\r
+       switch (iMessage)\r
+       {\r
+               case WM_INITDIALOG :\r
+                       if(CurWin == WIN_LOCAL)\r
+                               SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
+                       else\r
+                               SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
+\r
+                       SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
+                       SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
+                       SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
+                       SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, EM_LIMITTEXT, 4, 0);\r
+                       SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_SETTEXT, 0, (LPARAM)TmpFileCode);\r
+\r
+                       return(TRUE);\r
+\r
+               case WM_COMMAND :\r
+                       switch(GET_WM_COMMAND_ID(wParam, lParam))\r
+                       {\r
+                               case IDOK :\r
+                                       SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
+                                       SendDlgItemMessage(hDlg, UPDOWNAS_FILECODE, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpFileCode);\r
+                                       EndDialog(hDlg, YES);\r
+                                       break;\r
+\r
+                               case UPDOWNAS_STOP :\r
+                                       EndDialog(hDlg, NO_ALL);\r
+                                       break;\r
+                       }\r
+            return(TRUE);\r
+       }\r
+       return(FALSE);\r
+}\r
+#endif\r
+\r
+\r
 /*----- ファイル一覧で指定されたファイルを削除する ----------------------------\r
 *\r
 *      Parameter\r