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

Side by Side Diff: net/ftp/ftp_directory_parser.h

Issue 42261: Add the directory listing code for the new portable... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Upload before checkin Created 11 years, 9 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/build/net.vcproj ('k') | net/ftp/ftp_directory_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 // The contents of this file are subject to the Mozilla Public License Version
7 // 1.1 (the "License"); you may not use this file except in compliance with
8 // the License. You may obtain a copy of the License at
9 // http://www.mozilla.org/MPL/
10 // Software distributed under the License is distributed on an "AS IS" basis,
11 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 // for the specific language governing rights and limitations under the
13 // License.
14 //
15 // The Original Code is mozilla.org Code.
16 //
17 // The Initial Developer of the Original Code is
18 // Cyrus Patel <cyp@fb14.uni-mainz.de>.
19 // Portions created by the Initial Developer are Copyright (C) 2002
20 // the Initial Developer. All Rights Reserved.
21 //
22 // Contributor(s):
23 // Doug Turner <dougt@netscape.com>
24 //
25 // Alternatively, the contents of this file may be used under the terms of
26 // either the GNU General Public License Version 2 or later (the "GPL"), or
27 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 // in which case the provisions of the GPL or the LGPL are applicable instead
29 // of those above. If you wish to allow use of your version of this file only
30 // under the terms of either the GPL or the LGPL, and not to allow others to
31 // use your version of this file under the terms of the MPL, indicate your
32 // decision by deleting the provisions above and replace them with the notice
33 // and other provisions required by the GPL or the LGPL. If you do not delete
34 // the provisions above, a recipient may use your version of this file under
35 // the terms of any one of the MPL, the GPL or the LGPL.
36
37 // Derived from:
38 // mozilla/netwerk/streamconv/converters/ParseFTPList.h revision 1.3
39
40
41 #ifndef NET_FTP_FTP_DIRECTORY_PARSER_H_
42 #define NET_FTP_FTP_DIRECTORY_PARSER_H_
43
44 #include <time.h>
45
46 #include "base/basictypes.h"
47
48 namespace net {
49
50 struct ListState {
51 int64 now_time; // needed for year determination.
52 struct tm now_tm; // needed for year determination.
53 int lstyle; // LISTing style.
54 int parsed_one; // returned anything yet?
55 char carry_buf[84]; // for VMS multiline.
56 unsigned int carry_buf_len; // length of name in carry_buf.
57 unsigned int numlines; // number of lines seen.
58 };
59
60 enum LineType {
61 FTP_TYPE_DIRECTORY, // LIST line is a directory entry ('result' is valid).
62 FTP_TYPE_FILE, // LIST line is a file's entry ('result' is valid).
63 FTP_TYPE_SYMLINK, // LIST line is a symlink's entry ('result' is valid).
64 FTP_TYPE_JUNK, // LIST line is junk. (cwd, non-file/dir/link, etc).
65 FTP_TYPE_COMMENT // Its not a LIST line (its a "comment").
66 };
67
68 struct ListResult {
69 LineType fe_type;
70 const char* fe_fname; // pointer to filename
71 unsigned int fe_fnlen; // length of filename
72 const char* fe_lname; // pointer to symlink name
73 unsigned int fe_lnlen; // length of symlink name
74 char fe_size[40]; // size of file in bytes (<= (2^128 - 1))
75 int fe_cinfs; // file system is definitely case insensitive
76 struct tm fe_time; // last-modified time
77 };
78
79 // ParseFTPLine() parses line from an FTP LIST command.
80 //
81 // Written July 2002 by Cyrus Patel <cyp@fb14.uni-mainz.de>
82 // with acknowledgements to squid, lynx, wget and ftpmirror.
83 //
84 // Arguments:
85 // 'line': line of FTP data connection output. The line is assumed
86 // to end at the first '\0' or '\n' or '\r\n'.
87 // 'state': a structure used internally to track state between
88 // lines. Needs to be bzero()'d at LIST begin.
89 // 'result': where ParseFTPList will store the results of the parse
90 // if 'line' is not a comment and is not junk.
91 //
92 // Returns one of the following:
93 // 'd' - LIST line is a directory entry ('result' is valid)
94 // 'f' - LIST line is a file's entry ('result' is valid)
95 // 'l' - LIST line is a symlink's entry ('result' is valid)
96 // '?' - LIST line is junk. (cwd, non-file/dir/link, etc)
97 // '"' - its not a LIST line (its a "comment")
98 //
99 // It may be advisable to let the end-user see "comments" (particularly when
100 // the listing results in ONLY such lines) because such a listing may be:
101 // - an unknown LIST format (NLST or "custom" format for example)
102 // - an error msg (EPERM,ENOENT,ENFILE,EMFILE,ENOTDIR,ENOTBLK,EEXDEV etc).
103 // - an empty directory and the 'comment' is a "total 0" line or similar.
104 // (warning: a "total 0" can also mean the total size is unknown).
105 //
106 // ParseFTPList() supports all known FTP LISTing formats:
107 // - '/bin/ls -l' and all variants (including Hellsoft FTP for NetWare);
108 // - EPLF (Easily Parsable List Format);
109 // - Windows NT's default "DOS-dirstyle";
110 // - OS/2 basic server format LIST format;
111 // - VMS (MultiNet, UCX, and CMU) LIST format (including multi-line format);
112 // - IBM VM/CMS, VM/ESA LIST format (two known variants);
113 // - SuperTCP FTP Server for Win16 LIST format;
114 // - NetManage Chameleon (NEWT) for Win16 LIST format;
115 // - '/bin/dls' (two known variants, plus multi-line) LIST format;
116 // If there are others, then I'd like to hear about them (send me a sample).
117 //
118 // NLSTings are not supported explicitely because they cannot be machine
119 // parsed consistently: NLSTings do not have unique characteristics - even
120 // the assumption that there won't be whitespace on the line does not hold
121 // because some nlistings have more than one filename per line and/or
122 // may have filenames that have spaces in them. Moreover, distinguishing
123 // between an error message and an NLST line would require ParseList() to
124 // recognize all the possible strerror() messages in the world.
125
126 LineType ParseFTPLine(const char *line,
127 struct ListState *state,
128 struct ListResult *result);
129
130 } // namespace net
131
132 #endif // NET_FTP_FTP_DIRECTORY_PARSER_H_
OLDNEW
« no previous file with comments | « net/build/net.vcproj ('k') | net/ftp/ftp_directory_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698