OSDN Git Service

Modify documents.
[ffftp/ffftp.git] / filelist.c
index 737d3dc..74d14bb 100644 (file)
@@ -83,7 +83,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
 static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LONGLONG Size, int Attr, int Type, int Link, char *Owner, int InfoExist, int Win);\r
 static void EraseDispFileList(FLISTANCHOR *Anchor);\r
 static void DispFileList2View(HWND hWnd, FLISTANCHOR *Anchor);\r
-static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist);\r
+// ファイルアイコン表示対応\r
+//static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist);\r
+static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist, int ImageId);\r
 // 64ビット対応\r
 //static BOOL CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
 static INT_PTR CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
@@ -122,6 +124,8 @@ extern int RemoteWidth;
 extern int ListHeight;\r
 extern char FilterStr[FILTER_EXT_LEN+1];\r
 extern HWND hHelpWin;\r
+// 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+extern int SuppressRefresh;\r
 \r
 /* 設定値 */\r
 extern int LocalWidth;\r
@@ -145,6 +149,8 @@ static WNDPROC LocalProcPtr;
 static WNDPROC RemoteProcPtr;\r
 \r
 static HIMAGELIST ListImg = NULL;\r
+// ファイルアイコン表示対応\r
+static HIMAGELIST ListImgFileIcon = NULL;\r
 \r
 static char FindStr[40+1] = { "*" };           /* 検索文字列 */\r
 static int IgnoreNew = NO;\r
@@ -179,6 +185,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst)
        LV_COLUMN LvCol;\r
        long Tmp;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        /*===== ローカル側のリストビュー =====*/\r
 \r
        hWndListLocal = CreateWindowEx(/*WS_EX_STATICEDGE*/WS_EX_CLIENTEDGE,\r
@@ -444,9 +453,11 @@ static void doTransferRemoteFile(void)
        int CancelFlg = NO;\r
        char LocDir[FMAX_PATH+1];\r
        char TmpDir[FMAX_PATH+1];\r
-       char buf[32];\r
+       // 環境依存の不具合対策\r
+//     char buf[32];\r
        int i;\r
-       DWORD pid;\r
+       // 環境依存の不具合対策\r
+//     DWORD pid;\r
 \r
        // すでにリモートから転送済みなら何もしない。(2007.9.3 yutaka)\r
        if (remoteFileListBase != NULL)\r
@@ -470,7 +481,7 @@ static void doTransferRemoteFile(void)
        GetAppTempPath(TmpDir);\r
        _mkdir(TmpDir);\r
        SetYenTail(TmpDir);\r
-       strcat(TmpDir, "transfer");\r
+       strcat(TmpDir, "file");\r
        _mkdir(TmpDir);\r
 #if 0\r
        if (TmpDir[strlen(TmpDir) - 1] == '\\') {\r
@@ -489,6 +500,11 @@ static void doTransferRemoteFile(void)
                remove(fn);\r
        }\r
 \r
+       // 同時接続対応\r
+       DisableUserOpe();\r
+       // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+       SuppressRefresh = 1;\r
+\r
        // ダウンロード先をテンポラリに設定\r
        SetLocalDirHist(TmpDir);\r
 \r
@@ -520,6 +536,12 @@ static void doTransferRemoteFile(void)
        SetLocalDirHist(LocDir);\r
        SetCurrentDirAsDirHist();\r
 \r
+       // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+       SuppressRefresh = 0;\r
+       GetLocalDirForWnd();\r
+       // 同時接続対応\r
+       EnableUserOpe();\r
+\r
        remoteFileListBase = FileListBase;  // あとでフリーすること\r
        remoteFileListBaseNoExpand = FileListBaseNoExpand;  // あとでフリーすること\r
        strncpy_s(remoteFileDir, sizeof(remoteFileDir), TmpDir, _TRUNCATE);\r
@@ -782,6 +804,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                        return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
 \r
                case WM_DROPFILES :\r
+                       // 同時接続対応\r
+                       if(AskUserOpeDisabled() == YES)\r
+                               break;\r
                        // ドラッグ中は処理しない。ドラッグ後にWM_LBUTTONDOWNが飛んでくるため、そこで処理する。\r
                        if (Dragging == YES) \r
                                return (FALSE);\r
@@ -789,7 +814,7 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                        if(hWnd == hWndListRemote)\r
                        {\r
                                if(AskConnecting() == YES)\r
-                                       UpLoadDragProc(wParam);\r
+                                       UploadDragProc(wParam);\r
                        }\r
                        else if(hWnd == hWndListLocal)\r
                        {\r
@@ -814,6 +839,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                                hCsrDrg = LoadCursor(NULL, IDC_ARROW);\r
                                SetCursor(hCsrDrg);\r
 \r
+                               // 同時接続対応\r
+                               if(AskUserOpeDisabled() == YES)\r
+                                       break;\r
                                Point.x = (long)(short)LOWORD(lParam);\r
                                Point.y = (long)(short)HIWORD(lParam);\r
                                ClientToScreen(hWnd, &Point);\r
@@ -894,6 +922,11 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
  \r
                                        } \r
  \r
+#if defined(HAVE_TANDEM)\r
+                                       if(FileListBaseNoExpand == NULL)\r
+                                               pf = FileListBase;\r
+                                       else\r
+#endif\r
                                        pf = FileListBaseNoExpand;\r
                                        for (filenum = 0; pf ; filenum++) {\r
                                                pf = pf->Next;\r
@@ -1108,6 +1141,9 @@ void GetListTabWidth(void)
        LV_COLUMN LvCol;\r
        int i;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        for(i = 0; i <= 3; i++)\r
        {\r
                LvCol.mask = LVCF_WIDTH;\r
@@ -1316,6 +1352,64 @@ void GetRemoteDirForWnd(int Mode, int *CancelCheckWork)
 *              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
+// ファイルアイコン表示対応\r
+void RefreshIconImageList(FLISTANCHOR *Anchor)\r
+{\r
+       HBITMAP hBitmap;\r
+       int ImageId;\r
+       FILELIST *Pos;\r
+       int i;\r
+       char Cur[FMAX_PATH+1];\r
+       SHFILEINFO FileInfo;\r
+       if(AskDispFileIcon() == YES)\r
+       {\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+               ImageList_Destroy(ListImgFileIcon);\r
+               ListImgFileIcon = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 1);\r
+               hBitmap = LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(dirattr16_bmp));\r
+               ImageList_AddMasked(ListImgFileIcon, hBitmap, RGB(255, 0, 0));\r
+               DeleteObject(hBitmap);\r
+               ImageId = 0;\r
+               Pos = Anchor->Top;\r
+               for(i = 0; i < Anchor->Files; i++)\r
+               {\r
+                       Pos->ImageId = -1;\r
+                       if(Pos->Node == NODE_DRIVE)\r
+                               strcpy(Cur, Pos->File);\r
+                       else\r
+                       {\r
+                               AskLocalCurDir(Cur, FMAX_PATH);\r
+                               SetYenTail(Cur);\r
+                               strcat(Cur, Pos->File);\r
+                       }\r
+                       if(SHGetFileInfoM(Cur, 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_ICON) != 0)\r
+                       {\r
+                               if(ImageList_AddIcon(ListImgFileIcon, FileInfo.hIcon) >= 0)\r
+                               {\r
+                                       Pos->ImageId = ImageId;\r
+                                       ImageId++;\r
+                               }\r
+                               DestroyIcon(FileInfo.hIcon);\r
+                       }\r
+                       Pos = Pos->Next;\r
+               }\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+       }\r
+       else\r
+       {\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+       }\r
+}\r
+\r
 void GetLocalDirForWnd(void)\r
 {\r
        HANDLE fHnd;\r
@@ -1368,7 +1462,7 @@ void GetLocalDirForWnd(void)
        if(DispDrives)\r
        {\r
                GetLogicalDriveStrings(FMAX_PATH, Scan);\r
-               NoDrives = LoadHideDriveListRegistory();\r
+               NoDrives = LoadHideDriveListRegistry();\r
 \r
                Pos = Scan;\r
                while(*Pos != NUL)\r
@@ -1384,6 +1478,8 @@ void GetLocalDirForWnd(void)
                }\r
        }\r
 \r
+       // ファイルアイコン表示対応\r
+       RefreshIconImageList(&Anchor);\r
        DispFileList2View(GetLocalHwnd(), &Anchor);\r
        EraseDispFileList(&Anchor);\r
 \r
@@ -1448,15 +1544,36 @@ static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LON
 \r
                        if((Sort & SORT_GET_ORD) == SORT_ASCENT)\r
                        {\r
-                               if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
-                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
-                                       ((Cmp = Size - Pos->Size) < 0)) ||\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
-                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
-                               {\r
+                               // 読みにくいのでリファクタリング\r
+//                             if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
+//#if defined(HAVE_TANDEM)\r
+//                                ((AskHostType() == HTYPE_TANDEM) &&\r
+//                                 ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = Attr - Pos->Attr) < 0)) ||\r
+//#endif\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+//                                     ((Cmp = Size - Pos->Size) < 0)) ||\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+//                                     ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
+//                             {\r
+//                                     break;\r
+//                             }\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0))\r
+                                       break;\r
+#if defined(HAVE_TANDEM)\r
+                               if((AskHostType() == HTYPE_TANDEM) &&\r
+                                       ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = Attr - Pos->Attr) < 0))\r
+                                       break;\r
+#endif\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+                                       ((Cmp = Size - Pos->Size) < 0))\r
+                                       break;\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0))\r
                                        break;\r
-                               }\r
 \r
                                if(((Sort & SORT_MASK_ORD) == SORT_NAME) || (Cmp == 0))\r
                                {\r
@@ -1468,6 +1585,11 @@ static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LON
                        {\r
                                if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
                                        ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) > 0)) ||\r
+#if defined(HAVE_TANDEM)\r
+                                  ((AskHostType() == HTYPE_TANDEM) &&\r
+                                   ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = Attr - Pos->Attr) > 0)) ||\r
+#endif\r
                                   (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
                                        ((Cmp = Size - Pos->Size) > 0)) ||\r
                                   (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
@@ -1563,7 +1685,9 @@ static void DispFileList2View(HWND hWnd, FLISTANCHOR *Anchor)
        Pos = Anchor->Top;\r
        for(i = 0; i < Anchor->Files; i++)\r
        {\r
-               AddListView(hWnd, -1, Pos->File, Pos->Node, Pos->Size, &Pos->Time, Pos->Attr, Pos->Owner, Pos->Link, Pos->InfoExist);\r
+               // ファイルアイコン表示対応\r
+//             AddListView(hWnd, -1, Pos->File, Pos->Node, Pos->Size, &Pos->Time, Pos->Attr, Pos->Owner, Pos->Link, Pos->InfoExist);\r
+               AddListView(hWnd, -1, Pos->File, Pos->Node, Pos->Size, &Pos->Time, Pos->Attr, Pos->Owner, Pos->Link, Pos->InfoExist, Pos->ImageId);\r
                Pos = Pos->Next;\r
        }\r
 \r
@@ -1593,7 +1717,9 @@ static void DispFileList2View(HWND hWnd, FLISTANCHOR *Anchor)
 *              なし\r
 *----------------------------------------------------------------------------*/\r
 \r
-static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist)\r
+// ファイルアイコン表示対応\r
+//static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist)\r
+static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size, FILETIME *Time, int Attr, char *Owner, int Link, int InfoExist, int ImageId)\r
 {\r
        LV_ITEM LvItem;\r
        char Tmp[20];\r
@@ -1601,6 +1727,8 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        if(Pos == -1)\r
                Pos = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        /* アイコン/ファイル名 */\r
        LvItem.mask = LVIF_TEXT | LVIF_IMAGE;\r
        LvItem.iItem = Pos;\r
@@ -1612,6 +1740,9 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
                LvItem.iImage = Type;\r
        else\r
                LvItem.iImage = 4;\r
+       // ファイルアイコン表示対応\r
+       if(AskDispFileIcon() == YES && hWnd == GetLocalHwnd())\r
+               LvItem.iImage = ImageId + 5;\r
        LvItem.iItem = SendMessage(hWnd, LVM_INSERTITEM, 0, (LPARAM)&LvItem);\r
 \r
        /* 日付/時刻 */\r
@@ -1641,6 +1772,12 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 3;\r
+#if defined(HAVE_TANDEM)\r
+       if (AskHostType() == HTYPE_TANDEM) {\r
+               _itoa_s(Attr, Tmp, sizeof(Tmp), 10);\r
+               LvItem.pszText = Tmp;\r
+       } else\r
+#endif\r
        LvItem.pszText = GetFileExt(Name);\r
        LvItem.iItem = SendMessage(hWnd, LVM_SETITEM, 0, (LPARAM)&LvItem);\r
 \r
@@ -1648,7 +1785,11 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        {\r
                /* 属性 */\r
                strcpy(Tmp, "");\r
+#if defined(HAVE_TANDEM)\r
+               if((InfoExist & FINFO_ATTR) && (AskHostType() != HTYPE_TANDEM))\r
+#else\r
                if(InfoExist & FINFO_ATTR)\r
+#endif\r
                        AttrValue2String(Attr, Tmp);\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
@@ -1710,6 +1851,8 @@ void SelectFileInList(HWND hWnd, int Type)
        FILETIME Time2;\r
        int Find;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        WinDst = WIN_REMOTE;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -1890,6 +2033,8 @@ void FindFileInList(HWND hWnd, int Type)
        LV_ITEM LvItem;\r
        char *Title;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        Title = MSGJPN050;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -2171,6 +2316,8 @@ int FindNameNode(int Win, char *Name)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&FindInfo, 0, sizeof(LV_FINDINFO));\r
        FindInfo.flags = LVFI_STRING;\r
        FindInfo.psz = Name;\r
        return(SendMessage(hWnd, LVM_FINDITEM, -1, (LPARAM)&FindInfo));\r
@@ -2198,6 +2345,8 @@ void GetNodeName(int Win, int Pos, char *Buf, int Max)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 0;\r
@@ -2231,6 +2380,8 @@ int GetNodeTime(int Win, int Pos, FILETIME *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 1;\r
@@ -2265,6 +2416,8 @@ int GetNodeSize(int Win, int Pos, LONGLONG *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2273,6 +2426,13 @@ int GetNodeSize(int Win, int Pos, LONGLONG *Buf)
        SendMessage(hWnd, LVM_GETITEM, 0, (LPARAM)&LvItem);\r
        *Buf = -1;\r
        Ret = NO;\r
+#if defined(HAVE_TANDEM)\r
+       if(AskHostType() == HTYPE_TANDEM) {\r
+               RemoveComma(Tmp);\r
+               *Buf = _atoi64(Tmp);\r
+               Ret = YES;\r
+       } else\r
+#endif\r
        if(strlen(Tmp) > 0)\r
        {\r
                RemoveComma(Tmp);\r
@@ -2305,14 +2465,26 @@ int GetNodeAttr(int Win, int Pos, int *Buf)
        Ret = NO;\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
+#if defined(HAVE_TANDEM)\r
+               if(AskHostType() == HTYPE_TANDEM)\r
+                       LvItem.iSubItem = 3;\r
+               else\r
+#endif\r
                LvItem.iSubItem = 4;\r
                LvItem.pszText = Tmp;\r
                LvItem.cchTextMax = 20;\r
                SendMessage(GetRemoteHwnd(), LVM_GETITEM, 0, (LPARAM)&LvItem);\r
                if(strlen(Tmp) > 0)\r
                {\r
+#if defined(HAVE_TANDEM)\r
+                       if(AskHostType() == HTYPE_TANDEM)\r
+                               *Buf = atoi(Tmp);\r
+                       else\r
+#endif\r
                        *Buf = AttrString2Value(Tmp);\r
                        Ret = YES;\r
                }\r
@@ -2342,6 +2514,8 @@ int GetNodeType(int Win, int Pos)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2379,6 +2553,8 @@ void GetNodeOwner(int Win, int Pos, char *Buf, int Max)
        strcpy(Buf, "");\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
                LvItem.iSubItem = 5;\r
@@ -2478,6 +2654,9 @@ void MakeSelectedFileList(int Win, int Expand, int All, FILELIST **Base, int *Ca
                        if((Node == NODE_FILE) ||\r
                           ((Expand == NO) && (Node == NODE_DIR)))\r
                        {\r
+                               // 変数が未初期化のバグ修正\r
+                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                Pkt.InfoExist = 0;\r
                                GetNodeName(Win, Pos, Pkt.File, FMAX_PATH);\r
                                if(GetNodeSize(Win, Pos, &Pkt.Size) == YES)\r
@@ -2514,6 +2693,9 @@ void MakeSelectedFileList(int Win, int Expand, int All, FILELIST **Base, int *Ca
                        {\r
                                if(GetNodeType(Win, Pos) == NODE_DIR)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        GetNodeName(Win, Pos, Name, FMAX_PATH);\r
                                        strcpy(Pkt.File, Name);\r
                                        ReplaceAll(Pkt.File, '\\', '/');\r
@@ -2611,14 +2793,26 @@ void MakeDroppedFileList(WPARAM wParam, char *Cur, FILELIST **Base)
 \r
                if((GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY) == 0)\r
                {\r
+                       // 変数が未初期化のバグ修正\r
+                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                        Pkt.Node = NODE_FILE;\r
                        strcpy(Pkt.File, GetFileName(Name));\r
 \r
                        memset(&Pkt.Time, 0, sizeof(FILETIME));\r
+#if defined(HAVE_TANDEM)\r
+                       /* Guardian スペースへのアップロードのためにサイズが必要 */\r
+                       Pkt.Size = 0;\r
+                       Pkt.InfoExist = 0;\r
+#endif\r
                        if((fHnd = FindFirstFile(Name, &Find)) != INVALID_HANDLE_VALUE)\r
                        {\r
                                FindClose(fHnd);\r
                                Pkt.Time = Find.ftLastWriteTime;\r
+#if defined(HAVE_TANDEM)\r
+                               Pkt.Size = MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow);\r
+                               Pkt.InfoExist |= (FINFO_TIME | FINFO_DATE | FINFO_SIZE);\r
+#endif\r
                        }\r
                        AddFileList(&Pkt, Base);\r
                }\r
@@ -2632,6 +2826,9 @@ void MakeDroppedFileList(WPARAM wParam, char *Cur, FILELIST **Base)
 \r
                if(GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY)\r
                {\r
+                       // 変数が未初期化のバグ修正\r
+                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                        Pkt.Node = NODE_DIR;\r
                        strcpy(Pkt.File, GetFileName(Name));\r
                        AddFileList(&Pkt, Base);\r
@@ -2751,6 +2948,9 @@ static void MakeRemoteTree2(char *Path, char *Cur, FILELIST **Base, int *CancelC
                        {\r
                                if(Pos->Node == NODE_DIR)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        /* まずディレクトリ名をセット */\r
                                        strcpy(Pkt.File, Pos->File);\r
                                        Pkt.Node = NODE_DIR;\r
@@ -2841,6 +3041,9 @@ void AddRemoteTreeToFileList(int Num, char *Path, int IncDir, FILELIST **Base)
                                {\r
                                        if(IncDir == RDIR_NLST)\r
                                        {\r
+                                               // 変数が未初期化のバグ修正\r
+                                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                                strcpy(Pkt.File, Dir);\r
                                                Pkt.Node = NODE_DIR;\r
                                                Pkt.Size = 0;\r
@@ -2859,6 +3062,9 @@ void AddRemoteTreeToFileList(int Num, char *Path, int IncDir, FILELIST **Base)
                                        if((Node == NODE_FILE) ||\r
                                           ((IncDir == RDIR_CWD) && (Node == NODE_DIR)))\r
                                        {\r
+                                               // 変数が未初期化のバグ修正\r
+                                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                                strcpy(Pkt.File, Dir);\r
                                                if(strlen(Pkt.File) > 0)\r
                                                        SetSlashTail(Pkt.File);\r
@@ -3026,6 +3232,9 @@ static void MakeLocalTree(char *Path, FILELIST **Base)
                        {\r
                                if(AskFilterStr(FindBuf.cFileName, NODE_FILE) == YES)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        strcpy(Pkt.File, Path);\r
                                        SetSlashTail(Pkt.File);\r
                                        strcat(Pkt.File, FindBuf.cFileName);\r
@@ -3054,6 +3263,9 @@ static void MakeLocalTree(char *Path, FILELIST **Base)
                           (strcmp(FindBuf.cFileName, ".") != 0) &&\r
                           (strcmp(FindBuf.cFileName, "..") != 0))\r
                        {\r
+                               // 変数が未初期化のバグ修正\r
+                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                strcpy(Src, Path);\r
                                SetYenTail(Src);\r
                                strcat(Src, FindBuf.cFileName);\r
@@ -3331,6 +3543,21 @@ static int AnalizeFileInfo(char *Str)
                                        }\r
                                }\r
 \r
+                               // linux-ftpd\r
+                               if((Ret == LIST_UNKNOWN) &&\r
+                                  (FindField(Str, Tmp, 7+Add1, NO) == FFFTP_SUCCESS))\r
+                               {\r
+                                       if((FindField(Str, Tmp, 5, NO) == FFFTP_SUCCESS) &&\r
+                                          (CheckYYYYMMDDformat(Tmp, NUL) != 0))\r
+                                       {\r
+                                               if((FindField(Str, Tmp, 6, NO) == FFFTP_SUCCESS) &&\r
+                                                  (CheckHHMMformat(Tmp) == YES))\r
+                                               {\r
+                                                       Ret = LIST_UNIX_16;\r
+                                               }\r
+                                       }\r
+                               }\r
+\r
                                if((Ret != LIST_UNKNOWN) && (Flag1 == YES))\r
                                        Ret |= LIST_MELCOM;\r
                        }\r
@@ -3634,6 +3861,20 @@ static int AnalizeFileInfo(char *Str)
                                }\r
                        }\r
                }\r
+#if defined(HAVE_TANDEM)\r
+               /* 以下のフォーマットをチェック */\r
+               /* LIST_TANDEM */\r
+\r
+               /* OSS の場合は自動判別可能のため Ret == LIST_UNKNOWN のチェックは後 */\r
+               if(AskRealHostType() == HTYPE_TANDEM) {\r
+                       if(Ret == LIST_UNKNOWN) {\r
+                               SetOSS(NO);\r
+                               Ret = LIST_TANDEM;\r
+                       } else {\r
+                               SetOSS(YES);\r
+                       }\r
+               }\r
+#endif\r
 \r
                // MLSD対応\r
                if(Ret == LIST_UNKNOWN)\r
@@ -3965,6 +4206,8 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
 \r
        /* まずクリアしておく */\r
        Ret = NODE_NONE;\r
+       // バグ対策\r
+       memset(Fname, NUL, FMAX_PATH+1);\r
        *Size = -1;\r
        *Attr = 0;\r
        *Link = NO;\r
@@ -4640,6 +4883,142 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                        }\r
                        break;\r
 \r
+#if defined(HAVE_TANDEM)\r
+               case LIST_TANDEM :\r
+                       *InfoExist |= (FINFO_TIME | FINFO_DATE | FINFO_SIZE | FINFO_ATTR);\r
+                       /* Open 中だったらずらす */\r
+                       if(FindField(Str, Buf, 1, NO) != FFFTP_SUCCESS)\r
+                               break;\r
+                       if (!strncmp(Buf, "O", 1)) {\r
+                               offs = 1;\r
+                       }\r
+                       /* 日付 */\r
+                       if(FindField(Str, Buf, 3 + offs, NO) != FFFTP_SUCCESS)\r
+                               break;\r
+                       if (Buf[1] == '-') {  /* 日付が 1桁 */\r
+                               sTime.wYear = Assume1900or2000(atoi(Buf + 6));\r
+                               Buf[5] = 0;\r
+                               GetMonth(Buf+2, &sTime.wMonth, &sTime.wDay);    /* wDayは常に0 */\r
+                               sTime.wDay = atoi(Buf);\r
+                               sTime.wDayOfWeek = 0;\r
+                       } else {\r
+                               sTime.wYear = Assume1900or2000(atoi(Buf + 7));\r
+                               Buf[6] = 0;\r
+                               GetMonth(Buf+3, &sTime.wMonth, &sTime.wDay);    /* wDayは常に0 */\r
+                               sTime.wDay = atoi(Buf);\r
+                               sTime.wDayOfWeek = 0;\r
+                       }\r
+                       /* 時刻 */\r
+                       FindField(Str, Buf, 4 + offs, NO);\r
+                       sTime.wHour = atoi(Buf);\r
+                       sTime.wMinute = atoi(Buf+3);\r
+                       sTime.wSecond = atoi(Buf+6);\r
+                       sTime.wMilliseconds = 0;\r
+                       SystemTimeToFileTime(&sTime, Time);\r
+                       SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
+\r
+                       /* 属性 セキュリティではなく FileCode を保存する */\r
+                       FindField(Str, Buf, 1 + offs, NO);\r
+                       *Attr = atoi(Buf);\r
+                       /* サイズ */\r
+                       FindField(Str, Buf, 2 + offs, NO);\r
+                       *Size = _atoi64(Buf);\r
+                       /* オーナ名 */\r
+                       if(FindField(Str, Buf, 5 + offs, NO) == FFFTP_SUCCESS) {\r
+                               if(strncmp(Buf, "Owner", sizeof("Owner"))) {\r
+                                       memset(Owner, NUL, OWNER_NAME_LEN+1);\r
+                                       strncpy(Owner, Buf, OWNER_NAME_LEN);\r
+                                       /* 通常は 255,255 だが、20, 33 などにも対応する */\r
+                                       /* 最後の文字が , だったら後ろとつなげる */\r
+                                       if (Buf[strlen(Buf)-1] == ',') {\r
+                                               FindField(Str, Buf, 6 + offs, NO);\r
+                                               strncat(Owner, Buf, OWNER_NAME_LEN - strlen(Buf));\r
+                                       }\r
+                                       /* ファイル名 */\r
+                                       if(FindField(Str, Fname, 0, NO) == FFFTP_SUCCESS) {\r
+                                               Ret = NODE_FILE;\r
+                                       }\r
+                               }\r
+                       }\r
+                       break;\r
+#endif\r
+\r
+                       // MLSD対応\r
+                       // 以下の形式に対応\r
+                       // fact1=value1;fact2=value2;fact3=value3; filename\r\n\r
+                       // 不完全な実装のホストが存在するため以下の形式も許容\r
+                       // fact1=value1;fact2=value2;fact3=value3 filename\r\n\r
+                       // fact1=value1;fact2=value2;fact3=value3;filename\r\n\r
+               case LIST_MLSD:\r
+                       {\r
+                               int i = 0;\r
+                               char StrBuf[(FMAX_PATH * 2) + 1];\r
+                               char Fact[FMAX_PATH + 1];\r
+                               char Name[FMAX_PATH + 1];\r
+                               char Value[FMAX_PATH + 1];\r
+                               char* pFileName;\r
+                               strncpy(StrBuf, Str, FMAX_PATH * 2);\r
+                               StrBuf[FMAX_PATH * 2] = '\0';\r
+                               if((pFileName = strstr(StrBuf, "; ")) != NULL)\r
+                               {\r
+                                       *pFileName = '\0';\r
+                                       pFileName += 2;\r
+                               }\r
+                               else if((pFileName = strchr(StrBuf, ' ')) != NULL)\r
+                               {\r
+                                       *pFileName = '\0';\r
+                                       pFileName++;\r
+                               }\r
+                               else if((pFileName = strrchr(StrBuf, ';')) != NULL)\r
+                               {\r
+                                       *pFileName = '\0';\r
+                                       pFileName++;\r
+                               }\r
+                               if(pFileName != NULL)\r
+                                       strcpy(Fname, pFileName);\r
+                               while(FindField2(StrBuf, Fact, ';', i, NO) == FFFTP_SUCCESS)\r
+                               {\r
+                                       if(FindField2(Fact, Name, '=', 0, NO) == FFFTP_SUCCESS && FindField2(Fact, Value, '=', 1, NO) == FFFTP_SUCCESS)\r
+                                       {\r
+                                               if(_stricmp(Name, "type") == 0)\r
+                                               {\r
+                                                       if(_stricmp(Value, "dir") == 0)\r
+                                                               Ret = NODE_DIR;\r
+                                                       else if(_stricmp(Value, "file") == 0)\r
+                                                               Ret = NODE_FILE;\r
+                                               }\r
+                                               else if(_stricmp(Name, "size") == 0)\r
+                                               {\r
+                                                       *Size = _atoi64(Value);\r
+                                                       *InfoExist |= FINFO_SIZE;\r
+                                               }\r
+                                               else if(_stricmp(Name, "modify") == 0)\r
+                                               {\r
+                                                       sTime.wYear = atoi_n(Value, 4);\r
+                                                       sTime.wMonth = atoi_n(Value + 4, 2);\r
+                                                       sTime.wDay = atoi_n(Value + 6, 2);\r
+                                                       sTime.wHour = atoi_n(Value + 8, 2);\r
+                                                       sTime.wMinute = atoi_n(Value + 10, 2);\r
+                                                       sTime.wSecond = atoi_n(Value + 12, 2);\r
+                                                       sTime.wMilliseconds = 0;\r
+                                                       SystemTimeToFileTime(&sTime, Time);\r
+                                                       // 時刻はGMT\r
+//                                                     SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
+                                                       *InfoExist |= FINFO_DATE | FINFO_TIME;\r
+                                               }\r
+                                               else if(_stricmp(Name, "UNIX.mode") == 0)\r
+                                               {\r
+                                                       *Attr = strtol(Value, NULL, 16);\r
+                                                       *InfoExist |= FINFO_ATTR;\r
+                                               }\r
+                                               else if(_stricmp(Name, "UNIX.owner") == 0)\r
+                                                       strcpy(Owner, Value);\r
+                                       }\r
+                                       i++;\r
+                               }\r
+                       }\r
+                       break;\r
+\r
                case LIST_UNIX_10 :\r
                case LIST_UNIX_11 :\r
                case LIST_UNIX_12 :\r
@@ -4669,6 +5048,8 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                case LIST_UNIX_75 :\r
 // MELCOMはビットフラグになっている\r
 //             case LIST_MELCOM :\r
+               // linux-ftpd\r
+               case LIST_UNIX_16 :\r
                default:\r
                        /* offsはサイズの位置, offs=0はカラム4 */\r
                        offs = 0;\r
@@ -4703,6 +5084,16 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
 \r
                        /* offs2は時間(もしくは年)の位置 */\r
                        offs2 = 0;\r
+                       // linux-ftpd\r
+//                     if((ListType == LIST_UNIX_11) ||\r
+//                        (ListType == LIST_UNIX_13) ||\r
+//                        (ListType == LIST_UNIX_21) ||\r
+//                        (ListType == LIST_UNIX_23) ||\r
+//                        (ListType == LIST_UNIX_51) ||\r
+//                        (ListType == LIST_UNIX_61) ||\r
+//                        (ListType == LIST_UNIX_63) ||\r
+//                        (ListType == LIST_UNIX_71) ||\r
+//                        (ListType == LIST_UNIX_73))\r
                        if((ListType == LIST_UNIX_11) ||\r
                           (ListType == LIST_UNIX_13) ||\r
                           (ListType == LIST_UNIX_21) ||\r
@@ -4711,7 +5102,8 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                           (ListType == LIST_UNIX_61) ||\r
                           (ListType == LIST_UNIX_63) ||\r
                           (ListType == LIST_UNIX_71) ||\r
-                          (ListType == LIST_UNIX_73))\r
+                          (ListType == LIST_UNIX_73) ||\r
+                          (ListType == LIST_UNIX_16))\r
                                offs2 = -1;\r
 \r
                        /* offs3はオーナ名の位置 */\r
@@ -4789,6 +5181,16 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                                        if(GetHourAndMinute(Buf, &sTime.wHour, &sTime.wMinute) == FFFTP_SUCCESS)\r
                                                *InfoExist |= FINFO_TIME;\r
                                }\r
+                               // linux-ftpd\r
+                               else if(CheckYYYYMMDDformat(Buf, NUL) != 0)\r
+                               {\r
+                                       sTime.wYear = atoi(Buf);\r
+                                       sTime.wMonth = atoi(Buf+5);\r
+                                       sTime.wDay = atoi(Buf+8);\r
+                                       FindField(Str, Buf, 7+offs+offs2, NO);\r
+                                       if(GetHourAndMinute(Buf, &sTime.wHour, &sTime.wMinute) == FFFTP_SUCCESS)\r
+                                               *InfoExist |= FINFO_TIME;\r
+                               }\r
                                else\r
                                {\r
                                        GetMonth(Buf, &sTime.wMonth, &sTime.wDay);\r
@@ -4882,57 +5284,6 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                                        Ret = NODE_NONE;\r
                        }\r
                        break;\r
-\r
-                       // MLSD対応\r
-               case LIST_MLSD:\r
-                       {\r
-                               int i = 0;\r
-                               char Tmp[FMAX_PATH + 1];\r
-                               char Name[FMAX_PATH + 1];\r
-                               char Value[FMAX_PATH + 1];\r
-                               while(FindField2(Str, Tmp, ';', i, NO) == FFFTP_SUCCESS)\r
-                               {\r
-                                       if(i >= 1 && strncmp(Tmp, " ", 1) == 0)\r
-                                               strcpy(Fname, strstr(Str, "; ") + 2);\r
-                                       else if(FindField2(Tmp, Name, '=', 0, NO) == FFFTP_SUCCESS && FindField2(Tmp, Value, '=', 1, NO) == FFFTP_SUCCESS)\r
-                                       {\r
-                                               if(_stricmp(Name, "type") == 0)\r
-                                               {\r
-                                                       if(_stricmp(Value, "dir") == 0)\r
-                                                               Ret = NODE_DIR;\r
-                                                       else if(_stricmp(Value, "file") == 0)\r
-                                                               Ret = NODE_FILE;\r
-                                               }\r
-                                               else if(_stricmp(Name, "size") == 0)\r
-                                               {\r
-                                                       *Size = _atoi64(Value);\r
-                                                       *InfoExist |= FINFO_SIZE;\r
-                                               }\r
-                                               else if(_stricmp(Name, "modify") == 0)\r
-                                               {\r
-                                                       sTime.wYear = atoi_n(Value, 4);\r
-                                                       sTime.wMonth = atoi_n(Value + 4, 2);\r
-                                                       sTime.wDay = atoi_n(Value + 6, 2);\r
-                                                       sTime.wHour = atoi_n(Value + 8, 2);\r
-                                                       sTime.wMinute = atoi_n(Value + 10, 2);\r
-                                                       sTime.wSecond = atoi_n(Value + 12, 2);\r
-                                                       sTime.wMilliseconds = 0;\r
-                                                       SystemTimeToFileTime(&sTime, Time);\r
-//                                                     SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
-                                                       *InfoExist |= FINFO_DATE | FINFO_TIME;\r
-                                               }\r
-                                               else if(_stricmp(Name, "UNIX.mode") == 0)\r
-                                               {\r
-                                                       *Attr = strtol(Value, NULL, 16);\r
-                                                       *InfoExist |= FINFO_ATTR;\r
-                                               }\r
-                                               else if(_stricmp(Name, "UNIX.owner") == 0)\r
-                                                       strcpy(Owner, Value);\r
-                                       }\r
-                                       i++;\r
-                               }\r
-                       }\r
-                       break;\r
        }\r
 \r
        // UTF-8対応\r