r=dougt, sr=darinr
XP support for FTP to OS/2 servers
This commit is contained in:
mkaply%us.ibm.com 2001-09-20 14:16:14 +00:00
Родитель 321c5b7db0
Коммит 3ed79ab4fc
6 изменённых файлов: 84 добавлений и 0 удалений

Просмотреть файл

@ -205,6 +205,7 @@ nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
#define FTP_UNIX_TO_INDEX "?from=text/ftp-dir-unix&to=application/http-index-format"
#define FTP_NT_TO_INDEX "?from=text/ftp-dir-nt&to=application/http-index-format"
#define FTP_OS2_TO_INDEX "?from=text/ftp-dir-os2&to=application/http-index-format"
#define GOPHER_TO_INDEX "?from=text/gopher-dir&to=application/http-index-format"
#define INDEX_TO_HTML "?from=application/http-index-format&to=text/html"
#define MULTI_MIXED_X "?from=multipart/x-mixed-replace&to=*/*"
@ -233,6 +234,7 @@ static PRUint32 g_StreamConverterCount = 15;
static char *g_StreamConverterArray[] = {
FTP_UNIX_TO_INDEX,
FTP_NT_TO_INDEX,
FTP_OS2_TO_INDEX,
GOPHER_TO_INDEX,
INDEX_TO_HTML,
MULTI_MIXED_X,
@ -707,6 +709,12 @@ static nsModuleComponentInfo gNetModuleInfo[] = {
CreateNewFTPDirListingConv
},
{ "FTPDirListingConverter",
NS_FTPDIRLISTINGCONVERTER_CID,
NS_ISTREAMCONVERTER_KEY FTP_OS2_TO_INDEX,
CreateNewFTPDirListingConv
},
{ "GopherDirListingConverter",
NS_GOPHERDIRLISTINGCONVERTER_CID,
NS_ISTREAMCONVERTER_KEY GOPHER_TO_INDEX,

Просмотреть файл

@ -1079,6 +1079,10 @@ nsFtpState::R_syst() {
{
mServerType = FTP_NT_TYPE;
}
else if ( mResponseMsg.Find("OS/2", PR_TRUE) > -1)
{
mServerType = FTP_OS2_TYPE;
}
else
{
NS_ASSERTION(0, "Server type list format unrecognized.");
@ -1944,6 +1948,9 @@ nsFtpState::SetDirMIMEType(nsString& aString) {
case FTP_NT_TYPE:
aString.Append(NS_LITERAL_STRING("nt"));
break;
case FTP_OS2_TYPE:
aString.Append(NS_LITERAL_STRING("os2"));
break;
default:
aString.Append(NS_LITERAL_STRING("generic"));
}

Просмотреть файл

@ -53,6 +53,7 @@
#define FTP_GENERIC_TYPE 0
#define FTP_UNIX_TYPE 1
#define FTP_NT_TYPE 9
#define FTP_OS2_TYPE 11
// ftp states
typedef enum _FTP_STATE {

Просмотреть файл

@ -232,6 +232,12 @@ static nsModuleComponentInfo components[] =
NS_ISTREAMCONVERTER_KEY "?from=text/ftp-dir-nt&to=application/http-index-format",
CreateNewFTPDirListingConv
},
{ "FTPDirListingConverter",
NS_FTPDIRLISTINGCONVERTER_CID,
NS_ISTREAMCONVERTER_KEY "?from=text/ftp-dir-os2&to=application/http-index-format",
CreateNewFTPDirListingConv
},
{ "MultiMixedConverter",
NS_MULTIMIXEDCONVERTER_CID,

Просмотреть файл

@ -96,6 +96,8 @@ DetermineServerType (nsCString &fromMIMEString, const PRUnichar *aFromType)
return CMS;
} else if (-1 != fromMIMEString.Find("tcpc")) {
return TCPC;
} else if (-1 != fromMIMEString.Find("os2")) {
return OS_2;
}
return GENERIC;
@ -927,6 +929,65 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) {
break; //END EPLF
}
case OS_2:
{
if(!PL_strncmp(line, "total ", 6)
|| (PL_strnstr(line, "not authorized") != NULL)
|| (PL_strnstr(line, "Path not found") != NULL)
|| (PL_strnstr(line, "No Files") != NULL)) {
NS_DELETEXPCOM(thisEntry);
if (cr)
line = eol+2;
else
line = eol+1;
continue;
}
char *name;
nsCAutoString str;
if(PL_strnstr(line, "DIR")) {
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);
thisEntry->mName = escName;
nsMemory::Free(escName);
break;
}
default:
{
escName = nsEscape(line, url_Path);

Просмотреть файл

@ -72,6 +72,7 @@ typedef enum _FTP_Server_Type {
VMS,
NT,
EPLF,
OS_2,
ERROR_TYPE
} FTP_Server_Type;