Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: net/ftp/ftp_directory_listing_parser.cc

Issue 7590011: FTP: add directory listing parser for OS/2 format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/data/ftp/dir-listing-os2-1.expected ('k') | net/ftp/ftp_directory_listing_parser_os2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 #include "net/ftp/ftp_directory_listing_parser.h" 5 #include "net/ftp/ftp_directory_listing_parser.h"
6 6
7 #include "base/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/ftp/ftp_directory_listing_parser_ls.h" 13 #include "net/ftp/ftp_directory_listing_parser_ls.h"
14 #include "net/ftp/ftp_directory_listing_parser_netware.h" 14 #include "net/ftp/ftp_directory_listing_parser_netware.h"
15 #include "net/ftp/ftp_directory_listing_parser_os2.h"
15 #include "net/ftp/ftp_directory_listing_parser_vms.h" 16 #include "net/ftp/ftp_directory_listing_parser_vms.h"
16 #include "net/ftp/ftp_directory_listing_parser_windows.h" 17 #include "net/ftp/ftp_directory_listing_parser_windows.h"
17 #include "net/ftp/ftp_server_type_histograms.h" 18 #include "net/ftp/ftp_server_type_histograms.h"
18 19
19 namespace net { 20 namespace net {
20 21
21 namespace { 22 namespace {
22 23
23 // Fills in |raw_name| for all |entries| using |encoding|. Returns network 24 // Fills in |raw_name| for all |entries| using |encoding|. Returns network
24 // error code. 25 // error code.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return FillInRawName(encoding, entries); 66 return FillInRawName(encoding, entries);
66 } 67 }
67 68
68 entries->clear(); 69 entries->clear();
69 if (ParseFtpDirectoryListingNetware(lines, current_time, entries)) { 70 if (ParseFtpDirectoryListingNetware(lines, current_time, entries)) {
70 *server_type = SERVER_NETWARE; 71 *server_type = SERVER_NETWARE;
71 return FillInRawName(encoding, entries); 72 return FillInRawName(encoding, entries);
72 } 73 }
73 74
74 entries->clear(); 75 entries->clear();
76 if (ParseFtpDirectoryListingOS2(lines, entries)) {
77 *server_type = SERVER_OS2;
78 return FillInRawName(encoding, entries);
79 }
80
81 entries->clear();
75 return ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT; 82 return ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT;
76 } 83 }
77 84
78 // Detects encoding of |text| and parses it as an FTP directory listing. 85 // Detects encoding of |text| and parses it as an FTP directory listing.
79 // Fills in |entries| and |server_type| and returns network error code. 86 // Fills in |entries| and |server_type| and returns network error code.
80 int DecodeAndParse(const std::string& text, 87 int DecodeAndParse(const std::string& text,
81 const base::Time& current_time, 88 const base::Time& current_time,
82 std::vector<FtpDirectoryListingEntry>* entries, 89 std::vector<FtpDirectoryListingEntry>* entries,
83 FtpServerType* server_type) { 90 FtpServerType* server_type) {
84 std::vector<std::string> encodings; 91 std::vector<std::string> encodings;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int ParseFtpDirectoryListing(const std::string& text, 124 int ParseFtpDirectoryListing(const std::string& text,
118 const base::Time& current_time, 125 const base::Time& current_time,
119 std::vector<FtpDirectoryListingEntry>* entries) { 126 std::vector<FtpDirectoryListingEntry>* entries) {
120 FtpServerType server_type = SERVER_UNKNOWN; 127 FtpServerType server_type = SERVER_UNKNOWN;
121 int rv = DecodeAndParse(text, current_time, entries, &server_type); 128 int rv = DecodeAndParse(text, current_time, entries, &server_type);
122 UpdateFtpServerTypeHistograms(server_type); 129 UpdateFtpServerTypeHistograms(server_type);
123 return rv; 130 return rv;
124 } 131 }
125 132
126 } // namespace net 133 } // namespace net
OLDNEW
« no previous file with comments | « net/data/ftp/dir-listing-os2-1.expected ('k') | net/ftp/ftp_directory_listing_parser_os2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698