2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-09-09 23:33:16 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1999-09-09 23:33:16 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1999-09-09 23:33:16 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2002-03-27 08:43:49 +03:00
|
|
|
* Contributor(s): Bradley Baetz <bbaetz@student.usyd.edu.au>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
#include "nsFTPDirListingConv.h"
|
2000-06-03 13:46:12 +04:00
|
|
|
#include "nsMemory.h"
|
1999-09-09 23:33:16 +04:00
|
|
|
#include "plstr.h"
|
1999-09-10 18:36:56 +04:00
|
|
|
#include "prlog.h"
|
1999-09-09 23:33:16 +04:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIGenericFactory.h"
|
1999-11-23 18:13:29 +03:00
|
|
|
#include "nsXPIDLString.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1999-09-09 23:33:16 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-09-10 18:36:56 +04:00
|
|
|
#include "nsEscape.h"
|
1999-11-30 07:50:42 +03:00
|
|
|
#include "nsNetUtil.h"
|
1999-09-09 23:33:16 +04:00
|
|
|
#include "nsIStringStream.h"
|
|
|
|
#include "nsILocaleService.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsDateTimeFormatCID.h"
|
1999-11-23 18:13:29 +03:00
|
|
|
#include "nsIStreamListener.h"
|
1999-11-23 23:55:27 +03:00
|
|
|
#include "nsCRT.h"
|
2001-03-25 01:57:35 +03:00
|
|
|
#include "nsMimeTypes.h"
|
|
|
|
|
2002-01-08 05:56:20 +03:00
|
|
|
#define IS_LWS(c) (PL_strchr(" \t\r\n",c) != 0)
|
|
|
|
#define IS_FTYPE(c) (PL_strchr("-dlbcsp",c) != 0)
|
|
|
|
#define IS_RPERM(c) (PL_strchr("r-",c) != 0)
|
|
|
|
#define IS_WPERM(c) (PL_strchr("w-",c) != 0)
|
|
|
|
#define IS_SPERM(c) (PL_strchr("sSx-",c) != 0)
|
|
|
|
#define IS_TPERM(c) (PL_strchr("tTx-",c) != 0)
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
|
|
|
static NS_DEFINE_CID(kDateTimeCID, NS_DATETIMEFORMAT_CID);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#if defined(PR_LOGGING)
|
1999-09-10 18:36:56 +04:00
|
|
|
//
|
|
|
|
// Log module for FTP dir listing stream converter logging...
|
|
|
|
//
|
|
|
|
// To enable logging (see prlog.h for full details):
|
|
|
|
//
|
2000-10-29 02:17:53 +04:00
|
|
|
// set NSPR_LOG_MODULES=nsFTPDirListConv:5
|
1999-09-10 18:36:56 +04:00
|
|
|
// set NSPR_LOG_FILE=nspr.log
|
|
|
|
//
|
|
|
|
// this enables PR_LOG_DEBUG level information and places all output in
|
|
|
|
// the file nspr.log
|
|
|
|
//
|
2000-10-29 02:17:53 +04:00
|
|
|
PRLogModuleInfo* gFTPDirListConvLog = nsnull;
|
1999-09-10 18:36:56 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif /* PR_LOGGING */
|
1999-09-10 18:36:56 +04:00
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
// nsISupports implementation
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS3(nsFTPDirListingConv,
|
|
|
|
nsIStreamConverter,
|
|
|
|
nsIStreamListener,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsIRequestObserver);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2001-08-01 06:04:53 +04:00
|
|
|
// Common code of Convert and AsyncConvertData function
|
1999-11-23 18:13:29 +03:00
|
|
|
|
2001-08-01 06:04:53 +04:00
|
|
|
static FTP_Server_Type
|
|
|
|
DetermineServerType (nsCString &fromMIMEString, const PRUnichar *aFromType)
|
|
|
|
{
|
|
|
|
fromMIMEString.AssignWithConversion(aFromType);
|
2001-03-02 12:26:57 +03:00
|
|
|
const char *from = fromMIMEString.get();
|
1999-11-23 18:13:29 +03:00
|
|
|
NS_ASSERTION(from, "nsCString/PRUnichar acceptance failed.");
|
|
|
|
|
|
|
|
from = PL_strstr(from, "/ftp-dir-");
|
2001-08-01 06:04:53 +04:00
|
|
|
if (!from) return ERROR_TYPE;
|
1999-11-23 18:13:29 +03:00
|
|
|
from += 9;
|
|
|
|
fromMIMEString = from;
|
|
|
|
|
|
|
|
if (-1 != fromMIMEString.Find("unix")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return UNIX;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("nt")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return NT;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("dcts")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return DCTS;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("ncsa")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return NCSA;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("peter_lewis")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return PETER_LEWIS;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("machten")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return MACHTEN;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("cms")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return CMS;
|
1999-11-23 18:13:29 +03:00
|
|
|
} else if (-1 != fromMIMEString.Find("tcpc")) {
|
2001-08-01 06:04:53 +04:00
|
|
|
return TCPC;
|
2001-09-20 18:16:14 +04:00
|
|
|
} else if (-1 != fromMIMEString.Find("os2")) {
|
|
|
|
return OS_2;
|
1999-11-23 18:13:29 +03:00
|
|
|
}
|
|
|
|
|
2001-08-01 06:04:53 +04:00
|
|
|
return GENERIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIStreamConverter implementation
|
|
|
|
|
|
|
|
#define CONV_BUF_SIZE (4*1024)
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFTPDirListingConv::Convert(nsIInputStream *aFromStream,
|
|
|
|
const PRUnichar *aFromType,
|
|
|
|
const PRUnichar *aToType,
|
|
|
|
nsISupports *aCtxt, nsIInputStream **_retval) {
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// set our internal state to reflect the server type
|
|
|
|
nsCString fromMIMEString;
|
|
|
|
|
|
|
|
mServerType = DetermineServerType(fromMIMEString, aFromType);
|
|
|
|
if (mServerType == ERROR_TYPE) return NS_ERROR_FAILURE;
|
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
char buffer[CONV_BUF_SIZE];
|
|
|
|
int i = 0;
|
|
|
|
while (i < CONV_BUF_SIZE) {
|
|
|
|
buffer[i] = '\0';
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
CBufDescriptor desc(buffer, PR_TRUE, CONV_BUF_SIZE);
|
|
|
|
nsCAutoString aBuffer(desc);
|
2001-12-06 03:09:00 +03:00
|
|
|
nsCString convertedData;
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(aCtxt, "FTP dir conversion needs the context");
|
2001-12-06 03:09:00 +03:00
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
nsCOMPtr<nsIURI> uri(do_QueryInterface(aCtxt, &rv));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-12-06 03:09:00 +03:00
|
|
|
|
|
|
|
rv = GetHeaders(convertedData, uri);
|
1999-11-23 18:13:29 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// build up the body
|
|
|
|
while (1) {
|
|
|
|
PRUint32 amtRead = 0;
|
|
|
|
|
|
|
|
rv = aFromStream->Read(buffer+aBuffer.Length(),
|
|
|
|
CONV_BUF_SIZE-aBuffer.Length(), &amtRead);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (!amtRead) {
|
|
|
|
// EOF
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aBuffer = DigestBufferLines(buffer, convertedData);
|
|
|
|
}
|
|
|
|
// end body building
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#ifndef DEBUG_valeski
|
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() sending the following %d bytes...\n\n%s\n\n",
|
2001-03-02 12:26:57 +03:00
|
|
|
convertedData.Length(), convertedData.get()) );
|
2000-10-29 02:17:53 +04:00
|
|
|
#else
|
2001-09-29 12:28:41 +04:00
|
|
|
char *unescData = ToNewCString(convertedData);
|
1999-11-23 18:13:29 +03:00
|
|
|
nsUnescape(unescData);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("::OnData() sending the following %d bytes...\n\n%s\n\n", convertedData.Length(), unescData);
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(unescData);
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif // DEBUG_valeski
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
// send the converted data out.
|
2002-01-28 01:02:00 +03:00
|
|
|
return NS_NewCStringInputStream(_retval, convertedData);
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
// Stream converter service calls this to initialize the actual stream converter (us).
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnichar *aToType,
|
1999-10-26 13:16:24 +04:00
|
|
|
nsIStreamListener *aListener, nsISupports *aCtxt) {
|
1999-09-09 23:33:16 +04:00
|
|
|
NS_ASSERTION(aListener && aFromType && aToType, "null pointer passed into FTP dir listing converter");
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// hook up our final listener. this guy gets the various On*() calls we want to throw
|
|
|
|
// at him.
|
|
|
|
mFinalListener = aListener;
|
|
|
|
NS_ADDREF(mFinalListener);
|
|
|
|
|
|
|
|
// set our internal state to reflect the server type
|
2001-08-01 06:04:53 +04:00
|
|
|
nsCString fromMIMEString;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2001-08-01 06:04:53 +04:00
|
|
|
mServerType = DetermineServerType(fromMIMEString, aFromType);
|
|
|
|
if (mServerType == ERROR_TYPE) return NS_ERROR_FAILURE;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
|
|
|
|
// we need our own channel that represents the content-type of the
|
|
|
|
// converted data.
|
|
|
|
NS_ASSERTION(aCtxt, "FTP dir listing needs a context (the uri)");
|
|
|
|
nsIURI *uri;
|
|
|
|
rv = aCtxt->QueryInterface(NS_GET_IID(nsIURI), (void**)&uri);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
rv = NS_NewInputStreamChannel(&mPartChannel,
|
|
|
|
uri,
|
|
|
|
nsnull,
|
2002-03-21 01:50:33 +03:00
|
|
|
NS_LITERAL_CSTRING(APPLICATION_HTTP_INDEX_FORMAT),
|
|
|
|
NS_LITERAL_CSTRING(""),
|
2000-03-29 07:58:50 +04:00
|
|
|
-1); // XXX fix contentLength
|
1999-09-09 23:33:16 +04:00
|
|
|
NS_RELEASE(uri);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG,
|
2001-03-02 12:26:57 +03:00
|
|
|
("nsFTPDirListingConv::AsyncConvertData() converting FROM raw %s, TO application/http-index-format\n", fromMIMEString.get()));
|
1999-09-10 18:36:56 +04:00
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsIStreamListener implementation
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
|
1999-09-09 23:33:16 +04:00
|
|
|
nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) {
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_ASSERTION(request, "FTP dir listing stream converter needs a request");
|
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
nsresult rv;
|
2001-02-21 23:38:08 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
PRUint32 read, streamLen;
|
|
|
|
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = inStr->Available(&streamLen);
|
1999-09-09 23:33:16 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char *buffer = (char*)nsMemory::Alloc(streamLen + 1);
|
1999-09-09 23:33:16 +04:00
|
|
|
rv = inStr->Read(buffer, streamLen, &read);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// the dir listings are ascii text, null terminate this sucker.
|
|
|
|
buffer[streamLen] = '\0';
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %d, count = %d)\n", request, ctxt, inStr, sourceOffset, count));
|
1999-09-10 18:36:56 +04:00
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
if (!mBuffer.IsEmpty()) {
|
|
|
|
// we have data left over from a previous OnDataAvailable() call.
|
|
|
|
// combine the buffers so we don't lose any data.
|
|
|
|
mBuffer.Append(buffer);
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(buffer);
|
2001-09-29 12:28:41 +04:00
|
|
|
buffer = ToNewCString(mBuffer);
|
1999-09-09 23:33:16 +04:00
|
|
|
mBuffer.Truncate();
|
|
|
|
}
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#ifndef DEBUG_valeski
|
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer) );
|
|
|
|
#else
|
|
|
|
printf("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer);
|
|
|
|
#endif // DEBUG_valeski
|
|
|
|
|
2001-12-06 03:09:00 +03:00
|
|
|
nsCString indexFormat;
|
1999-09-09 23:33:16 +04:00
|
|
|
if (!mSentHeading) {
|
1999-11-23 18:13:29 +03:00
|
|
|
// build up the 300: line
|
2001-12-06 03:09:00 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
rv = channel->GetURI(getter_AddRefs(uri));
|
1999-11-23 18:13:29 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-10 18:36:56 +04:00
|
|
|
|
2001-12-06 03:09:00 +03:00
|
|
|
rv = GetHeaders(indexFormat, uri);
|
1999-11-23 18:13:29 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
mSentHeading = PR_TRUE;
|
|
|
|
}
|
1999-09-10 18:36:56 +04:00
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
char *line = buffer;
|
|
|
|
line = DigestBufferLines(line, indexFormat);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#ifndef DEBUG_valeski
|
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() sending the following %d bytes...\n\n%s\n\n",
|
2001-03-02 12:26:57 +03:00
|
|
|
indexFormat.Length(), indexFormat.get()) );
|
2000-10-29 02:17:53 +04:00
|
|
|
#else
|
2001-09-29 12:28:41 +04:00
|
|
|
char *unescData = ToNewCString(indexFormat);
|
1999-09-18 00:13:33 +04:00
|
|
|
nsUnescape(unescData);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("::OnData() sending the following %d bytes...\n\n%s\n\n", indexFormat.Length(), unescData);
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(unescData);
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif // DEBUG_valeski
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
// if there's any data left over, buffer it.
|
|
|
|
if (line && *line) {
|
|
|
|
mBuffer.Append(line);
|
2000-10-29 02:17:53 +04:00
|
|
|
PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() buffering the following %d bytes...\n\n%s\n\n",
|
1999-09-10 18:36:56 +04:00
|
|
|
PL_strlen(line), line) );
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(buffer);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
// send the converted data out.
|
1999-10-01 18:10:02 +04:00
|
|
|
nsCOMPtr<nsIInputStream> inputData;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2002-01-28 01:02:00 +03:00
|
|
|
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat);
|
1999-09-09 23:33:16 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = mFinalListener->OnDataAvailable(mPartChannel, ctxt, inputData, 0, indexFormat.Length());
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
// nsIRequestObserver implementation
|
1999-09-09 23:33:16 +04:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsFTPDirListingConv::OnStartRequest(nsIRequest* request, nsISupports *ctxt) {
|
1999-09-09 23:33:16 +04:00
|
|
|
// we don't care about start. move along... but start masqeurading
|
|
|
|
// as the http-index channel now.
|
|
|
|
return mFinalListener->OnStartRequest(mPartChannel, ctxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsFTPDirListingConv::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsresult aStatus) {
|
1999-09-09 23:33:16 +04:00
|
|
|
// we don't care about stop. move along...
|
2001-02-21 23:38:08 +03:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
|
2000-01-20 03:51:18 +03:00
|
|
|
nsCOMPtr<nsILoadGroup> loadgroup;
|
2001-02-21 23:38:08 +03:00
|
|
|
rv = channel->GetLoadGroup(getter_AddRefs(loadgroup));
|
2000-01-20 03:51:18 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (loadgroup)
|
2001-04-10 10:01:08 +04:00
|
|
|
(void)loadgroup->RemoveRequest(mPartChannel, nsnull, aStatus);
|
2000-01-20 03:51:18 +03:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
return mFinalListener->OnStopRequest(mPartChannel, ctxt, aStatus);
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsFTPDirListingConv methods
|
|
|
|
nsFTPDirListingConv::nsFTPDirListingConv() {
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
mFinalListener = nsnull;
|
|
|
|
mServerType = GENERIC;
|
|
|
|
mPartChannel = nsnull;
|
|
|
|
mSentHeading = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFTPDirListingConv::~nsFTPDirListingConv() {
|
|
|
|
NS_IF_RELEASE(mFinalListener);
|
|
|
|
NS_IF_RELEASE(mPartChannel);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFTPDirListingConv::Init() {
|
2000-10-29 02:17:53 +04:00
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
//
|
|
|
|
// Initialize the global PRLogModule for FTP Protocol logging
|
|
|
|
// if necessary...
|
|
|
|
//
|
|
|
|
if (nsnull == gFTPDirListConvLog) {
|
|
|
|
gFTPDirListConvLog = PR_NewLogModule("nsFTPDirListingConv");
|
|
|
|
}
|
|
|
|
#endif /* PR_LOGGING */
|
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-06 03:09:00 +03:00
|
|
|
nsresult
|
2002-03-24 00:35:01 +03:00
|
|
|
nsFTPDirListingConv::GetHeaders(nsACString& headers,
|
2001-12-06 03:09:00 +03:00
|
|
|
nsIURI* uri)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// build up 300 line
|
|
|
|
headers.Append("300: ");
|
|
|
|
|
|
|
|
// Bug 111117 - don't print the password
|
2002-03-06 10:48:55 +03:00
|
|
|
nsCAutoString pw;
|
|
|
|
nsCAutoString spec;
|
|
|
|
uri->GetPassword(pw);
|
2001-12-06 03:09:00 +03:00
|
|
|
if (!pw.IsEmpty()) {
|
2002-03-06 10:48:55 +03:00
|
|
|
rv = uri->SetPassword(NS_LITERAL_CSTRING(""));
|
2001-12-06 03:09:00 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2002-03-06 10:48:55 +03:00
|
|
|
rv = uri->GetAsciiSpec(spec);
|
2001-12-06 03:09:00 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
headers.Append(spec);
|
|
|
|
rv = uri->SetPassword(pw);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
} else {
|
2002-03-06 10:48:55 +03:00
|
|
|
rv = uri->GetAsciiSpec(spec);
|
2001-12-06 03:09:00 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
headers.Append(spec);
|
|
|
|
}
|
|
|
|
headers.Append(char(nsCRT::LF));
|
|
|
|
// END 300:
|
|
|
|
|
|
|
|
// build up the column heading; 200:
|
|
|
|
headers.Append("200: filename content-length last-modified file-type\n");
|
|
|
|
// END 200:
|
|
|
|
return rv;
|
|
|
|
}
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
PRInt8
|
|
|
|
nsFTPDirListingConv::MonthNumber(const char *month) {
|
|
|
|
NS_ASSERTION(month && month[1] && month[2], "bad month");
|
|
|
|
if (!month || !month[0] || !month[1] || !month[2])
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
char c1 = month[1], c2 = month[2];
|
1999-09-10 18:36:56 +04:00
|
|
|
PRInt8 rv = -1;
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
//PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::MonthNumber(month = %s) ", month) );
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
switch (*month) {
|
|
|
|
case 'f': case 'F':
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 1; break;
|
1999-09-09 23:33:16 +04:00
|
|
|
case 'm': case 'M':
|
2001-08-01 06:04:53 +04:00
|
|
|
// c1 == 'a' || c1 == 'A'
|
|
|
|
if (c2 == 'r' || c2 == 'R')
|
|
|
|
rv = 2;
|
|
|
|
else
|
|
|
|
// c2 == 'y' || c2 == 'Y'
|
|
|
|
rv = 4;
|
1999-09-09 23:33:16 +04:00
|
|
|
break;
|
|
|
|
case 'a': case 'A':
|
|
|
|
if (c1 == 'p' || c1 == 'P')
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 3;
|
2001-08-01 06:04:53 +04:00
|
|
|
else
|
|
|
|
// c1 == 'u' || c1 == 'U'
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 7;
|
1999-09-09 23:33:16 +04:00
|
|
|
break;
|
|
|
|
case 'j': case 'J':
|
1999-09-11 02:08:26 +04:00
|
|
|
if (c1 == 'u' || c1 == 'U') {
|
1999-09-09 23:33:16 +04:00
|
|
|
if (c2 == 'n' || c2 == 'N')
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 5;
|
2001-08-01 06:04:53 +04:00
|
|
|
else
|
|
|
|
// c2 == 'l' || c2 == 'L'
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 6;
|
2001-08-01 06:04:53 +04:00
|
|
|
} else {
|
|
|
|
// c1 == 'a' || c1 == 'A'
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 0;
|
1999-09-11 02:08:26 +04:00
|
|
|
}
|
1999-09-09 23:33:16 +04:00
|
|
|
break;
|
|
|
|
case 's': case 'S':
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 8; break;
|
1999-09-09 23:33:16 +04:00
|
|
|
case 'o': case 'O':
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 9; break;
|
1999-09-09 23:33:16 +04:00
|
|
|
case 'n': case 'N':
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 10; break;
|
1999-09-09 23:33:16 +04:00
|
|
|
case 'd': case 'D':
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = 11; break;
|
1999-09-09 23:33:16 +04:00
|
|
|
default:
|
1999-09-10 18:36:56 +04:00
|
|
|
rv = -1;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
//PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("returning %d\n", rv) );
|
1999-09-10 18:36:56 +04:00
|
|
|
|
|
|
|
return rv;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Return true if the string is of the form:
|
|
|
|
// "Sep 1 1990 " or
|
|
|
|
// "Sep 11 11:59 " or
|
|
|
|
// "Dec 12 1989 " or
|
|
|
|
// "FCv 23 1990 " ...
|
|
|
|
PRBool
|
|
|
|
nsFTPDirListingConv::IsLSDate(char *aCStr) {
|
|
|
|
|
|
|
|
/* must start with three alpha characters */
|
2000-03-12 12:14:14 +03:00
|
|
|
if (!nsCRT::IsAsciiAlpha(*aCStr++) || !nsCRT::IsAsciiAlpha(*aCStr++) || !nsCRT::IsAsciiAlpha(*aCStr++))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
/* space */
|
|
|
|
if (*aCStr != ' ')
|
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* space or digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if ((*aCStr != ' ') && !nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if (!nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* space */
|
|
|
|
if (*aCStr != ' ')
|
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* space or digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if ((*aCStr != ' ') && !nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if (!nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* colon or digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if ((*aCStr != ':') && !nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if (!nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* space or digit */
|
2000-03-12 12:14:14 +03:00
|
|
|
if ((*aCStr != ' ') && !nsCRT::IsAsciiDigit(*aCStr))
|
1999-09-09 23:33:16 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
/* space */
|
|
|
|
if (*aCStr != ' ')
|
|
|
|
return PR_FALSE;
|
|
|
|
aCStr++;
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-10 18:36:56 +04:00
|
|
|
// Converts a date string from 'ls -l' to a PRTime number
|
1999-09-09 23:33:16 +04:00
|
|
|
// "Sep 1 1990 " or
|
|
|
|
// "Sep 11 11:59 " or
|
|
|
|
// "Dec 12 1989 " or
|
|
|
|
// "FCv 23 1990 " ...
|
|
|
|
// Returns 0 on error.
|
1999-09-10 19:27:19 +04:00
|
|
|
PRBool
|
2000-02-09 08:07:48 +03:00
|
|
|
nsFTPDirListingConv::ConvertUNIXDate(char *aCStr, PRExplodedTime& outDate) {
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
PRExplodedTime curTime;
|
1999-09-14 23:45:43 +04:00
|
|
|
InitPRExplodedTime(curTime);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
char *bcol = aCStr; /* Column begin */
|
|
|
|
char *ecol; /* Column end */
|
1999-09-14 03:26:26 +04:00
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
// MONTH
|
|
|
|
char tmpChar = bcol[3];
|
|
|
|
bcol[3] = '\0';
|
|
|
|
|
1999-09-10 18:36:56 +04:00
|
|
|
if ((curTime.tm_month = MonthNumber(bcol)) < 0)
|
2002-02-09 01:42:48 +03:00
|
|
|
return PR_FALSE;
|
1999-09-10 18:36:56 +04:00
|
|
|
bcol[3] = tmpChar;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
// DAY
|
|
|
|
ecol = &bcol[3];
|
1999-12-21 05:57:12 +03:00
|
|
|
while (*(++ecol) == ' ') ;
|
|
|
|
while (*(++ecol) != ' ') ;
|
|
|
|
*ecol = '\0';
|
|
|
|
bcol = ecol+1;
|
|
|
|
while (*(--ecol) != ' ') ;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
PRInt32 error;
|
1999-12-21 05:57:12 +03:00
|
|
|
nsCAutoString day(ecol);
|
1999-09-09 23:33:16 +04:00
|
|
|
curTime.tm_mday = day.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
// YEAR
|
|
|
|
if ((ecol = PL_strchr(bcol, ':')) == NULL) {
|
|
|
|
nsCAutoString intStr(bcol);
|
|
|
|
curTime.tm_year = intStr.ToInteger(&error, 10);
|
|
|
|
} else {
|
|
|
|
// TIME
|
2002-02-09 01:42:48 +03:00
|
|
|
/* If the time is given as hh:mm, then the file is less than 1 year
|
|
|
|
* old, but we might shift calandar year. This is avoided by checking
|
|
|
|
* if the date parsed is future or not.
|
|
|
|
*/
|
|
|
|
*ecol = '\0';
|
1999-09-09 23:33:16 +04:00
|
|
|
nsCAutoString intStr(++ecol);
|
1999-09-10 18:36:56 +04:00
|
|
|
curTime.tm_min = intStr.ToInteger(&error, 10); // Right side of ':'
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
intStr = bcol;
|
1999-09-10 18:36:56 +04:00
|
|
|
curTime.tm_hour = intStr.ToInteger(&error, 10); // Left side of ':'
|
1999-09-14 03:26:26 +04:00
|
|
|
|
1999-09-14 23:45:43 +04:00
|
|
|
PRExplodedTime nowETime;
|
|
|
|
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &nowETime);
|
|
|
|
curTime.tm_year = nowETime.tm_year;
|
2000-02-09 11:04:45 +03:00
|
|
|
|
|
|
|
PRBool thisCalendarYear = PR_FALSE;
|
|
|
|
if (nowETime.tm_month > curTime.tm_month) {
|
|
|
|
thisCalendarYear = PR_TRUE;
|
|
|
|
} else if (nowETime.tm_month == curTime.tm_month
|
|
|
|
&& nowETime.tm_mday > curTime.tm_mday) {
|
|
|
|
thisCalendarYear = PR_TRUE;
|
|
|
|
} else if (nowETime.tm_month == curTime.tm_month
|
2000-02-09 11:39:44 +03:00
|
|
|
&& nowETime.tm_mday == curTime.tm_mday
|
2000-02-09 11:04:45 +03:00
|
|
|
&& nowETime.tm_hour > curTime.tm_hour) {
|
|
|
|
thisCalendarYear = PR_TRUE;
|
|
|
|
} else if (nowETime.tm_month == curTime.tm_month
|
|
|
|
&& nowETime.tm_mday == curTime.tm_mday
|
|
|
|
&& nowETime.tm_hour == curTime.tm_hour
|
|
|
|
&& nowETime.tm_min >= curTime.tm_min) {
|
|
|
|
thisCalendarYear = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!thisCalendarYear) curTime.tm_year--;
|
1999-12-21 05:57:12 +03:00
|
|
|
}
|
1999-09-09 23:33:16 +04:00
|
|
|
|
1999-09-10 19:27:19 +04:00
|
|
|
// set the out param
|
2000-02-09 08:07:48 +03:00
|
|
|
outDate = curTime;
|
1999-09-10 19:27:19 +04:00
|
|
|
return PR_TRUE;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
1999-09-10 19:27:19 +04:00
|
|
|
PRBool
|
2000-02-09 08:07:48 +03:00
|
|
|
nsFTPDirListingConv::ConvertDOSDate(char *aCStr, PRExplodedTime& outDate) {
|
1999-09-09 23:33:16 +04:00
|
|
|
|
1999-11-11 03:28:30 +03:00
|
|
|
PRExplodedTime curTime, nowTime;
|
|
|
|
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &nowTime);
|
2002-03-27 08:43:49 +03:00
|
|
|
PRInt16 currCentury = nowTime.tm_year / 100;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
1999-09-14 23:45:43 +04:00
|
|
|
InitPRExplodedTime(curTime);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2002-03-27 08:43:49 +03:00
|
|
|
curTime.tm_month = ((aCStr[0]-'0')*10 + (aCStr[1]-'0')) - 1;
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
curTime.tm_mday = (((aCStr[3]-'0')*10) + aCStr[4]-'0');
|
2002-03-27 08:43:49 +03:00
|
|
|
curTime.tm_year = currCentury*100 + ((aCStr[6]-'0')*10) + aCStr[7]-'0';
|
|
|
|
// year is only 2-digit, so we've converted. If its in the future,
|
|
|
|
// it must have been last century
|
|
|
|
if (curTime.tm_year > nowTime.tm_year) {
|
|
|
|
curTime.tm_year -= 100;
|
|
|
|
}
|
|
|
|
|
1999-09-09 23:33:16 +04:00
|
|
|
curTime.tm_hour = (((aCStr[10]-'0')*10) + aCStr[11]-'0');
|
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
if (aCStr[15] == 'P')
|
1999-09-09 23:33:16 +04:00
|
|
|
curTime.tm_hour += 12;
|
|
|
|
|
|
|
|
curTime.tm_min = (((aCStr[13]-'0')*10) + aCStr[14]-'0');
|
|
|
|
|
2000-02-09 08:07:48 +03:00
|
|
|
outDate = curTime;
|
1999-09-10 19:27:19 +04:00
|
|
|
return PR_TRUE;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFTPDirListingConv::ParseLSLine(char *aLine, indexEntry *aEntry) {
|
|
|
|
|
|
|
|
PRInt32 base=1;
|
2002-01-08 05:56:20 +03:00
|
|
|
PRInt32 size_num=0;
|
|
|
|
char save_char;
|
|
|
|
char *ptr, *escName;
|
|
|
|
|
|
|
|
// insure that we have enough data to parse here
|
|
|
|
// using 27 for a minimal LIST line
|
|
|
|
if (PL_strlen(aLine) <= 27) {
|
|
|
|
NS_WARNING("ls -l is incorrectly formatted");
|
|
|
|
aEntry->mName.Adopt(nsEscape(aLine, url_Path));
|
|
|
|
// initialize the time struct to 0
|
|
|
|
InitPRExplodedTime(aEntry->mMDTM);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-09 23:33:16 +04:00
|
|
|
|
|
|
|
for (ptr = &aLine[PL_strlen(aLine) - 1];
|
2000-03-12 12:14:14 +03:00
|
|
|
(ptr > aLine+13) && (!nsCRT::IsAsciiSpace(*ptr) || !IsLSDate(ptr-12)); ptr--)
|
1999-09-09 23:33:16 +04:00
|
|
|
; /* null body */
|
2002-02-09 01:42:48 +03:00
|
|
|
save_char = *ptr;
|
1999-09-09 23:33:16 +04:00
|
|
|
*ptr = '\0';
|
|
|
|
if (ptr > aLine+13) {
|
1999-09-10 19:27:19 +04:00
|
|
|
ConvertUNIXDate(ptr-12, aEntry->mMDTM);
|
1999-09-09 23:33:16 +04:00
|
|
|
} else {
|
2002-02-09 01:42:48 +03:00
|
|
|
// must be a dl listing
|
|
|
|
// unterminate the line
|
|
|
|
*ptr = save_char;
|
|
|
|
// find the first whitespace and terminate
|
|
|
|
for(ptr=aLine; *ptr != '\0'; ptr++)
|
|
|
|
if (nsCRT::IsAsciiSpace(*ptr)) {
|
|
|
|
*ptr = '\0';
|
|
|
|
break;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
1999-09-14 03:26:26 +04:00
|
|
|
escName = nsEscape(aLine, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
aEntry->mName.Adopt(escName);
|
2002-03-26 17:11:27 +03:00
|
|
|
|
|
|
|
// initialize the time struct to 0 to be safe
|
|
|
|
InitPRExplodedTime(aEntry->mMDTM);
|
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
return NS_OK;
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
|
|
|
|
1999-09-14 03:26:26 +04:00
|
|
|
escName = nsEscape(ptr+1, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
aEntry->mName.Adopt(escName);
|
1999-09-09 23:33:16 +04:00
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
// parse size
|
|
|
|
if (ptr > aLine+15) {
|
1999-09-09 23:33:16 +04:00
|
|
|
ptr -= 14;
|
2000-03-12 12:14:14 +03:00
|
|
|
while (nsCRT::IsAsciiDigit(*ptr)) {
|
1999-09-09 23:33:16 +04:00
|
|
|
size_num += ((PRInt32) (*ptr - '0')) * base;
|
|
|
|
base *= 10;
|
|
|
|
ptr--;
|
|
|
|
}
|
|
|
|
|
|
|
|
aEntry->mContentLen = size_num;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-14 23:45:43 +04:00
|
|
|
void
|
|
|
|
nsFTPDirListingConv::InitPRExplodedTime(PRExplodedTime& aTime) {
|
|
|
|
aTime.tm_usec = 0;
|
|
|
|
aTime.tm_sec = 0;
|
|
|
|
aTime.tm_min = 0;
|
|
|
|
aTime.tm_hour = 0;
|
|
|
|
aTime.tm_mday = 0;
|
|
|
|
aTime.tm_month= 0;
|
|
|
|
aTime.tm_year = 0;
|
1999-10-01 18:10:02 +04:00
|
|
|
aTime.tm_wday = 0;
|
|
|
|
aTime.tm_yday = 0;
|
2000-02-09 08:07:48 +03:00
|
|
|
aTime.tm_params.tp_gmt_offset = 0;
|
|
|
|
aTime.tm_params.tp_dst_offset = 0;
|
1999-09-14 23:45:43 +04:00
|
|
|
}
|
|
|
|
|
2002-01-08 05:56:20 +03:00
|
|
|
/**
|
|
|
|
* Can this line possibly be a ls-l line?
|
|
|
|
* Ideally, one should parse the line into tokens, etc. but
|
|
|
|
* that's for later. At the moment, just test the line for
|
|
|
|
* length and examine the first token. An absolutely minimal
|
|
|
|
* line has the form
|
|
|
|
* -rwxrwxrwx 0 Dec 31 23:59 F
|
|
|
|
* which is 27 characters. If the line is at least 27 bytes
|
|
|
|
* long and the first token matches the regular expression
|
|
|
|
* [-dlbcps][r-][w-][sSx-][r-][w-][sSx-][r-][w-][tTx-]
|
|
|
|
* then accept the line *provided* there is another token on
|
|
|
|
* the line.
|
|
|
|
|
|
|
|
* As written, this function *assumes* leading whitespace has
|
|
|
|
* been removed. That's what the rest of the code assumes. It
|
|
|
|
* may not be a reasonable assumption.
|
|
|
|
|
|
|
|
* DigestBufferLines hints that the regular expression test should
|
|
|
|
* be done case insensitively. That would relax this test so it is
|
|
|
|
* *not* done. If definitive evidence exists of a server that does
|
|
|
|
* this, then it can be changed.
|
|
|
|
|
|
|
|
* This function uses a lot of macros for clarity. They probably
|
|
|
|
* should be improved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsFTPDirListingConv::ls_lCandidate(const char *lsLine) {
|
|
|
|
|
|
|
|
const char *cp;
|
|
|
|
|
|
|
|
if (PL_strlen(lsLine) < 27) return PR_FALSE;
|
|
|
|
if (!IS_FTYPE(lsLine[0])) return PR_FALSE;
|
|
|
|
// shorter tests first
|
|
|
|
if (!IS_RPERM(lsLine[1])) return PR_FALSE;
|
|
|
|
if (!IS_WPERM(lsLine[2])) return PR_FALSE;
|
|
|
|
if (!IS_RPERM(lsLine[4])) return PR_FALSE;
|
|
|
|
if (!IS_WPERM(lsLine[5])) return PR_FALSE;
|
|
|
|
if (!IS_RPERM(lsLine[7])) return PR_FALSE;
|
|
|
|
if (!IS_WPERM(lsLine[8])) return PR_FALSE;
|
|
|
|
if (!IS_SPERM(lsLine[3])) return PR_FALSE;
|
|
|
|
if (!IS_SPERM(lsLine[6])) return PR_FALSE;
|
|
|
|
for (cp = &lsLine[10]; *cp; ++cp)
|
|
|
|
if (!IS_LWS(*cp)) return PR_TRUE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
char *
|
2001-12-06 03:09:00 +03:00
|
|
|
nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCString &aString) {
|
1999-11-23 18:13:29 +03:00
|
|
|
nsresult rv;
|
|
|
|
char *line = aBuffer;
|
|
|
|
char *eol;
|
|
|
|
PRBool cr = PR_FALSE;
|
|
|
|
|
|
|
|
// while we have new lines, parse 'em into application/http-index-format.
|
2001-04-18 09:59:43 +04:00
|
|
|
while ( line && (eol = PL_strchr(line, nsCRT::LF)) ) {
|
1999-11-23 18:13:29 +03:00
|
|
|
// yank any carriage returns too.
|
2001-04-18 09:59:43 +04:00
|
|
|
if (eol > line && *(eol-1) == nsCRT::CR) {
|
1999-11-23 18:13:29 +03:00
|
|
|
eol--;
|
|
|
|
*eol = '\0';
|
|
|
|
cr = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
*eol = '\0';
|
|
|
|
cr = PR_FALSE;
|
|
|
|
}
|
|
|
|
indexEntry *thisEntry = nsnull;
|
|
|
|
NS_NEWXPCOM(thisEntry, indexEntry);
|
|
|
|
if (!thisEntry) return nsnull;
|
|
|
|
|
|
|
|
// XXX we need to handle comments in the raw stream.
|
|
|
|
|
|
|
|
// special case windows servers who masquerade as unix servers
|
2000-03-12 12:14:14 +03:00
|
|
|
if (NT == mServerType && !nsCRT::IsAsciiSpace(line[8]))
|
1999-11-23 18:13:29 +03:00
|
|
|
mServerType = UNIX;
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// check for an eplf response
|
|
|
|
if (line[0] == '+')
|
|
|
|
mServerType = EPLF;
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
char *escName = nsnull;
|
|
|
|
switch (mServerType) {
|
|
|
|
|
|
|
|
case UNIX:
|
|
|
|
case PETER_LEWIS:
|
|
|
|
case MACHTEN:
|
|
|
|
{
|
|
|
|
// don't bother w/ these lines.
|
2002-02-09 01:42:48 +03:00
|
|
|
if (!PL_strncmp(line, "total ", 6)
|
2000-03-16 02:19:58 +03:00
|
|
|
|| !PL_strncmp(line, "ls: total", 9)
|
2002-02-09 01:42:48 +03:00
|
|
|
|| (PL_strstr(line, "Permission denied") != NULL)
|
2000-03-16 02:19:58 +03:00
|
|
|
|| (PL_strstr(line, "not available") != NULL)) {
|
1999-11-23 18:13:29 +03:00
|
|
|
NS_DELETEXPCOM(thisEntry);
|
|
|
|
if (cr)
|
|
|
|
line = eol+2;
|
|
|
|
else
|
|
|
|
line = eol+1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 len = PL_strlen(line);
|
|
|
|
|
|
|
|
// check first character of ls -l output
|
|
|
|
// For example: "dr-x--x--x" is what we're starting with.
|
2002-01-08 05:56:20 +03:00
|
|
|
// sanity check for dir permission bits
|
|
|
|
if ((line[0] == 'D' || line[0] == 'd') && ls_lCandidate(line)) {
|
1999-11-23 18:13:29 +03:00
|
|
|
/* it's a directory */
|
|
|
|
thisEntry->mType = Dir;
|
|
|
|
thisEntry->mSupressSize = PR_TRUE;
|
2002-01-08 05:56:20 +03:00
|
|
|
} else if ((line[0] == 'L' || line[0] == 'l') && ls_lCandidate(line)) {
|
|
|
|
/**
|
|
|
|
* Dir Links are not displayed properly
|
|
|
|
* we need a more robust implementation
|
|
|
|
*/
|
1999-11-23 18:13:29 +03:00
|
|
|
thisEntry->mType = Link;
|
|
|
|
thisEntry->mSupressSize = PR_TRUE;
|
|
|
|
|
|
|
|
/* strip off " -> pathname" */
|
|
|
|
PRInt32 i;
|
2000-03-12 12:14:14 +03:00
|
|
|
for (i = len - 1; (i > 3) && (!nsCRT::IsAsciiSpace(line[i])
|
1999-11-23 18:13:29 +03:00
|
|
|
|| (line[i-1] != '>')
|
|
|
|
|| (line[i-2] != '-')
|
|
|
|
|| (line[i-3] != ' ')); i--)
|
|
|
|
; /* null body */
|
|
|
|
if (i > 3) {
|
|
|
|
line[i-3] = '\0';
|
|
|
|
len = i - 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ParseLSLine(line, thisEntry);
|
|
|
|
if ( NS_FAILED(rv) || (thisEntry->mName.Equals("..")) || (thisEntry->mName.Equals(".")) ) {
|
|
|
|
NS_DELETEXPCOM(thisEntry);
|
|
|
|
if (cr)
|
|
|
|
line = eol+2;
|
|
|
|
else
|
|
|
|
line = eol+1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break; // END UNIX, PETER_LEWIS, MACHTEN
|
|
|
|
}
|
|
|
|
|
|
|
|
case NCSA:
|
|
|
|
case TCPC:
|
|
|
|
{
|
|
|
|
escName = nsEscape(line, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
1999-11-23 18:13:29 +03:00
|
|
|
|
2000-02-23 23:05:30 +03:00
|
|
|
if (thisEntry->mName.Last() == '/') {
|
1999-11-23 18:13:29 +03:00
|
|
|
thisEntry->mType = Dir;
|
2000-02-23 23:05:30 +03:00
|
|
|
thisEntry->mName.Truncate(thisEntry->mName.Length()-1);
|
|
|
|
}
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
break; // END NCSA, TCPC
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMS:
|
|
|
|
{
|
|
|
|
escName = nsEscape(line, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
1999-11-23 18:13:29 +03:00
|
|
|
break; // END CMS
|
|
|
|
}
|
|
|
|
case NT:
|
|
|
|
{
|
2002-02-09 01:42:48 +03:00
|
|
|
// don't bother w/ these lines.
|
|
|
|
if (!PL_strncmp(line, "total ", 6)
|
2001-03-01 03:23:36 +03:00
|
|
|
|| !PL_strncmp(line, "ls: total", 9)
|
2002-02-09 01:42:48 +03:00
|
|
|
|| (PL_strstr(line, "Permission denied") != NULL)
|
2001-03-01 03:23:36 +03:00
|
|
|
|| (PL_strstr(line, "not available") != NULL)) {
|
|
|
|
NS_DELETEXPCOM(thisEntry);
|
|
|
|
if (cr)
|
|
|
|
line = eol+2;
|
|
|
|
else
|
|
|
|
line = eol+1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *date, *size_s, *name;
|
1999-11-23 18:13:29 +03:00
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
if (PL_strlen(line) > 37) {
|
|
|
|
date = line;
|
|
|
|
line[17] = '\0';
|
|
|
|
size_s = &line[18];
|
|
|
|
line[38] = '\0';
|
|
|
|
name = &line[39];
|
1999-11-23 18:13:29 +03:00
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
if (PL_strstr(size_s, "<DIR>")) {
|
1999-11-23 18:13:29 +03:00
|
|
|
thisEntry->mType = Dir;
|
|
|
|
} else {
|
|
|
|
nsCAutoString size(size_s);
|
|
|
|
size.StripWhitespace();
|
2001-03-02 12:26:57 +03:00
|
|
|
thisEntry->mContentLen = atol(size.get());
|
1999-11-23 18:13:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ConvertDOSDate(date, thisEntry->mMDTM);
|
|
|
|
|
|
|
|
escName = nsEscape(name, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
1999-11-23 18:13:29 +03:00
|
|
|
} else {
|
|
|
|
escName = nsEscape(line, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
|
|
|
}
|
1999-11-23 18:13:29 +03:00
|
|
|
break; // END NT
|
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
case EPLF:
|
|
|
|
{
|
|
|
|
|
|
|
|
int flagcwd = 0;
|
|
|
|
int when = 0;
|
|
|
|
int flagsize = 0;
|
2002-02-18 18:22:56 +03:00
|
|
|
unsigned long size = 0;
|
2001-02-21 23:38:08 +03:00
|
|
|
PRBool processing = PR_TRUE;
|
|
|
|
while (*line && processing)
|
|
|
|
switch (*line) {
|
|
|
|
case '\t':
|
|
|
|
{
|
|
|
|
if (flagcwd) {
|
|
|
|
thisEntry->mType = Dir;
|
|
|
|
thisEntry->mContentLen = 0;
|
|
|
|
} else {
|
|
|
|
thisEntry->mType = File;
|
|
|
|
thisEntry->mContentLen = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
escName = nsEscape(line+1, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
2002-01-16 01:34:32 +03:00
|
|
|
thisEntry->mSupressSize = !flagsize;
|
|
|
|
|
|
|
|
// Mutiply what the last modification date to get usecs.
|
|
|
|
PRInt64 usecs = LL_Zero();
|
|
|
|
PRInt64 seconds = LL_Zero();
|
|
|
|
PRInt64 multiplier = LL_Zero();
|
|
|
|
LL_I2L(seconds, when);
|
|
|
|
LL_I2L(multiplier, PR_USEC_PER_SEC);
|
|
|
|
LL_MUL(usecs, seconds, multiplier);
|
|
|
|
PR_ExplodeTime(usecs, PR_LocalTimeParameters, &thisEntry->mMDTM);
|
2001-02-21 23:38:08 +03:00
|
|
|
|
|
|
|
processing = PR_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
flagsize = 1;
|
|
|
|
size = 0;
|
2001-03-01 03:23:36 +03:00
|
|
|
while (*++line && nsCRT::IsAsciiDigit(*line))
|
2001-02-21 23:38:08 +03:00
|
|
|
size = size * 10 + (*line - '0');
|
|
|
|
break;
|
|
|
|
case 'm':
|
2001-03-01 03:23:36 +03:00
|
|
|
while (*++line && nsCRT::IsAsciiDigit(*line))
|
2001-02-21 23:38:08 +03:00
|
|
|
when = when * 10 + (*line - '0');
|
|
|
|
break;
|
|
|
|
case '/':
|
|
|
|
flagcwd = 1;
|
|
|
|
default:
|
|
|
|
while (*line) if (*line++ == ',') break;
|
|
|
|
}
|
|
|
|
break; //END EPLF
|
|
|
|
}
|
|
|
|
|
2001-09-20 18:16:14 +04:00
|
|
|
case OS_2:
|
|
|
|
{
|
2002-02-09 01:42:48 +03:00
|
|
|
if (!PL_strncmp(line, "total ", 6)
|
2001-09-20 18:51:00 +04:00
|
|
|
|| (PL_strstr(line, "not authorized") != NULL)
|
|
|
|
|| (PL_strstr(line, "Path not found") != NULL)
|
|
|
|
|| (PL_strstr(line, "No Files") != NULL)) {
|
2001-09-20 18:16:14 +04:00
|
|
|
NS_DELETEXPCOM(thisEntry);
|
|
|
|
if (cr)
|
|
|
|
line = eol+2;
|
|
|
|
else
|
|
|
|
line = eol+1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *name;
|
|
|
|
nsCAutoString str;
|
|
|
|
|
2002-02-09 01:42:48 +03:00
|
|
|
if (PL_strstr(line, "DIR")) {
|
2001-09-20 18:16:14 +04:00
|
|
|
thisEntry->mType = Dir;
|
|
|
|
thisEntry->mSupressSize = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thisEntry->mType = File;
|
|
|
|
|
|
|
|
PRInt32 error;
|
|
|
|
line[18] = '\0';
|
|
|
|
str = line;
|
|
|
|
str.StripWhitespace();
|
|
|
|
thisEntry->mContentLen = str.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
InitPRExplodedTime(thisEntry->mMDTM);
|
|
|
|
line[37] = '\0';
|
|
|
|
str = &line[35];
|
|
|
|
thisEntry->mMDTM.tm_month = str.ToInteger(&error, 10) - 1;
|
|
|
|
|
|
|
|
line[40] = '\0';
|
|
|
|
str = &line[38];
|
|
|
|
thisEntry->mMDTM.tm_mday = str.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
line[43] = '\0';
|
|
|
|
str = &line[41];
|
|
|
|
thisEntry->mMDTM.tm_year = str.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
line[48] = '\0';
|
|
|
|
str = &line[46];
|
|
|
|
thisEntry->mMDTM.tm_hour = str.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
line[51] = '\0';
|
|
|
|
str = &line[49];
|
|
|
|
thisEntry->mMDTM.tm_min = str.ToInteger(&error, 10);
|
|
|
|
|
|
|
|
name = &line[53];
|
|
|
|
escName = nsEscape(name, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
2001-09-20 18:16:14 +04:00
|
|
|
|
|
|
|
break;
|
2002-02-09 01:42:48 +03:00
|
|
|
}
|
2001-09-20 18:16:14 +04:00
|
|
|
|
1999-11-23 18:13:29 +03:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
escName = nsEscape(line, url_Path);
|
2002-02-09 01:42:48 +03:00
|
|
|
thisEntry->mName.Adopt(escName);
|
1999-11-23 18:13:29 +03:00
|
|
|
break; // END default (catches GENERIC, DCTS)
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end switch (mServerType)
|
|
|
|
|
|
|
|
// blast the index entry into the indexFormat buffer as a 201: line.
|
|
|
|
aString.Append("201: ");
|
|
|
|
// FILENAME
|
|
|
|
aString.Append(thisEntry->mName);
|
2001-10-23 04:56:41 +04:00
|
|
|
if (thisEntry->mType == Dir)
|
|
|
|
aString.Append('/');
|
1999-11-23 18:13:29 +03:00
|
|
|
aString.Append(' ');
|
|
|
|
|
|
|
|
// CONTENT LENGTH
|
|
|
|
if (!thisEntry->mSupressSize) {
|
2000-04-15 13:16:58 +04:00
|
|
|
aString.AppendInt(thisEntry->mContentLen);
|
1999-11-23 18:13:29 +03:00
|
|
|
} else {
|
|
|
|
aString.Append('0');
|
|
|
|
}
|
|
|
|
aString.Append(' ');
|
|
|
|
|
|
|
|
// MODIFIED DATE
|
2000-10-25 01:53:12 +04:00
|
|
|
char buffer[256] = "";
|
2001-10-03 04:43:30 +04:00
|
|
|
// Note: The below is the RFC822/1123 format, as required by
|
|
|
|
// the application/http-index-format specs
|
|
|
|
// viewers of such a format can then reformat this into the
|
|
|
|
// current locale (or anything else they choose)
|
2002-01-08 05:56:20 +03:00
|
|
|
|
|
|
|
// make sure we don't have a null time struct
|
|
|
|
if ((thisEntry->mMDTM.tm_month + thisEntry->mMDTM.tm_mday +
|
|
|
|
thisEntry->mMDTM.tm_year + thisEntry->mMDTM.tm_hour +
|
|
|
|
thisEntry->mMDTM.tm_min) != nsnull) {
|
|
|
|
PR_FormatTimeUSEnglish(buffer, sizeof(buffer),
|
2001-10-23 04:56:41 +04:00
|
|
|
"%a, %d %b %Y %H:%M:%S", &thisEntry->mMDTM );
|
2002-01-08 05:56:20 +03:00
|
|
|
}
|
|
|
|
|
2000-10-25 01:53:12 +04:00
|
|
|
char *escapedDate = nsEscape(buffer, url_Path);
|
1999-11-23 18:13:29 +03:00
|
|
|
|
|
|
|
aString.Append(escapedDate);
|
2002-02-23 03:41:52 +03:00
|
|
|
nsMemory::Free(escapedDate);
|
1999-11-23 18:13:29 +03:00
|
|
|
aString.Append(' ');
|
|
|
|
|
|
|
|
|
|
|
|
// ENTRY TYPE
|
|
|
|
switch (thisEntry->mType) {
|
|
|
|
case Dir:
|
|
|
|
aString.Append("DIRECTORY");
|
|
|
|
break;
|
|
|
|
case Link:
|
2000-02-08 04:20:46 +03:00
|
|
|
aString.Append("SYMBOLIC-LINK");
|
1999-11-23 18:13:29 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aString.Append("FILE");
|
|
|
|
}
|
|
|
|
aString.Append(' ');
|
|
|
|
|
2001-04-18 09:59:43 +04:00
|
|
|
aString.Append(char(nsCRT::LF)); // complete this line
|
1999-11-23 18:13:29 +03:00
|
|
|
// END 201:
|
|
|
|
|
|
|
|
NS_DELETEXPCOM(thisEntry);
|
|
|
|
|
|
|
|
if (cr)
|
|
|
|
line = eol+2;
|
|
|
|
else
|
|
|
|
line = eol+1;
|
|
|
|
} // end while(eol)
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
1999-10-14 17:36:33 +04:00
|
|
|
nsresult
|
|
|
|
NS_NewFTPDirListingConv(nsFTPDirListingConv** aFTPDirListingConv)
|
1999-09-09 23:33:16 +04:00
|
|
|
{
|
1999-10-14 17:36:33 +04:00
|
|
|
NS_PRECONDITION(aFTPDirListingConv != nsnull, "null ptr");
|
|
|
|
if (! aFTPDirListingConv)
|
1999-09-09 23:33:16 +04:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-10-14 17:36:33 +04:00
|
|
|
*aFTPDirListingConv = new nsFTPDirListingConv();
|
|
|
|
if (! *aFTPDirListingConv)
|
1999-09-09 23:33:16 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
1999-10-14 17:36:33 +04:00
|
|
|
NS_ADDREF(*aFTPDirListingConv);
|
|
|
|
return (*aFTPDirListingConv)->Init();
|
1999-09-09 23:33:16 +04:00
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
|