summaryrefslogtreecommitdiffstats
path: root/net/third_party/parseftp/ParseFTPList.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:03:39 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:03:39 +0000
commit8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca (patch)
tree90326da8fe65d9576a2e32cc39a8b224f313c2d4 /net/third_party/parseftp/ParseFTPList.h
parent7f113f39afed41b39d5c937039879c5d822c6b5e (diff)
downloadchromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.zip
chromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.tar.gz
chromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.tar.bz2
Get the latest ParseFTPList code from Mozilla, and apply only the absolutely
required changes. This way future merging would be much easier. TEST=none BUG=none Review URL: http://codereview.chromium.org/201034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party/parseftp/ParseFTPList.h')
-rw-r--r--net/third_party/parseftp/ParseFTPList.h239
1 files changed, 122 insertions, 117 deletions
diff --git a/net/third_party/parseftp/ParseFTPList.h b/net/third_party/parseftp/ParseFTPList.h
index 341e517..b11abdc 100644
--- a/net/third_party/parseftp/ParseFTPList.h
+++ b/net/third_party/parseftp/ParseFTPList.h
@@ -1,131 +1,136 @@
-// Version: MPL 1.1/GPL 2.0/LGPL 2.1
-//
-// The contents of this file are subject to the Mozilla Public License Version
-// 1.1 (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-// Software distributed under the License is distributed on an "AS IS" basis,
-// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-// for the specific language governing rights and limitations under the
-// License.
-//
-// The Original Code is mozilla.org Code.
-//
-// The Initial Developer of the Original Code is
-// Cyrus Patel <cyp@fb14.uni-mainz.de>.
-// Portions created by the Initial Developer are Copyright (C) 2002
-// the Initial Developer. All Rights Reserved.
-//
-// Contributor(s):
-// Doug Turner <dougt@netscape.com>
-//
-// Alternatively, the contents of this file may be used under the terms of
-// either the GNU General Public License Version 2 or later (the "GPL"), or
-// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-// in which case the provisions of the GPL or the LGPL are applicable instead
-// of those above. If you wish to allow use of your version of this file only
-// under the terms of either the GPL or the LGPL, and not to allow others to
-// use your version of this file under the terms of the MPL, indicate your
-// decision by deleting the provisions above and replace them with the notice
-// and other provisions required by the GPL or the LGPL. If you do not delete
-// the provisions above, a recipient may use your version of this file under
-// the terms of any one of the MPL, the GPL or the LGPL.
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Cyrus Patel <cyp@fb14.uni-mainz.de>.
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Doug Turner <dougt@netscape.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
-// Derived from:
-// mozilla/netwerk/streamconv/converters/ParseFTPList.h revision 1.3
+#ifndef NET_THIRD_PARTY_PARSEFTP_PARSEFTPLIST_H_
+#define NET_THIRD_PARTY_PARSEFTP_PARSEFTPLIST_H_
+#include "base/time.h"
-#ifndef NET_THIRD_PARTY_PARSEFTP_FTP_DIRECTORY_PARSER_H_
-#define NET_THIRD_PARTY_PARSEFTP_FTP_DIRECTORY_PARSER_H_
+/* ParseFTPList() parses lines from an FTP LIST command.
+**
+** Written July 2002 by Cyrus Patel <cyp@fb14.uni-mainz.de>
+** with acknowledgements to squid, lynx, wget and ftpmirror.
+**
+** Arguments:
+** 'line': line of FTP data connection output. The line is assumed
+** to end at the first '\0' or '\n' or '\r\n'.
+** 'state': a structure used internally to track state between
+** lines. Needs to be bzero()'d at LIST begin.
+** 'result': where ParseFTPList will store the results of the parse
+** if 'line' is not a comment and is not junk.
+**
+** Returns one of the following:
+** 'd' - LIST line is a directory entry ('result' is valid)
+** 'f' - LIST line is a file's entry ('result' is valid)
+** 'l' - LIST line is a symlink's entry ('result' is valid)
+** '?' - LIST line is junk. (cwd, non-file/dir/link, etc)
+** '"' - its not a LIST line (its a "comment")
+**
+** It may be advisable to let the end-user see "comments" (particularly when
+** the listing results in ONLY such lines) because such a listing may be:
+** - an unknown LIST format (NLST or "custom" format for example)
+** - an error msg (EPERM,ENOENT,ENFILE,EMFILE,ENOTDIR,ENOTBLK,EEXDEV etc).
+** - an empty directory and the 'comment' is a "total 0" line or similar.
+** (warning: a "total 0" can also mean the total size is unknown).
+**
+** ParseFTPList() supports all known FTP LISTing formats:
+** - '/bin/ls -l' and all variants (including Hellsoft FTP for NetWare);
+** - EPLF (Easily Parsable List Format);
+** - Windows NT's default "DOS-dirstyle";
+** - OS/2 basic server format LIST format;
+** - VMS (MultiNet, UCX, and CMU) LIST format (including multi-line format);
+** - IBM VM/CMS, VM/ESA LIST format (two known variants);
+** - SuperTCP FTP Server for Win16 LIST format;
+** - NetManage Chameleon (NEWT) for Win16 LIST format;
+** - '/bin/dls' (two known variants, plus multi-line) LIST format;
+** If there are others, then I'd like to hear about them (send me a sample).
+**
+** NLSTings are not supported explicitely because they cannot be machine
+** parsed consistently: NLSTings do not have unique characteristics - even
+** the assumption that there won't be whitespace on the line does not hold
+** because some nlistings have more than one filename per line and/or
+** may have filenames that have spaces in them. Moreover, distinguishing
+** between an error message and an NLST line would require ParseList() to
+** recognize all the possible strerror() messages in the world.
+*/
-#include "base/time.h"
-namespace net {
+/* #undef anything you don't want to support */
+#define SUPPORT_LSL /* /bin/ls -l and dozens of variations therof */
+#define SUPPORT_DLS /* /bin/dls format (very, Very, VERY rare) */
+#define SUPPORT_EPLF /* Extraordinarily Pathetic List Format */
+#define SUPPORT_DOS /* WinNT server in 'site dirstyle' dos */
+#define SUPPORT_VMS /* VMS (all: MultiNet, UCX, CMU-IP) */
+#define SUPPORT_CMS /* IBM VM/CMS,VM/ESA (z/VM and LISTING forms) */
+#define SUPPORT_OS2 /* IBM TCP/IP for OS/2 - FTP Server */
+#define SUPPORT_W16 /* win16 hosts: SuperTCP or NetManage Chameleon */
-struct ListState {
- void* magic; // to determine if previously
- // initialized.
- int now_tm_valid; // now_tm contains a valid time?
- base::Time::Exploded now_tm; // needed for year determination.
- int lstyle; // LISTing style.
- int parsed_one; // returned anything yet?
- char carry_buf[84]; // for VMS multiline.
- unsigned int carry_buf_len; // length of name in carry_buf.
- unsigned int numlines; // number of lines seen.
-};
+namespace net {
-enum LineType {
- FTP_TYPE_DIRECTORY, // LIST line is a directory entry ('result' is valid).
- FTP_TYPE_FILE, // LIST line is a file's entry ('result' is valid).
- FTP_TYPE_SYMLINK, // LIST line is a symlink's entry ('result' is valid).
- FTP_TYPE_JUNK, // LIST line is junk. (cwd, non-file/dir/link, etc).
- FTP_TYPE_COMMENT // Its not a LIST line (its a "comment").
+struct list_state
+{
+ void *magic; /* to determine if previously initialized */
+ bool now_tm_valid; /* true if now_tm is valid */
+ base::Time::Exploded now_tm; /* needed for year determination */
+ int lstyle; /* LISTing style */
+ int parsed_one; /* returned anything yet? */
+ char carry_buf[84]; /* for VMS multiline */
+ unsigned int carry_buf_len; /* length of name in carry_buf */
+ unsigned int numlines; /* number of lines seen */
};
-struct ListResult {
- LineType fe_type;
- const char* fe_fname; // pointer to filename
- unsigned int fe_fnlen; // length of filename
- const char* fe_lname; // pointer to symlink name
- unsigned int fe_lnlen; // length of symlink name
- char fe_size[40]; // size of file in bytes
- // (<= (2^128 - 1))
- base::Time::Exploded fe_time; // last-modified time
- int fe_cinfs; // file system is definitely
- // case insensitive
+struct list_result
+{
+ int fe_type; /* 'd'(dir) or 'l'(link) or 'f'(file) */
+ const char * fe_fname; /* pointer to filename */
+ unsigned int fe_fnlen; /* length of filename */
+ const char * fe_lname; /* pointer to symlink name */
+ unsigned int fe_lnlen; /* length of symlink name */
+ char fe_size[40]; /* size of file in bytes (<= (2^128 - 1)) */
+ base::Time::Exploded fe_time; /* last-modified time */
+ int fe_cinfs; /* file system is definitely case insensitive */
+ /* (converting all-upcase names may be desirable) */
};
-// ParseFTPLine() parses line from an FTP LIST command.
-//
-// Written July 2002 by Cyrus Patel <cyp@fb14.uni-mainz.de>
-// with acknowledgements to squid, lynx, wget and ftpmirror.
-//
-// Arguments:
-// 'line': line of FTP data connection output. The line is assumed
-// to end at the first '\0' or '\n' or '\r\n'.
-// 'state': a structure used internally to track state between
-// lines. Needs to be bzero()'d at LIST begin.
-// 'result': where ParseFTPList will store the results of the parse
-// if 'line' is not a comment and is not junk.
-//
-// Returns one of the following:
-// 'd' - LIST line is a directory entry ('result' is valid)
-// 'f' - LIST line is a file's entry ('result' is valid)
-// 'l' - LIST line is a symlink's entry ('result' is valid)
-// '?' - LIST line is junk. (cwd, non-file/dir/link, etc)
-// '"' - its not a LIST line (its a "comment")
-//
-// It may be advisable to let the end-user see "comments" (particularly when
-// the listing results in ONLY such lines) because such a listing may be:
-// - an unknown LIST format (NLST or "custom" format for example)
-// - an error msg (EPERM,ENOENT,ENFILE,EMFILE,ENOTDIR,ENOTBLK,EEXDEV etc).
-// - an empty directory and the 'comment' is a "total 0" line or similar.
-// (warning: a "total 0" can also mean the total size is unknown).
-//
-// ParseFTPList() supports all known FTP LISTing formats:
-// - '/bin/ls -l' and all variants (including Hellsoft FTP for NetWare);
-// - EPLF (Easily Parsable List Format);
-// - Windows NT's default "DOS-dirstyle";
-// - OS/2 basic server format LIST format;
-// - VMS (MultiNet, UCX, and CMU) LIST format (including multi-line format);
-// - IBM VM/CMS, VM/ESA LIST format (two known variants);
-// - SuperTCP FTP Server for Win16 LIST format;
-// - NetManage Chameleon (NEWT) for Win16 LIST format;
-// - '/bin/dls' (two known variants, plus multi-line) LIST format;
-// If there are others, then I'd like to hear about them (send me a sample).
-//
-// NLSTings are not supported explicitely because they cannot be machine
-// parsed consistently: NLSTings do not have unique characteristics - even
-// the assumption that there won't be whitespace on the line does not hold
-// because some nlistings have more than one filename per line and/or
-// may have filenames that have spaces in them. Moreover, distinguishing
-// between an error message and an NLST line would require ParseList() to
-// recognize all the possible strerror() messages in the world.
-
-LineType ParseFTPLine(const char *line,
- struct ListState *state,
- struct ListResult *result);
+int ParseFTPList(const char *line,
+ struct list_state *state,
+ struct list_result *result );
} // namespace net
-#endif // NET_THIRD_PARTY_PARSEFTP_FTP_DIRECTORY_PARSER_H_
+#endif // NET_THIRD_PARTY_PARSEFTP_PARSEFTPLIST_H_