| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ | 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ | 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "net/ftp/ftp_directory_listing_parser.h" | 11 #include "net/ftp/ftp_directory_listing_parser.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 // Parser for VMS-style directory listing (including variants). | 15 // Parser for VMS-style directory listing (including variants). |
| 16 class FtpDirectoryListingParserVms : public FtpDirectoryListingParser { | 16 class FtpDirectoryListingParserVms : public FtpDirectoryListingParser { |
| 17 public: | 17 public: |
| 18 FtpDirectoryListingParserVms(); | 18 FtpDirectoryListingParserVms(); |
| 19 virtual ~FtpDirectoryListingParserVms(); | 19 virtual ~FtpDirectoryListingParserVms(); |
| 20 | 20 |
| 21 // FtpDirectoryListingParser methods: | 21 // FtpDirectoryListingParser methods: |
| 22 virtual FtpServerType GetServerType() const; | 22 virtual FtpServerType GetServerType() const; |
| 23 virtual bool ConsumeLine(const string16& line); | 23 virtual bool ConsumeLine(const string16& line); |
| 24 virtual bool OnEndOfInput(); | 24 virtual bool OnEndOfInput(); |
| 25 virtual bool EntryAvailable() const; | 25 virtual bool EntryAvailable() const; |
| 26 virtual FtpDirectoryListingEntry PopEntry(); | 26 virtual FtpDirectoryListingEntry PopEntry(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Consumes listing line which is expected to be a directory listing entry | |
| 30 // (and not a comment etc). Returns true on success. | |
| 31 bool ConsumeEntryLine(const string16& line); | |
| 32 | |
| 33 enum State { | 29 enum State { |
| 34 STATE_INITIAL, | 30 STATE_INITIAL, |
| 35 | 31 |
| 36 // Indicates that we have received the header, like this: | 32 // Indicates that we have received the header, like this: |
| 37 // Directory SYS$SYSDEVICE:[ANONYMOUS] | 33 // Directory SYS$SYSDEVICE:[ANONYMOUS] |
| 38 STATE_RECEIVED_HEADER, | 34 STATE_RECEIVED_HEADER, |
| 39 | 35 |
| 40 // Indicates that we have received the first listing entry, like this: | 36 // Indicates that we have received the first listing entry, like this: |
| 41 // MADGOAT.DIR;1 2 9-MAY-2001 22:23:44.85 | 37 // MADGOAT.DIR;1 2 9-MAY-2001 22:23:44.85 |
| 42 STATE_ENTRIES, | 38 STATE_ENTRIES, |
| 43 | 39 |
| 44 // Indicates that we have received the last listing entry. | 40 // Indicates that we have received the last listing entry. |
| 45 STATE_RECEIVED_LAST_ENTRY, | 41 STATE_RECEIVED_LAST_ENTRY, |
| 46 | 42 |
| 47 // Indicates that we have successfully received all parts of the listing. | 43 // Indicates that we have successfully received all parts of the listing. |
| 48 STATE_END, | 44 STATE_END, |
| 49 } state_; | 45 }; |
| 46 |
| 47 // Consumes listing line which is expected to be a directory listing entry |
| 48 // (and not a comment etc). Returns true on success. |
| 49 bool ConsumeEntryLine(const string16& line); |
| 50 |
| 51 State state_; |
| 50 | 52 |
| 51 // VMS can use two physical lines if the filename is long. The first line will | 53 // VMS can use two physical lines if the filename is long. The first line will |
| 52 // contain the filename, and the second line everything else. Store the | 54 // contain the filename, and the second line everything else. Store the |
| 53 // filename until we receive the next line. | 55 // filename until we receive the next line. |
| 54 string16 last_filename_; | 56 string16 last_filename_; |
| 55 bool last_is_directory_; | 57 bool last_is_directory_; |
| 56 | 58 |
| 57 std::queue<FtpDirectoryListingEntry> entries_; | 59 std::queue<FtpDirectoryListingEntry> entries_; |
| 58 | 60 |
| 59 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserVms); | 61 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserVms); |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 } // namespace net | 64 } // namespace net |
| 63 | 65 |
| 64 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ | 66 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ |
| OLD | NEW |