OSDN Git Service

Add support for linux-ftpd (untested).
[ffftp/ffftp.git] / filelist.c
index 363446d..930f21d 100644 (file)
@@ -31,6 +31,8 @@
 //#define _WIN32_WINNT 0x400\r
 \r
 #define        STRICT\r
+// IPv6対応\r
+#include <winsock2.h>\r
 #include <windows.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -82,7 +84,9 @@ static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LON
 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
-static BOOL CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\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
 static void DispListList(FILELIST *Pos, char *Title);\r
 static void MakeRemoteTree1(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork);\r
 static void MakeRemoteTree2(char *Path, char *Cur, FILELIST **Base, int *CancelCheckWork);\r
@@ -106,7 +110,9 @@ static int GetHourAndMinute(char *Str, WORD *Hour, WORD *Minute);
 static int GetVMSdate(char *Str, WORD *Year, WORD *Month, WORD *Day);\r
 static int CheckSpecialDirName(char *Fname);\r
 static int AskFilterStr(char *Fname, int Type);\r
-static BOOL CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+// 64ビット対応\r
+//static BOOL CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
 static int atoi_n(const char *Str, int Len);\r
 \r
 /*===== 外部参照 =====*/\r
@@ -183,7 +189,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst)
 \r
        if(hWndListLocal != NULL)\r
        {\r
-               LocalProcPtr = (WNDPROC)SetWindowLong(hWndListLocal, GWL_WNDPROC, (LONG)LocalWndProc);\r
+               // 64ビット対応\r
+//             LocalProcPtr = (WNDPROC)SetWindowLong(hWndListLocal, GWL_WNDPROC, (LONG)LocalWndProc);\r
+               LocalProcPtr = (WNDPROC)SetWindowLongPtr(hWndListLocal, GWLP_WNDPROC, (LONG_PTR)LocalWndProc);\r
 \r
            Tmp = SendMessage(hWndListLocal, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r
            Tmp |= LVS_EX_FULLROWSELECT;\r
@@ -232,7 +240,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst)
 \r
        if(hWndListRemote != NULL)\r
        {\r
-               RemoteProcPtr = (WNDPROC)SetWindowLong(hWndListRemote, GWL_WNDPROC, (LONG)RemoteWndProc);\r
+               // 64ビット対応\r
+//             RemoteProcPtr = (WNDPROC)SetWindowLong(hWndListRemote, GWL_WNDPROC, (LONG)RemoteWndProc);\r
+               RemoteProcPtr = (WNDPROC)SetWindowLongPtr(hWndListRemote, GWLP_WNDPROC, (LONG_PTR)RemoteWndProc);\r
 \r
            Tmp = SendMessage(hWndListRemote, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r
            Tmp |= LVS_EX_FULLROWSELECT;\r
@@ -434,9 +444,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
@@ -452,10 +464,15 @@ static void doTransferRemoteFile(void)
 \r
        // アプリを多重起動してもコンフリクトしないように、テンポラリフォルダ名にプロセスID\r
        // を付加する。(2007.9.13 yutaka)\r
-       GetTempPath(sizeof(TmpDir), TmpDir);\r
-       pid = GetCurrentProcessId();\r
-       _snprintf_s(buf, sizeof(buf), _TRUNCATE, "ffftp%d", pid);\r
-       strncat_s(TmpDir, sizeof(TmpDir), buf, _TRUNCATE);\r
+       // 環境依存の不具合対策\r
+//     GetTempPath(sizeof(TmpDir), TmpDir);\r
+//     pid = GetCurrentProcessId();\r
+//     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "ffftp%d", pid);\r
+//     strncat_s(TmpDir, sizeof(TmpDir), buf, _TRUNCATE);\r
+       GetAppTempPath(TmpDir);\r
+       _mkdir(TmpDir);\r
+       SetYenTail(TmpDir);\r
+       strcat(TmpDir, "file");\r
        _mkdir(TmpDir);\r
 #if 0\r
        if (TmpDir[strlen(TmpDir) - 1] == '\\') {\r
@@ -1121,32 +1138,50 @@ void GetListTabWidth(void)
 \r
 void SetListViewType(void)\r
 {\r
-       long lStyle;\r
+       // 64ビット対応\r
+//     long lStyle;\r
+       LONG_PTR lStyle;\r
 \r
        switch(ListType)\r
        {\r
                case LVS_LIST :\r
-                       lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
+                       // 64ビット対応\r
+//                     lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
+                       lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE);\r
                        lStyle &= ~(LVS_REPORT | LVS_LIST);\r
                        lStyle |= LVS_LIST;\r
-                       SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
+                       // 64ビット対応\r
+//                     SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
+                       SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle);\r
 \r
-                       lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
+                       // 64ビット対応\r
+//                     lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
+                       lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE);\r
                        lStyle &= ~(LVS_REPORT | LVS_LIST);\r
                        lStyle |= LVS_LIST;\r
-                       SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
+                       // 64ビット対応\r
+//                     SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
+                       SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
                        break;\r
 \r
                default :\r
-                       lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
+                       // 64ビット対応\r
+//                     lStyle = GetWindowLong(GetLocalHwnd(), GWL_STYLE);\r
+                       lStyle = GetWindowLongPtr(GetLocalHwnd(), GWL_STYLE);\r
                        lStyle &= ~(LVS_REPORT | LVS_LIST);\r
                        lStyle |= LVS_REPORT;\r
-                       SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
+                       // 64ビット対応\r
+//                     SetWindowLong(GetLocalHwnd(), GWL_STYLE, lStyle);\r
+                       SetWindowLongPtr(GetLocalHwnd(), GWL_STYLE, lStyle);\r
 \r
-                       lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
+                       // 64ビット対応\r
+//                     lStyle = GetWindowLong(GetRemoteHwnd(), GWL_STYLE);\r
+                       lStyle = GetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE);\r
                        lStyle &= ~(LVS_REPORT | LVS_LIST);\r
                        lStyle |= LVS_REPORT;\r
-                       SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
+                       // 64ビット対応\r
+//                     SetWindowLong(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
+                       SetWindowLongPtr(GetRemoteHwnd(), GWL_STYLE, lStyle);\r
                        break;\r
        }\r
        return;\r
@@ -1796,7 +1831,9 @@ void SelectFileInList(HWND hWnd, int Type)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK SelectDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\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
 {\r
        switch (iMessage)\r
        {\r
@@ -3296,6 +3333,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
@@ -4634,6 +4686,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
@@ -4668,6 +4722,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
@@ -4676,7 +4740,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
@@ -4754,6 +4819,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
+                                       sTime.wHour = atoi_n(Buf, 2);\r
+                                       sTime.wMinute = atoi(Buf+2);\r
+                               }\r
                                else\r
                                {\r
                                        GetMonth(Buf, &sTime.wMonth, &sTime.wDay);\r
@@ -4881,6 +4956,7 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                                                        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
@@ -5412,7 +5488,9 @@ void SetFilter(int *CancelCheckWork)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK FilterWndProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
 {\r
        switch (iMessage)\r
        {\r