| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> |
| 10 | 10 |
| 11 #include "net/ftp/ftp_directory_listing_parser.h" | 11 #include "base/string16.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 // Parser for VMS-style directory listing (including variants). | 15 struct FtpDirectoryListingEntry; |
| 16 class FtpDirectoryListingParserVms : public FtpDirectoryListingParser { | |
| 17 public: | |
| 18 FtpDirectoryListingParserVms(); | |
| 19 virtual ~FtpDirectoryListingParserVms(); | |
| 20 | 16 |
| 21 // FtpDirectoryListingParser methods: | 17 // Parses VMS FTP directory listing. Returns true on success. |
| 22 virtual FtpServerType GetServerType() const; | 18 bool ParseFtpDirectoryListingVms( |
| 23 virtual bool ConsumeLine(const string16& line); | 19 const std::vector<string16>& lines, |
| 24 virtual bool OnEndOfInput(); | 20 std::vector<FtpDirectoryListingEntry>* entries); |
| 25 virtual bool EntryAvailable() const; | |
| 26 virtual FtpDirectoryListingEntry PopEntry(); | |
| 27 | |
| 28 private: | |
| 29 enum State { | |
| 30 STATE_INITIAL, | |
| 31 | |
| 32 // Indicates that we have received the header, like this: | |
| 33 // Directory SYS$SYSDEVICE:[ANONYMOUS] | |
| 34 STATE_RECEIVED_HEADER, | |
| 35 | |
| 36 // Indicates that we have received the first listing entry, like this: | |
| 37 // MADGOAT.DIR;1 2 9-MAY-2001 22:23:44.85 | |
| 38 STATE_ENTRIES, | |
| 39 | |
| 40 // Indicates that we have received the last listing entry. | |
| 41 STATE_RECEIVED_LAST_ENTRY, | |
| 42 | |
| 43 // Indicates that we have successfully received all parts of the listing. | |
| 44 STATE_END, | |
| 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_; | |
| 52 | |
| 53 // VMS can use two physical lines if the filename is long. The first line will | |
| 54 // contain the filename, and the second line everything else. Store the | |
| 55 // filename until we receive the next line. | |
| 56 string16 last_filename_; | |
| 57 bool last_is_directory_; | |
| 58 | |
| 59 std::queue<FtpDirectoryListingEntry> entries_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserVms); | |
| 62 }; | |
| 63 | 21 |
| 64 } // namespace net | 22 } // namespace net |
| 65 | 23 |
| 66 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ | 24 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_VMS_H_ |
| OLD | NEW |