FtpListResult.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // FileZilla - a Windows ftp client
  2. // Copyright (C) 2002-2004 - Tim Kosse <[email protected]>
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the GNU General Public License
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program; if not, write to the Free Software
  13. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. // FtpListResult.h: Schnittstelle für die Klasse CFtpListResult.
  15. //
  16. //////////////////////////////////////////////////////////////////////
  17. #if !defined(AFX_FTPLISTRESULT_H__A175CA67_9A91_4BC0_AAD3_238DE1A6D9AE__INCLUDED_)
  18. #define AFX_FTPLISTRESULT_H__A175CA67_9A91_4BC0_AAD3_238DE1A6D9AE__INCLUDED_
  19. #include "FzApiStructures.h" // Hinzugefügt von der Klassenansicht
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif // _MSC_VER > 1000
  23. /*This class parses the directory listing returned from the server. These formats are supported:
  24. -rw-r--r-- 1 root other 531 Jan 29 03:26 README\r\n
  25. dr-xr-xr-x 2 root other 512 Apr 8 1994 etc\r\n
  26. dr-xr-xr-x 2 root 512 Apr 8 1994 etc\r\n
  27. lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin\r\n
  28. ---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z\r\n
  29. d--------- 1 owner group 0 May 9 19:45 Softlib\r\n
  30. -rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp\r\n
  31. d [R----F--] supervisor 512 Jan 16 18:53 login\r\n
  32. - [R----F--] rhesus 214059 Oct 20 15:27 cx.exe\r\n
  33. -------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit\r\n
  34. drwxrwxr-x folder 2 May 10 1996 network\r\n
  35. 00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)\r\n
  36. CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)\r\n
  37. CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)\r\n
  38. 04-27-00 09:09PM <DIR> licensed\r\n
  39. 07-18-00 10:16AM <DIR> pub\r\n
  40. 04-14-00 03:47PM 589 readme.htm\r\n
  41. Multiple spaces are ignored (except within filenames), a single LF character at the end is also supported as well as multiple
  42. CRLF pairs and other variants.
  43. */
  44. #include "ApiLog.h"
  45. class CFtpListResult : public CApiLog
  46. {
  47. public:
  48. t_server m_server;
  49. void SendToMessageLog(HWND hWnd, UINT nMsg);
  50. void AddData(char *data,int size);
  51. CFtpListResult(t_server server, bool *bUTF8 = 0);
  52. virtual ~CFtpListResult();
  53. t_directory::t_direntry *getList(int &num, CTime EntryTime, bool mlst);
  54. private:
  55. typedef std::list<t_directory::t_direntry> tEntryList;
  56. tEntryList m_EntryList;
  57. BOOL parseLine(const char *lineToParse, const int linelen, t_directory::t_direntry &direntry, int &nFTPServerType, bool mlst);
  58. BOOL parseAsVMS(const char *line, const int linelen, t_directory::t_direntry &direntry);
  59. BOOL parseAsEPLF(const char *line, const int linelen, t_directory::t_direntry &direntry);
  60. BOOL parseAsMlsd(const char *line, const int linelen, t_directory::t_direntry &direntry, bool mlst);
  61. BOOL parseAsUnix(const char *line, const int linelen, t_directory::t_direntry &direntry);
  62. BOOL parseAsDos(const char *line, const int linelen, t_directory::t_direntry &direntry);
  63. BOOL parseAsOther(const char *line, const int linelen, t_directory::t_direntry &direntry);
  64. BOOL parseAsIBM(const char *line, const int linelen, t_directory::t_direntry &direntry);
  65. BOOL parseAsIBMMVS(const char *line, const int linelen, t_directory::t_direntry &direntry);
  66. BOOL parseAsIBMMVSPDS(const char *line, const int linelen, t_directory::t_direntry &direntry);
  67. BOOL parseAsIBMMVSPDS2(const char *line, const int linelen, t_directory::t_direntry &direntry);
  68. BOOL parseAsWfFtp(const char *line, const int linelen, t_directory::t_direntry &direntry);
  69. const char *GetNextToken(const char *line, const int linelen, int &len, int &pos, int type) const;
  70. bool ParseShortDate(const char *str, int len, t_directory::t_direntry::t_date &date) const;
  71. bool parseTime(const char *str, int len, t_directory::t_direntry::t_date &date) const;
  72. bool ParseSize(const char* str, int len, __int64 &size) const;
  73. bool parseMlsdDateTime(const CString value, t_directory::t_direntry::t_date &date) const;
  74. int pos;
  75. struct t_list
  76. {
  77. char *buffer;
  78. int len;
  79. t_list *next;
  80. } *listhead, *curpos, *m_curlistaddpos;
  81. typedef std::list<int> tTempData;
  82. tTempData m_TempData;
  83. //Month names map
  84. std::map<CString, int> m_MonthNamesMap;
  85. protected:
  86. bool *m_bUTF8;
  87. void copyStr(CString &target, int pos, const char *source, int len, bool mayInvalidateUTF8 = false);
  88. const char * strnchr(const char *str, int len, char c) const;
  89. const char * strnstr(const char *str, int len, const char *c) const;
  90. _int64 strntoi64(const char *str, int len) const;
  91. void AddLine(t_directory::t_direntry &direntry);
  92. char * GetLine();
  93. bool IsNumeric(const char *str, int len) const;
  94. char *m_prevline;
  95. char *m_curline;
  96. };
  97. #endif // !defined(AFX_FTPLISTRESULT_H__A175CA67_9A91_4BC0_AAD3_238DE1A6D9AE__INCLUDED_)