backing out andreas and warren

This commit is contained in:
sspitzer%netscape.com 2000-01-14 22:01:56 +00:00
Родитель 0a83e08ac0
Коммит d8a5c41c93
40 изменённых файлов: 979 добавлений и 2684 удалений

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

@ -854,6 +854,3 @@ $(CHROME_L10N:.\=CLOBBER\.\):
!endif # CONFIG_RULES_MAK
# Easier than typing it by hand, works from any directory:
debug::
start msdev $(DIST)\bin\mozilla.exe

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

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr = nsnull;
char* urlStr;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

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

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr = nsnull;
char* urlStr;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

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

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr = nsnull;
char* urlStr;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

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

@ -309,6 +309,7 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetScheme(const char * aScheme)
return m_baseURL->SetScheme(aScheme);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPreHost(char * *aPreHost)
{
return m_baseURL->GetPreHost(aPreHost);
@ -319,26 +320,6 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetPreHost(const char * aPreHost)
return m_baseURL->SetPreHost(aPreHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetUsername(char * *aUsername)
{
return m_baseURL->GetUsername(aUsername);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetUsername(const char * aUsername)
{
return m_baseURL->SetUsername(aUsername);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPassword(char * *aPassword)
{
return m_baseURL->GetPassword(aPassword);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPassword(const char * aPassword)
{
return m_baseURL->SetPassword(aPassword);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetHost(char * *aHost)
{
return m_baseURL->GetHost(aHost);
@ -369,21 +350,12 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetPath(const char * aPath)
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetURLParser(nsIURLParser * *aURLParser)
{
return m_baseURL->GetURLParser(aURLParser);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetURLParser(nsIURLParser* aURLParser)
{
return m_baseURL->SetURLParser(aURLParser);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval)
{
return m_baseURL->Clone(_retval);
@ -417,22 +389,22 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetFileName(char * *aFileName)
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileBaseName(char * *aFileBaseName)
{
return m_baseURL->GetFileBaseName(aFileBaseName);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileBaseName(const char * aFileBaseName)
{
return m_baseURL->SetFileBaseName(aFileBaseName);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileExtension(char * *aFileExtension)
{
return m_baseURL->GetFileExtension(aFileExtension);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileExtension(const char * aFileExtension)
{
return m_baseURL->SetFileExtension(aFileExtension);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileName(const char * aFileName)

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

@ -318,26 +318,6 @@ NS_IMETHODIMP nsMailtoUrl::SetPreHost(const char * aPreHost)
return m_baseURL->SetPreHost(aPreHost);
}
NS_IMETHODIMP nsMailtoUrl::GetUsername(char * *aUsername)
{
return m_baseURL->GetUsername(aUsername);
}
NS_IMETHODIMP nsMailtoUrl::SetUsername(const char * aUsername)
{
return m_baseURL->SetUsername(aUsername);
}
NS_IMETHODIMP nsMailtoUrl::GetPassword(char * *aPassword)
{
return m_baseURL->GetPassword(aPassword);
}
NS_IMETHODIMP nsMailtoUrl::SetPassword(const char * aPassword)
{
return m_baseURL->SetPassword(aPassword);
}
NS_IMETHODIMP nsMailtoUrl::GetHost(char * *aHost)
{
return m_baseURL->GetHost(aHost);
@ -368,16 +348,6 @@ NS_IMETHODIMP nsMailtoUrl::SetPath(const char * aPath)
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMailtoUrl::GetURLParser(nsIURLParser * *aURLParser)
{
return m_baseURL->GetURLParser(aURLParser);
}
NS_IMETHODIMP nsMailtoUrl::SetURLParser(nsIURLParser * aURLParser)
{
return m_baseURL->SetURLParser(aURLParser);
}
NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);

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

@ -157,30 +157,6 @@ nsJARURI::SetPreHost(const char * aPreHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetUsername(char * *aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetUsername(const char * aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetPassword(char * *aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetPassword(const char * aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetHost(char * *aHost)
{
@ -217,18 +193,6 @@ nsJARURI::SetPath(const char * aPath)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetURLParser(nsIURLParser * *aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetURLParser(nsIURLParser * aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::Equals(nsIURI *other, PRBool *_retval)
{

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

@ -12,4 +12,3 @@ nsISocketTransportService.idl
nsIFileTransportService.idl
nsIFileSystem.idl
nsIUnicharStreamLoader.idl
nsIURLParser.idl

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

@ -51,7 +51,6 @@ XPIDLSRCS = \
nsIUnicharStreamLoader.idl \
nsINetPrompt.idl \
nsISocketTransport.idl \
nsIURLParser.idl \
$(NULL)
EXPORTS = \

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

@ -50,9 +50,8 @@ XPIDLSRCS = \
.\nsIStatusCodeEventSink.idl \
.\nsIFileSystem.idl \
.\nsIUnicharStreamLoader.idl \
.\nsINetPrompt.idl \
.\nsISocketTransport.idl \
.\nsIURLParser.idl \
.\nsINetPrompt.idl \
.\nsISocketTransport.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

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

@ -39,20 +39,6 @@ interface nsILoadGroupObserver;
[scriptable, uuid(1daf19f0-8ea7-11d3-93ad-00104ba0fd40)]
interface nsIIOService : nsISupports
{
/**
* constants for the Escape mask in the call to URLEscape
*/
const short url_Scheme = (1<<0);
const short url_Username = (1<<1);
const short url_Password = (1<<2);
const short url_Host = (1<<3);
const short url_Directory = (1<<4);
const short url_FileBaseName = (1<<5);
const short url_FileExtension = (1<<6);
const short url_Param = (1<<7);
const short url_Query = (1<<8);
const short url_Ref = (1<<9);
/**
* Returns a protocol handler for a given URI scheme.
*/
@ -174,18 +160,6 @@ interface nsIIOService : nsISupports
* causing the dialer to come up).
*/
attribute boolean offline;
/**
* escapes the string str with mask
*/
void URLEscape (in string str,
in short mask,
out string result);
/**
* unescapes str
*/
void URLUnescape(in string str,
out string result);
};
%{C++

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

@ -21,7 +21,6 @@
*/
#include "nsISupports.idl"
#include "nsIURLParser.idl"
/**
* URIs are essentially structured names for things -- anything.
@ -80,10 +79,6 @@ interface nsIURI : nsISupports
*/
attribute string preHost;
attribute string username;
attribute string password;
/**
* The Host is the internet domain name to which this URI refers.
* Note that it could be an IP address as well.
@ -108,11 +103,6 @@ interface nsIURI : nsISupports
*/
attribute string path;
/**
* This is a handle to the Parser used to parse the URI
*/
attribute nsIURLParser URLParser;
/**
* Note that this comparison is only on char* level. Use
* the scheme specific URI to do a more thorough check. For example,
@ -147,7 +137,6 @@ interface nsIURI : nsISupports
* This method subsumes the deprecated method nsIIOService::MakeAbsolute.
*/
string resolve(in string relativePath);
};
%{C++

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

@ -1,117 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* nsIURLParser is the abstract base class for parsing URLs
*/
[scriptable, uuid(4b4975f9-f128-47fd-b11e-88402233cbdf)]
interface nsIURLParser : nsISupports
{
/**
* Parses a URL and thinks it is parsing the scheme
*/
void ParseAtScheme(in string i_Spec,
out string o_Scheme,
out string o_Username,
out string o_Password,
out string o_Host,
out long o_Port,
out string o_Path);
/**
* Parses a URL and thinks it is parsing the prehost
*/
void ParseAtPreHost(in string i_Spec,
out string o_Username,
out string o_Password,
out string o_Host,
out long o_Port,
out string o_Path);
/**
* Parses a URL and thinks it is parsing the host
*/
void ParseAtHost(in string i_Spec,
out string o_Host,
out long o_Port,
out string o_Path);
/**
* Parses a URL and thinks it is parsing the port
*/
void ParseAtPort(in string i_Spec,
out long o_Port,
out string o_Path);
/**
* Parses a URL and thinks it is parsing the path
*/
void ParseAtPath(in string i_Spec,
out string o_Path);
/**
* Parses a URL-path and thinks it is parsing the directory
*/
void ParseAtDirectory(in string i_Path,
out string o_Directory,
out string o_FileBaseName,
out string o_FileExtension,
out string o_Param,
out string o_Query,
out string o_Ref);
/**
* Parses the URL-PreHost into its components
*/
void ParsePreHost(in string i_PreHost,
out string o_Username,
out string o_Password);
/**
* Parses the URL-Filename into its components
*/
void ParseFileName(in string i_FileName,
out string o_FileBaseName,
out string o_FileExtension);
};
%{C++
#define NS_NOAUTHORITYURLPARSER_CID \
{ /* 9eeb1b89-c87e-4404-9de6-dbd41aeaf3d7 */ \
0x9eeb1b89, \
0xc87e, \
0x4404, \
{0x9d, 0xe6, 0xdb, 0xd4, 0x1a, 0xea, 0xf3, 0xd7} \
}
#define NS_AUTHORITYURLPARSER_CID \
{ /* 90012125-1616-4fa1-ae14-4e7fa5766eb6 */ \
0x90012125, \
0x1616, \
0x4fa1, \
{0xae, 0x14, 0x4e, 0x7f, 0xa5, 0x76, 0x6e, 0xb6} \
}
%}

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

@ -29,16 +29,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = necko
LIBRARY_NAME = neckobase_s
EXPORTS = \
nsAuthURLParser.h \
nsNoAuthURLParser.h \
$(NULL)
CPPSRCS = \
nsURLHelper.cpp \
nsStdURLParser.cpp \
nsAuthURLParser.cpp \
nsNoAuthURLParser.cpp \
nsAsyncStreamListener.cpp \
nsSyncStreamListener.cpp \
nsIOService.cpp \
@ -62,3 +53,4 @@ override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

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

@ -27,10 +27,6 @@ LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
LIBRARY_NAME=neckobase_s
CPP_OBJS = \
.\$(OBJDIR)\nsURLHelper.obj \
.\$(OBJDIR)\nsStdURLParser.obj \
.\$(OBJDIR)\nsAuthURLParser.obj \
.\$(OBJDIR)\nsNoAuthURLParser.obj \
.\$(OBJDIR)\nsAsyncStreamListener.obj \
.\$(OBJDIR)\nsSyncStreamListener.obj \
.\$(OBJDIR)\nsIOService.obj \
@ -48,11 +44,6 @@ CPP_OBJS = \
.\$(OBJDIR)\nsUnicharStreamLoader.obj \
$(NULL)
EXPORTS = \
nsAuthURLParser.h \
nsNoAuthURLParser.h \
$(NULL)
INCS = $(INCS) \
-I$(DEPTH)\dist\include \
$(NULL)

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

@ -1,436 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte.
*
* Contributor(s):
*/
#include "nsAuthURLParser.h"
#include "nsURLHelper.h"
#include "nsCRT.h"
#include "nsString.h"
#include "prprf.h"
NS_IMPL_ISUPPORTS1(nsAuthURLParser,
nsIURLParser)
nsAuthURLParser::~nsAuthURLParser()
{
}
NS_METHOD
nsAuthURLParser::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsAuthURLParser* p = new nsAuthURLParser();
if (p == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(p);
nsresult rv = p->QueryInterface(aIID, aResult);
NS_RELEASE(p);
return rv;
}
nsresult
nsAuthURLParser::ParseAtScheme(const char* i_Spec, char* *o_Scheme,
char* *o_Username, char* *o_Password,
char* *o_Host, PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
NS_PRECONDITION( (nsnull != i_Spec), "Parse called on empty url!");
if (!i_Spec)
return NS_ERROR_MALFORMED_URI;
int len = PL_strlen(i_Spec);
if (len >= 2 && *i_Spec == '/' && *(i_Spec+1) == '/') // No Scheme
{
rv = ParseAtPreHost(i_Spec, o_Username, o_Password, o_Host, o_Port,
o_Path);
return rv;
}
static const char delimiters[] = "/:@?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a host
{
rv = ExtractString((char*)i_Spec, o_Host, len);
return rv;
} else
len = PL_strlen(brk);
switch (*brk)
{
case '/' :
case '?' :
// If the URL starts with a slash then everything is a path
if (brk == i_Spec)
{
rv = ParseAtPath(brk, o_Path);
return rv;
}
else // The first part is host, so its host/path
{
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPath(brk, o_Path);
return rv;
}
break;
case ':' :
if (len >= 2 && *(brk+1) == '/') {
// Standard http://... or malformed http:/...
rv = ExtractString((char*)i_Spec, o_Scheme, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPreHost(brk+1, o_Username, o_Password, o_Host,
o_Port, o_Path);
return rv;
} else {
// Could be host:port, so try conversion to number
PRInt32 port = ExtractPortFrom(brk+1);
if (port > 0)
{
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPort(brk+1, o_Port, o_Path);
return rv;
} else {
// No, it's not a number try scheme:host...
rv = ExtractString((char*)i_Spec, o_Scheme,
(brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPreHost(brk+1, o_Username, o_Password, o_Host,
o_Port, o_Path);
return rv;
}
}
break;
case '@' :
rv = ParseAtPreHost(i_Spec, o_Username, o_Password, o_Host,
o_Port, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsAuthURLParser::ParseAtPreHost(const char* i_Spec, char* *o_Username,
char* *o_Password, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
// Skip leading two slashes
char* fwdPtr= (char*) i_Spec;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
// Search for @
static const char delimiters[] = "@";
char* brk = PL_strpbrk(fwdPtr, delimiters);
if (brk)
{
char* e_PreHost = nsnull;
rv = ExtractString(fwdPtr, &e_PreHost, (brk - fwdPtr));
if (NS_FAILED(rv)) {
CRTFREEIF(e_PreHost);
return rv;
}
rv = ParsePreHost(e_PreHost,o_Username,o_Password);
CRTFREEIF(e_PreHost);
if (NS_FAILED(rv))
return rv;
rv = ParseAtHost(brk+1, o_Host, o_Port, o_Path);
} else {
rv = ParseAtHost(fwdPtr, o_Host, o_Port, o_Path);
}
return rv;
}
nsresult
nsAuthURLParser::ParseAtHost(const char* i_Spec, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
int len = PL_strlen(i_Spec);
static const char delimiters[] = ":/?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a host
{
rv = ExtractString((char*)i_Spec, o_Host, len);
return rv;
}
switch (*brk)
{
case '/' :
case '?' :
// Get the Host, the rest is Path
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPath(brk, o_Path);
return rv;
break;
case ':' :
// Get the Host
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPort(brk+1, o_Port, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsAuthURLParser::ParseAtPort(const char* i_Spec, PRInt32 *o_Port,
char* *o_Path)
{
nsresult rv = NS_OK;
static const char delimiters[] = "/?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a Port
{
*o_Port = ExtractPortFrom(i_Spec);
if (*o_Port <= 0)
return NS_ERROR_MALFORMED_URI;
else
return NS_OK;
}
switch (*brk)
{
case '/' :
case '?' :
// Get the Port, the rest is Path
*o_Port = ExtractPortFrom(i_Spec);
if (*o_Port <= 0)
return NS_ERROR_MALFORMED_URI;
rv = ParseAtPath(brk, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsAuthURLParser::ParseAtPath(const char* i_Spec, char* *o_Path)
{
// Just write the path and check for a starting /
nsAutoString dir;
if ('/' != *i_Spec)
dir += "/";
dir += i_Spec;
*o_Path = dir.ToNewCString();
return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
nsresult
nsAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory,
char* *o_FileBaseName, char* *o_FileExtension,
char* *o_Param, char* *o_Query, char* *o_Ref)
{
// Cleanout
CRTFREEIF(*o_Directory);
CRTFREEIF(*o_FileBaseName);
CRTFREEIF(*o_FileExtension);
CRTFREEIF(*o_Param);
CRTFREEIF(*o_Query);
CRTFREEIF(*o_Ref);
nsresult rv = NS_OK;
// Parse the Path into its components
if (!i_Path)
{
DupString(o_Directory, "/");
return (o_Directory ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
char* dirfile = nsnull;
char* options = nsnull;
int len = PL_strlen(i_Path);
/* Factor out the optionpart with ;?# */
static const char delimiters[] = ";?#"; // for param, query and ref
char* brk = PL_strpbrk(i_Path, delimiters);
if (!brk) // Everything is just path and filename
{
DupString(&dirfile, i_Path);
}
else
{
int dirfileLen = brk - i_Path;
ExtractString((char*)i_Path, &dirfile, dirfileLen);
len -= dirfileLen;
ExtractString((char*)i_Path + dirfileLen, &options, len);
brk = options;
}
/* now that we have broken up the path treat every part differently */
/* first dir+file */
char* file;
int dlen = PL_strlen(dirfile);
if (dlen == 0)
{
DupString(o_Directory, "/");
file = dirfile;
} else {
CoaleseDirs(dirfile);
// Get length again
dlen = PL_strlen(dirfile);
// First find the last slash
file = PL_strrchr(dirfile, '/');
if (!file)
{
DupString(o_Directory, "/");
file = dirfile;
}
// If its not the same as the first slash then extract directory
if (file != dirfile)
{
ExtractString(dirfile, o_Directory, (file - dirfile)+1);
} else {
DupString(o_Directory, "/");
}
}
/* Extract FileBaseName and FileExtension */
if (dlen > 0) {
// Look again if there was a slash
char* slash = PL_strrchr(dirfile, '/');
char* e_FileName = nsnull;
if (slash) {
ExtractString(file+1, &e_FileName, dlen-(slash-dirfile+1));
} else {
// Use the full String as Filename
ExtractString(dirfile, &e_FileName, dlen);
}
rv = ParseFileName(e_FileName,o_FileBaseName,o_FileExtension);
CRTFREEIF(e_FileName);
}
// Now take a look at the options. "#" has precedence over "?"
// which has precedence over ";"
if (options) {
// Look for "#" first. Everything following it is in the ref
brk = PL_strchr(options, '#');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Ref, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
// Now look for "?"
brk = PL_strchr(options, '?');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Query, pieceLen);
len -= pieceLen + 1;
}
// Now look for ';'
brk = PL_strchr(options, ';');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Param, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
}
nsCRT::free(dirfile);
nsCRT::free(options);
return rv;
}
nsresult
nsAuthURLParser::ParsePreHost(const char* i_PreHost, char* *o_Username,
char* *o_Password)
{
nsresult rv = NS_OK;
// Search for :
static const char delimiters[] = ":";
char* brk = PL_strpbrk(i_PreHost, delimiters);
if (brk)
{
rv = ExtractString((char*)i_PreHost, o_Username, (brk - i_PreHost));
if (NS_FAILED(rv))
return rv;
rv = ExtractString(brk+1, o_Password,
(i_PreHost+PL_strlen(i_PreHost) - brk - 1));
} else {
CRTFREEIF(*o_Password);
rv = DupString(o_Username, i_PreHost);
}
return rv;
}
nsresult
nsAuthURLParser::ParseFileName(const char* i_FileName, char* *o_FileBaseName,
char* *o_FileExtension)
{
nsresult rv = NS_OK;
// Search for FileExtension
// Search for last .
// Ignore . at the beginning
char* brk = PL_strrchr(i_FileName+1, '.');
if (brk)
{
rv = ExtractString((char*)i_FileName, o_FileBaseName,
(brk - i_FileName));
if (NS_FAILED(rv))
return rv;
rv = ExtractString(brk + 1, o_FileExtension,
(i_FileName+PL_strlen(i_FileName) - brk - 1));
} else {
rv = DupString(o_FileBaseName, i_FileName);
}
return rv;
}

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

@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsAuthURLParser_h__
#define nsAuthURLParser_h__
#include "nsIURLParser.h"
#include "nsIURI.h"
#include "nsAgg.h"
#include "nsCRT.h"
class nsAuthURLParser : public nsIURLParser
{
public:
NS_DECL_ISUPPORTS
///////////////////////////////////////////////////////////////////////////
// nsAuthURLParser methods:
nsAuthURLParser() {
NS_INIT_REFCNT();
}
virtual ~nsAuthURLParser();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
///////////////////////////////////////////////////////////////////////////
// nsIURLParser methods:
NS_DECL_NSIURLPARSER
};
#endif // nsAuthURLParser_h__

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

@ -411,16 +411,4 @@ nsIOService::SetOffline(PRBool offline)
return NS_OK;
}
NS_IMETHODIMP
nsIOService::URLEscape(const char* str, PRInt16 mask, char **result)
{
return nsURLEscape((char*)str,mask,result);
}
NS_IMETHODIMP
nsIOService::URLUnescape(const char* str, char **result)
{
return nsURLUnescape((char*)str,result);
}
////////////////////////////////////////////////////////////////////////////////

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

@ -25,7 +25,6 @@
#include "nsIIOService.h"
#include "nsString2.h"
#include "nsURLHelper.h"
class nsIOService : public nsIIOService
{

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

@ -1,301 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte.
*
* Contributor(s):
*/
#include "nsNoAuthURLParser.h"
#include "nsURLHelper.h"
#include "nsCRT.h"
#include "nsString.h"
#include "prprf.h"
NS_IMPL_ISUPPORTS1(nsNoAuthURLParser,
nsIURLParser)
nsNoAuthURLParser::~nsNoAuthURLParser()
{
}
NS_METHOD
nsNoAuthURLParser::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsNoAuthURLParser* p = new nsNoAuthURLParser();
if (p == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(p);
nsresult rv = p->QueryInterface(aIID, aResult);
NS_RELEASE(p);
return rv;
}
nsresult
nsNoAuthURLParser::ParseAtScheme(const char* i_Spec, char* *o_Scheme,
char* *o_Username, char* *o_Password,
char* *o_Host, PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
NS_PRECONDITION( (nsnull != i_Spec), "Parse called on empty url!");
if (!i_Spec)
return NS_ERROR_MALFORMED_URI;
int len = PL_strlen(i_Spec);
if (len >= 2 && *i_Spec == '/' && *(i_Spec+1) == '/') // No Scheme
{
rv = ParseAtPreHost(i_Spec, o_Username, o_Password, o_Host, o_Port,
o_Path);
return rv;
}
static const char delimiters[] = ":"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a path
{
rv = ParseAtPath((char*)i_Spec, o_Path);
return rv;
}
switch (*brk)
{
case ':' :
rv = ExtractString((char*)i_Spec, o_Scheme, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPreHost(brk+1, o_Username, o_Password, o_Host,
o_Port, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsNoAuthURLParser::ParseAtPreHost(const char* i_Spec, char* *o_Username,
char* *o_Password, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
// Skip leading two slashes
char* fwdPtr= (char*) i_Spec;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
// There is no PreHost
rv = ParseAtHost(fwdPtr, o_Host, o_Port, o_Path);
return rv;
}
nsresult
nsNoAuthURLParser::ParseAtHost(const char* i_Spec, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
// There is no Host
rv = ParseAtPath(i_Spec, o_Path);
return rv;
}
nsresult
nsNoAuthURLParser::ParseAtPort(const char* i_Spec, PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
// There is no Port
rv = ParseAtPath(i_Spec, o_Path);
return NS_OK;
}
nsresult
nsNoAuthURLParser::ParseAtPath(const char* i_Spec, char* *o_Path)
{
// Just write the path and check for a starting /
nsAutoString dir;
if ('/' != *i_Spec)
dir += "/";
dir += i_Spec;
*o_Path = dir.ToNewCString();
return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
nsresult
nsNoAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory,
char* *o_FileBaseName, char* *o_FileExtension,
char* *o_Param, char* *o_Query, char* *o_Ref)
{
// Cleanout
CRTFREEIF(*o_Directory);
CRTFREEIF(*o_FileBaseName);
CRTFREEIF(*o_FileExtension);
CRTFREEIF(*o_Param);
CRTFREEIF(*o_Query);
CRTFREEIF(*o_Ref);
nsresult rv = NS_OK;
// Parse the Path into its components
if (!i_Path)
{
DupString(o_Directory, "/");
return (o_Directory ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
char* dirfile = nsnull;
char* options = nsnull;
int len = PL_strlen(i_Path);
/* Factor out the optionpart with ;?# */
static const char delimiters[] = ";?#"; // for param, query and ref
char* brk = PL_strpbrk(i_Path, delimiters);
if (!brk) // Everything is just path and filename
{
DupString(&dirfile, i_Path);
}
else
{
int dirfileLen = brk - i_Path;
ExtractString((char*)i_Path, &dirfile, dirfileLen);
len -= dirfileLen;
ExtractString((char*)i_Path + dirfileLen, &options, len);
brk = options;
}
/* now that we have broken up the path treat every part differently */
/* first dir+file */
char* file;
int dlen = PL_strlen(dirfile);
if (dlen == 0)
{
DupString(o_Directory, "/");
file = dirfile;
} else {
CoaleseDirs(dirfile);
// Get length again
dlen = PL_strlen(dirfile);
// First find the last slash
file = PL_strrchr(dirfile, '/');
if (!file)
{
DupString(o_Directory, "/");
file = dirfile;
}
// If its not the same as the first slash then extract directory
if (file != dirfile)
{
ExtractString(dirfile, o_Directory, (file - dirfile)+1);
} else {
DupString(o_Directory, "/");
}
}
/* Extract FileBaseName and FileExtension */
if (dlen > 0) {
// Look again if there was a slash
char* slash = PL_strrchr(dirfile, '/');
char* e_FileName = nsnull;
if (slash) {
ExtractString(file+1, &e_FileName, dlen-(slash-dirfile+1));
} else {
// Use the full String as Filename
ExtractString(dirfile, &e_FileName, dlen);
}
rv = ParseFileName(e_FileName,o_FileBaseName,o_FileExtension);
CRTFREEIF(e_FileName);
}
// Now take a look at the options. "#" has precedence over "?"
// which has precedence over ";"
if (options) {
// Look for "#" first. Everything following it is in the ref
brk = PL_strchr(options, '#');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Ref, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
// Now look for "?"
brk = PL_strchr(options, '?');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Query, pieceLen);
len -= pieceLen + 1;
}
// Now look for ';'
brk = PL_strchr(options, ';');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Param, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
}
nsCRT::free(dirfile);
nsCRT::free(options);
return rv;
}
nsresult
nsNoAuthURLParser::ParsePreHost(const char* i_PreHost, char* *o_Username,
char* *o_Password)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsNoAuthURLParser::ParseFileName(const char* i_FileName,
char* *o_FileBaseName,
char* *o_FileExtension)
{
nsresult rv = NS_OK;
// Search for FileExtension
// Search for last .
// Ignore . at the beginning
char* brk = PL_strrchr(i_FileName+1, '.');
if (brk)
{
rv = ExtractString((char*)i_FileName, o_FileBaseName,
(brk - i_FileName));
if (NS_FAILED(rv))
return rv;
rv = ExtractString(brk + 1, o_FileExtension,
(i_FileName+PL_strlen(i_FileName) - brk - 1));
} else {
rv = DupString(o_FileBaseName, i_FileName);
}
return rv;
}

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

@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsNoAuthURLParser_h__
#define nsNoAuthURLParser_h__
#include "nsIURLParser.h"
#include "nsIURI.h"
#include "nsAgg.h"
#include "nsCRT.h"
class nsNoAuthURLParser : public nsIURLParser
{
public:
NS_DECL_ISUPPORTS
///////////////////////////////////////////////////////////////////////////
// nsNoAuthURLParser methods:
nsNoAuthURLParser() {
NS_INIT_REFCNT();
}
virtual ~nsNoAuthURLParser();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
///////////////////////////////////////////////////////////////////////////
// nsIURLParser methods:
NS_DECL_NSIURLPARSER
};
#endif // nsNoAuthURLParser_h__

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

@ -27,7 +27,6 @@
#include "nsString.h"
#include "prmem.h"
#include "prprf.h"
#include "nsURLHelper.h"
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
@ -143,30 +142,6 @@ nsSimpleURI::SetPreHost(const char* preHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetUsername(char* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetUsername(const char* userName)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetPassword(char* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetPassword(const char* password)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetHost(char* *result)
{
@ -206,18 +181,6 @@ nsSimpleURI::SetPath(const char* path)
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetURLParser(nsIURLParser* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetURLParser(nsIURLParser* URLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::Equals(nsIURI* other, PRBool *result)
{
@ -266,7 +229,8 @@ nsSimpleURI::SetRelativePath(const char *i_RelativePath)
NS_IMETHODIMP
nsSimpleURI::Resolve(const char *relativePath, char **result)
{
return DupString(result,(char*)relativePath);
NS_ASSERTION(PR_FALSE, "This is meaningless in hack context!");
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////////////

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -24,8 +24,6 @@
#define nsStdURL_h__
#include "nsIURL.h"
#include "nsIURLParser.h"
#include "nsURLHelper.h"
#include "nsAgg.h"
#include "nsCRT.h"
#include "nsString.h" // REMOVE Later!!
@ -41,10 +39,9 @@
class nsStdURL : public nsIURL
{
public:
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// nsStdURL methods:
nsStdURL();
nsStdURL(const char* i_Spec, nsISupports* outer=nsnull);
nsStdURL(const nsStdURL& i_URL);
virtual ~nsStdURL();
@ -57,67 +54,156 @@ public:
NS_DECL_AGGREGATED
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// nsIURI methods:
NS_DECL_NSIURI
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// nsIURL methods:
NS_DECL_NSIURL
protected:
enum Format { ESCAPED, UNESCAPED };
nsresult Parse(const char* i_Spec);
nsresult AppendString(nsCString& buffer, char* fromUnescapedStr,
Format toFormat, PRInt16 mask);
nsresult GetString(char** result, char* fromEscapedStr,
Format toFormat);
nsresult AppendPreHost(nsCString& buffer, char* i_Username,
char* i_Password, Format toFormat);
nsresult AppendFileName(nsCString& buffer, char* i_FileBaseName,
char* i_FileExtension, Format toFormat);
/* todo move this to protected later */
nsresult ParsePath(void);
protected:
nsresult Parse(void);
nsresult ReconstructPath(void);
nsresult ReconstructSpec(void);
// Some handy functions
nsresult DupString(char* *o_Dest, const char* i_Src);
nsresult ExtractString(char* i_Src, char* *o_Dest, PRUint32 length);
protected:
char* mScheme;
char* mUsername;
char* mPassword;
char* mPreHost;
char* mHost;
PRInt32 mPort;
char* mPath;
char* mDirectory;
char* mFileBaseName;
char* mFileExtension;
char* mFileName;
char* mParam;
char* mQuery;
char* mRef;
nsIURLParser* mURLParser;
char* mSpec;
};
inline NS_METHOD
nsStdURL::GetSpec(char* *o_Spec)
{
return DupString(o_Spec, mSpec);
}
inline NS_METHOD
nsStdURL::GetScheme(char* *o_Scheme)
{
return GetString(o_Scheme, mScheme, UNESCAPED);
return DupString(o_Scheme, mScheme);
}
inline NS_METHOD
nsStdURL::GetUsername(char* *o_Username)
nsStdURL::GetPreHost(char* *o_PreHost)
{
return GetString(o_Username, mUsername, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetPassword(char* *o_Password)
{
return GetString(o_Password, mPassword, UNESCAPED);
return DupString(o_PreHost, mPreHost);
}
inline NS_METHOD
nsStdURL::GetHost(char* *o_Host)
{
return GetString(o_Host, mHost, UNESCAPED);
return DupString(o_Host, mHost);
}
inline NS_METHOD
nsStdURL::GetPath(char* *o_Path)
{
return DupString(o_Path, mPath);
}
inline NS_METHOD
nsStdURL::GetDirectory(char* *o_Directory)
{
return DupString(o_Directory, mDirectory);
}
inline NS_METHOD
nsStdURL::GetFileName(char* *o_FileName)
{
return DupString(o_FileName, mFileName);
}
inline NS_METHOD
nsStdURL::GetFileExtension(char* *o_FileExtension)
{
if (!o_FileExtension)
return NS_ERROR_NULL_POINTER;
char *dot = mFileName;
if (dot) {
// find the last dot
while (*dot) dot++;
while ( (dot != mFileName) && (*dot != '.') ) dot--; // goto the dot.
if (*dot == '.') {
nsCAutoString ext(dot+1);
*o_FileExtension = ext.ToNewCString();
if (!*o_FileExtension) return NS_ERROR_OUT_OF_MEMORY;
} else {
*o_FileExtension = nsnull;
}
}
return NS_OK;
}
inline NS_METHOD
nsStdURL::SetFileExtension(const char* FileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
inline NS_METHOD
nsStdURL::GetRef(char* *o_Ref)
{
return DupString(o_Ref, mRef);
}
inline NS_METHOD
nsStdURL::GetParam(char **o_Param)
{
return DupString(o_Param, mParam);
}
inline NS_METHOD
nsStdURL::GetQuery(char* *o_Query)
{
return DupString(o_Query, mQuery);
}
inline NS_METHOD
nsStdURL::SetScheme(const char* i_Scheme)
{
if (mScheme) nsCRT::free(mScheme);
nsresult status = DupString(&mScheme, i_Scheme);
ReconstructSpec();
return status;
}
inline NS_METHOD
nsStdURL::SetPreHost(const char* i_PreHost)
{
if (mPreHost) nsCRT::free(mPreHost);
nsresult status = DupString(&mPreHost, i_PreHost);
ReconstructSpec();
return status;
}
inline NS_METHOD
nsStdURL::SetHost(const char* i_Host)
{
if (mHost) nsCRT::free(mHost);
nsresult status = DupString(&mHost, i_Host);
ReconstructSpec();
return status;
}
inline NS_METHOD
@ -131,84 +217,12 @@ nsStdURL::GetPort(PRInt32 *aPort)
return NS_ERROR_NULL_POINTER;
}
inline NS_METHOD
nsStdURL::GetFileBaseName(char* *o_FileBaseName)
{
return GetString(o_FileBaseName, mFileBaseName, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetFileExtension(char* *o_FileExtension)
{
return GetString(o_FileExtension, mFileExtension, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetParam(char **o_Param)
{
return GetString(o_Param, mParam, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetQuery(char* *o_Query)
{
return GetString(o_Query, mQuery, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetRef(char* *o_Ref)
{
return GetString(o_Ref, mRef, UNESCAPED);
}
inline NS_METHOD
nsStdURL::SetScheme(const char* i_Scheme)
{
CRTFREEIF(mScheme);
return DupString(&mScheme, i_Scheme);
}
inline NS_METHOD
nsStdURL::SetUsername(const char* i_Username)
{
CRTFREEIF(mUsername);
return DupString(&mUsername, i_Username);
}
inline NS_METHOD
nsStdURL::SetPassword(const char* i_Password)
{
CRTFREEIF(mPassword);
return DupString(&mPassword, i_Password);
}
inline NS_METHOD
nsStdURL::SetHost(const char* i_Host)
{
CRTFREEIF(mHost);
return DupString(&mHost, i_Host);
}
inline NS_METHOD
nsStdURL::SetPort(PRInt32 aPort)
{
mPort = aPort;
ReconstructSpec();
return NS_OK;
}
inline NS_METHOD
nsStdURL::SetFileBaseName(const char* i_FileBaseName)
{
CRTFREEIF(mFileBaseName);
return DupString(&mFileBaseName, i_FileBaseName);
}
inline NS_METHOD
nsStdURL::SetFileExtension(const char* i_FileExtension)
{
CRTFREEIF(mFileExtension);
return DupString(&mFileExtension, i_FileExtension);
}
#endif // nsStdURL_h__

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

@ -1,463 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte.
*
* Contributor(s):
*/
#include "nsStdURLParser.h"
#include "nsURLHelper.h"
#include "nsCRT.h"
#include "nsString.h"
#include "prprf.h"
NS_IMPL_ISUPPORTS1(nsStdURLParser,
nsIURLParser)
nsStdURLParser::~nsStdURLParser()
{
}
NS_METHOD
nsStdURLParser::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsStdURLParser* p = new nsStdURLParser();
if (p == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(p);
nsresult rv = p->QueryInterface(aIID, aResult);
NS_RELEASE(p);
return rv;
}
nsresult
nsStdURLParser::ParseAtScheme(const char* i_Spec, char* *o_Scheme,
char* *o_Username,
char* *o_Password,
char* *o_Host, PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
NS_PRECONDITION( (nsnull != i_Spec), "Parse called on empty url!");
if (!i_Spec)
return NS_ERROR_MALFORMED_URI;
int len = PL_strlen(i_Spec);
if (len >= 2 && *i_Spec == '/' && *(i_Spec+1) == '/') // No Scheme
{
rv = ParseAtPreHost(i_Spec, o_Username, o_Password, o_Host, o_Port,
o_Path);
return rv;
}
static const char delimiters[] = "/:@?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a host
{
rv = ExtractString((char*)i_Spec, o_Host, len);
return rv;
} else
len = PL_strlen(brk);
switch (*brk)
{
case '/' :
case '?' :
// If the URL starts with a slash then everything is a path
if (brk == i_Spec)
{
rv = ParseAtPath(brk, o_Path);
return rv;
}
else // The first part is host, so its host/path
{
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPath(brk, o_Path);
return rv;
}
break;
case ':' :
if (len >= 2 && *(brk+1) == '/' && *(brk+2) == '/') {
// Standard http://...
rv = ExtractString((char*)i_Spec, o_Scheme, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPreHost(brk+1, o_Username, o_Password, o_Host,
o_Port, o_Path);
if (rv == NS_ERROR_MALFORMED_URI) {
// or not ? Try something else
CRTFREEIF(*o_Username);
CRTFREEIF(*o_Password);
CRTFREEIF(*o_Host);
*o_Port = -1;
rv = ParseAtPath(brk+3, o_Path);
}
return rv;
} else {
if ( len >= 2 && *(brk+1) == '/' && *(brk+2) != '/') {
// May be it is file:/....
rv = ExtractString((char*)i_Spec, o_Scheme, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPath(brk+1, o_Path);
return rv;
} else {
// Could be host:port, so try conversion to number
PRInt32 port = ExtractPortFrom(brk+1);
if (port <= 0)
{
// No, try normal procedure
rv = ExtractString((char*)i_Spec, o_Scheme,
(brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPreHost(brk+1, o_Username, o_Password, o_Host,
o_Port, o_Path);
if (rv == NS_ERROR_MALFORMED_URI) {
// Try something else
CRTFREEIF(*o_Username);
CRTFREEIF(*o_Password);
CRTFREEIF(*o_Host);
*o_Port = -1;
rv = ParseAtPath(brk+1, o_Path);
}
return rv;
} else {
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPort(brk+1, o_Port, o_Path);
return rv;
}
}
}
break;
case '@' :
rv = ParseAtPreHost(i_Spec, o_Username, o_Password, o_Host,
o_Port, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsStdURLParser::ParseAtPreHost(const char* i_Spec, char* *o_Username,
char* *o_Password, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
// Skip leading two slashes
char* fwdPtr= (char*) i_Spec;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
if (fwdPtr && (*fwdPtr != '\0') && (*fwdPtr == '/'))
fwdPtr++;
// Search for @
static const char delimiters[] = "@";
char* brk = PL_strpbrk(fwdPtr, delimiters);
if (brk)
{
char* e_PreHost = nsnull;
rv = ExtractString(fwdPtr, &e_PreHost, (brk - fwdPtr));
if (NS_FAILED(rv)) {
CRTFREEIF(e_PreHost);
return rv;
}
rv = ParsePreHost(e_PreHost,o_Username,o_Password);
CRTFREEIF(e_PreHost);
if (NS_FAILED(rv))
return rv;
rv = ParseAtHost(brk+1, o_Host, o_Port, o_Path);
return rv;
} else {
rv = ParseAtHost(fwdPtr, o_Host, o_Port, o_Path);
return rv;
}
return NS_OK;
}
nsresult
nsStdURLParser::ParseAtHost(const char* i_Spec, char* *o_Host,
PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
int len = PL_strlen(i_Spec);
static const char delimiters[] = ":/?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a host
{
rv = ExtractString((char*)i_Spec, o_Host, len);
return rv;
}
switch (*brk)
{
case '/' :
case '?' :
// Get the Host, the rest is Path
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPath(brk, o_Path);
return rv;
break;
case ':' :
// Get the Host
rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec));
if (NS_FAILED(rv))
return rv;
rv = ParseAtPort(brk+1, o_Port, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsStdURLParser::ParseAtPort(const char* i_Spec, PRInt32 *o_Port, char* *o_Path)
{
nsresult rv = NS_OK;
static const char delimiters[] = "/?"; //this order is optimized.
char* brk = PL_strpbrk(i_Spec, delimiters);
if (!brk) // everything is a Port
{
*o_Port = ExtractPortFrom(i_Spec);
if (*o_Port <= 0)
return NS_ERROR_MALFORMED_URI;
else
return NS_OK;
}
switch (*brk)
{
case '/' :
case '?' :
// Get the Port, the rest is Path
*o_Port = ExtractPortFrom(i_Spec);
if (*o_Port <= 0)
return NS_ERROR_MALFORMED_URI;
rv = ParseAtPath(brk, o_Path);
return rv;
break;
default:
NS_ASSERTION(0, "This just can't be!");
break;
}
return NS_OK;
}
nsresult
nsStdURLParser::ParseAtPath(const char* i_Spec, char* *o_Path)
{
// Just write the path and check for a starting /
nsAutoString dir;
if ('/' != *i_Spec)
dir += "/";
dir += i_Spec;
*o_Path = dir.ToNewCString();
return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
nsresult
nsStdURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory,
char* *o_FileBaseName, char* *o_FileExtension,
char* *o_Param, char* *o_Query, char* *o_Ref)
{
// Cleanout
CRTFREEIF(*o_Directory);
CRTFREEIF(*o_FileBaseName);
CRTFREEIF(*o_FileExtension);
CRTFREEIF(*o_Param);
CRTFREEIF(*o_Query);
CRTFREEIF(*o_Ref);
nsresult rv = NS_OK;
// Parse the Path into its components
if (!i_Path)
{
DupString(o_Directory, "/");
return (o_Directory ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
char* dirfile = nsnull;
char* options = nsnull;
int len = PL_strlen(i_Path);
/* Factor out the optionpart with ;?# */
static const char delimiters[] = ";?#"; // for param, query and ref
char* brk = PL_strpbrk(i_Path, delimiters);
if (!brk) // Everything is just path and filename
{
DupString(&dirfile, i_Path);
}
else
{
int dirfileLen = brk - i_Path;
ExtractString((char*)i_Path, &dirfile, dirfileLen);
len -= dirfileLen;
ExtractString((char*)i_Path + dirfileLen, &options, len);
brk = options;
}
/* now that we have broken up the path treat every part differently */
/* first dir+file */
char* file= nsnull;
int dlen = PL_strlen(dirfile);
if (dlen == 0)
{
DupString(o_Directory, "/");
file = dirfile;
} else {
CoaleseDirs(dirfile);
// Get length again
dlen = PL_strlen(dirfile);
// First find the last slash
file = PL_strrchr(dirfile, '/');
if (!file)
{
DupString(o_Directory, "/");
file = dirfile;
}
// If its not the same as the first slash then extract directory
if (file != dirfile)
{
ExtractString(dirfile, o_Directory, (file - dirfile)+1);
} else {
DupString(o_Directory, "/");
}
}
/* Extract FileBaseName and FileExtension */
if (dlen > 0) {
// Look again if there was a slash
char* slash = PL_strrchr(dirfile, '/');
char* e_FileName = nsnull;
if (slash) {
ExtractString(slash+1, &e_FileName, dlen-(slash-dirfile+1));
} else {
// Use the full String as Filename
ExtractString(dirfile, &e_FileName, dlen);
}
rv = ParseFileName(e_FileName,o_FileBaseName,o_FileExtension);
CRTFREEIF(e_FileName);
}
// Now take a look at the options. "#" has precedence over "?"
// which has precedence over ";"
if (options) {
// Look for "#" first. Everything following it is in the ref
brk = PL_strchr(options, '#');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Ref, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
// Now look for "?"
brk = PL_strchr(options, '?');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Query, pieceLen);
len -= pieceLen + 1;
}
// Now look for ';'
brk = PL_strchr(options, ';');
if (brk) {
int pieceLen = len - (brk + 1 - options);
ExtractString(brk+1, o_Param, pieceLen);
len -= pieceLen + 1;
*brk = '\0';
}
}
CRTFREEIF(dirfile);
CRTFREEIF(options);
return rv;
}
nsresult
nsStdURLParser::ParsePreHost(const char* i_PreHost, char* *o_Username,
char* *o_Password)
{
nsresult rv = NS_OK;
// Search for :
static const char delimiters[] = ":";
char* brk = PL_strpbrk(i_PreHost, delimiters);
if (brk)
{
rv = ExtractString((char*)i_PreHost, o_Username, (brk - i_PreHost));
if (NS_FAILED(rv))
return rv;
rv = ExtractString(brk+1, o_Password,
(i_PreHost+PL_strlen(i_PreHost) - brk - 1));
} else {
CRTFREEIF(*o_Password);
rv = DupString(o_Username, i_PreHost);
}
return rv;
}
nsresult
nsStdURLParser::ParseFileName(const char* i_FileName, char* *o_FileBaseName,
char* *o_FileExtension)
{
nsresult rv = NS_OK;
// Search for FileExtension
// Search for last .
// Ignore . at the beginning
char* brk = PL_strrchr(i_FileName+1, '.');
if (brk)
{
rv = ExtractString((char*)i_FileName, o_FileBaseName,
(brk - i_FileName));
if (NS_FAILED(rv))
return rv;
rv = ExtractString(brk + 1, o_FileExtension,
(i_FileName+PL_strlen(i_FileName) - brk - 1));
} else {
rv = DupString(o_FileBaseName, i_FileName);
}
return rv;
}

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

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsStdURLParser_h__
#define nsStdURLParser_h__
#include "nsIURLParser.h"
#include "nsIURI.h"
#include "nsAgg.h"
#include "nsCRT.h"
#define NS_STANDARDURLPARSER_CID \
{ /* dbf72351-4fd8-46f0-9dbc-fa5ba60a30c5 */ \
0xdbf72351, \
0x4fd8, \
0x46f0, \
{0x9d, 0xbc, 0xfa, 0x5b, 0xa6, 0x0a, 0x30, 0x5c} \
}
class nsStdURLParser : public nsIURLParser
{
public:
NS_DECL_ISUPPORTS
///////////////////////////////////////////////////////////////////////////
// nsStdURLParser methods:
nsStdURLParser() {
NS_INIT_REFCNT();
}
virtual ~nsStdURLParser();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
///////////////////////////////////////////////////////////////////////////
// nsIURLParser methods:
NS_DECL_NSIURLPARSER
};
#endif // nsStdURLParser_h__

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

@ -1,251 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte.
*
* Contributor(s):
*/
#include "nsURLHelper.h"
#include "prprf.h"
#include "nsCRT.h"
#include "nsIAllocator.h"
/* This array tells which chars has to be escaped */
const int EscapeChars[256] =
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */
0,1023, 0, 512, 0, 0,1023, 0,1023,1023,1023,1023,1023,1023, 959,1016, /* 2x !"#$%&'()*+,-./ */
1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896, 896, 0, 896, 0, 768, /* 3x 0123456789:;<=>? */
896,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, /* 4x @ABCDEFGHIJKLMNO */
1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896, 896, 896, 896,1023, /* 5x PQRSTUVWXYZ[\]^_ */
0,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, /* 6x `abcdefghijklmno */
1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896,1012, 896,1008, 0, /* 7x pqrstuvwxyz{|}~ */
0 /* 8x DEL */
};
/* decode % escaped hex codes into character values
*/
#define UNHEX(C) \
((C >= '0' && C <= '9') ? C - '0' : \
((C >= 'A' && C <= 'F') ? C - 'A' + 10 : \
((C >= 'a' && C <= 'f') ? C - 'a' + 10 : 0)))
/* check if char has to be escaped */
#define IS_OK(C) (EscapeChars[((unsigned int) (C))] & (mask))
/* HEX mask char */
#define HEX_ESCAPE '%'
/* returns an escaped string */
NS_NET nsresult
nsURLEscape(const char* str, PRInt16 mask, char **result)
{
if (!str)
return NS_OK;
int i, extra = 0;
char* hexChars = "0123456789ABCDEF";
static const char CheckHexChars[] = "0123456789ABCDEFabcdef";
int len = PL_strlen(str);
register const unsigned char* src = (const unsigned char *) str;
for (i = 0; i < len; i++)
{
if (!IS_OK(*src++)) {
extra += 2; /* the escape, plus an extra byte for each nibble */
}
}
*result = (char *)nsAllocator::Alloc(len + extra + 1);
if (!*result)
return NS_ERROR_OUT_OF_MEMORY;
register unsigned char* dst = (unsigned char *) *result;
src = (const unsigned char *) str;
for (i = 0; i < len; i++)
{
const char* checker = (char*) src;
unsigned char c = *src++;
/* if the char has not to be escaped or whatever follows % is
a valid escaped string, just copy the char */
if (IS_OK(c) || (c == HEX_ESCAPE && (checker+1) && (checker+2) &&
PL_strpbrk(((checker+1)), CheckHexChars) != 0 &&
PL_strpbrk(((checker+2)), CheckHexChars) != 0))
*dst++ = c;
else
/* do the escape magic */
{
*dst++ = HEX_ESCAPE;
*dst++ = hexChars[c >> 4]; /* high nibble */
*dst++ = hexChars[c & 0x0f]; /* low nibble */
}
}
*dst = '\0';
return NS_OK;
}
/* returns an unescaped string */
NS_NET nsresult
nsURLUnescape(char* str, char **result)
{
if (!str)
return NS_OK;
register char *src = str;
static const char hexChars[] = "0123456789ABCDEF";
int len = PL_strlen(str);
*result = (char *)nsAllocator::Alloc(len + 1);
if (!*result)
return NS_ERROR_OUT_OF_MEMORY;
src = str;
register unsigned char* dst = (unsigned char *) *result;
while (*src)
/* check for valid escaped sequence */
if (*src != HEX_ESCAPE || PL_strpbrk(((src+1)), hexChars) == 0 ||
PL_strpbrk(((src+2)), hexChars) == 0 )
*dst++ = *src++;
else
{
src++; /* walk over escape */
if (*src)
{
*dst = UNHEX(*src) << 4;
src++;
}
if (*src)
{
*dst = (*dst + UNHEX(*src));
src++;
}
dst++;
}
*dst = '\0';
return NS_OK;
}
/* extract portnumber from string */
NS_NET PRInt32
ExtractPortFrom(const char* src)
{
PRInt32 returnValue = -1;
return (0 < PR_sscanf(src, "%d", &returnValue)) ? returnValue : -1;
}
/* extract string from other string */
NS_NET nsresult
ExtractString(char* i_Src, char* *o_Dest, PRUint32 length)
{
NS_PRECONDITION( (nsnull != i_Src), "Extract called on empty string!");
CRTFREEIF(*o_Dest);
*o_Dest = PL_strndup(i_Src, length);
return (*o_Dest ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
}
/* duplicate string */
NS_NET nsresult
DupString(char* *o_Dest, const char* i_Src)
{
if (!o_Dest)
return NS_ERROR_NULL_POINTER;
if (i_Src)
{
*o_Dest = nsCRT::strdup(i_Src);
return (*o_Dest == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
else
{
*o_Dest = nsnull;
return NS_OK;
}
}
// Replace all /./ with a /
// Also changes all \ to /
// But only till #?;
NS_NET void
CoaleseDirs(char* io_Path)
{
/* Stolen from the old netlib's mkparse.c.
*
* modifies a url of the form /foo/../foo1 -> /foo1
* and /foo/./foo1 -> /foo/foo1
* and /foo/foo1/.. -> /foo/
*/
char *fwdPtr = io_Path;
char *urlPtr = io_Path;
for(; (*fwdPtr != '\0') &&
(*fwdPtr != ';') &&
(*fwdPtr != '?') &&
(*fwdPtr != '#'); ++fwdPtr)
{
if (*fwdPtr == '\\')
*fwdPtr = '/';
if (*fwdPtr == '/' && *(fwdPtr+1) == '.' &&
(*(fwdPtr+2) == '/' || *(fwdPtr+2) == '\\'))
{
// remove . followed by slash or a backslash
fwdPtr += 1;
}
else if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '.' &&
(*(fwdPtr+3) == '/' ||
*(fwdPtr+3) == '\0' ||
*(fwdPtr+3) == ';' || // This will take care of likes of
*(fwdPtr+3) == '?' || // foo/bar/..#sometag
*(fwdPtr+3) == '#' ||
*(fwdPtr+3) == '\\'))
{
// remove foo/..
// reverse the urlPtr to the previous slash
if(urlPtr != io_Path)
urlPtr--; // we must be going back at least by one
for(;*urlPtr != '/' && urlPtr != io_Path; urlPtr--)
; // null body
// forward the fwd_prt past the ../
fwdPtr += 2;
// special case if we have reached the end to preserve the last /
if (*fwdPtr == '.' && *(fwdPtr+1) == '\0')
urlPtr +=1;
}
else
{
// copy the url incrementaly
*urlPtr++ = *fwdPtr;
}
}
// Copy remaining stuff past the #?;
for (; *fwdPtr != '\0'; ++fwdPtr)
{
*urlPtr++ = *fwdPtr;
}
*urlPtr = '\0'; // terminate the url
/*
* Now lets remove trailing . case
* /foo/foo1/. -> /foo/foo1/
*/
if ((urlPtr > (io_Path+1)) && (*(urlPtr-1) == '.') && (*(urlPtr-2) == '/'))
*(urlPtr-1) = '\0';
}

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

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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 Andreas Otte.
*
* Contributor(s):
*/
#ifndef _nsURLHelper_h_
#define _nsURLHelper_h_
#include "prtypes.h"
#include "nscore.h"
#include "nsCRT.h"
#ifdef __cplusplus
extern "C" {
#endif
/* encode characters into % escaped hexcodes */
NS_NET nsresult nsURLEscape (const char* str, PRInt16 mask, char ** result);
/* decode % escaped hex codes into character values */
NS_NET nsresult nsURLUnescape(char* str, char ** result);
/* Get port from string */
NS_NET PRInt32 ExtractPortFrom(const char* src);
/* Extract string out of another */
NS_NET nsresult ExtractString(char* i_Src, char* *o_Dest, PRUint32 length);
/* Duplicate string */
NS_NET nsresult DupString(char* *o_Dest, const char* i_Src);
/* handle .. in dirs */
NS_NET void CoaleseDirs(char* io_Path);
#ifdef __cplusplus
}
#endif
#endif

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

@ -30,9 +30,6 @@
#include "nsSocketTransportService.h"
#include "nsSocketProviderService.h"
#include "nscore.h"
#include "nsStdURLParser.h"
#include "nsAuthURLParser.h"
#include "nsNoAuthURLParser.h"
#include "nsStdURL.h"
#include "nsSimpleURI.h"
#include "nsDnsService.h"
@ -101,20 +98,7 @@ static nsModuleComponentInfo gNetModuleInfo[] = {
{ "Load Group",
NS_LOADGROUP_CID,
"component://netscape/network/load-group",
nsLoadGroup::Create },
{ "StdURLParser",
NS_STANDARDURLPARSER_CID,
"component://netscape/network/standard-urlparser",
nsStdURLParser::Create },
{ "AuthURLParser",
NS_AUTHORITYURLPARSER_CID,
"component://netscape/network/authority-urlparser",
nsAuthURLParser::Create },
{ "NoAuthURLParser",
NS_NOAUTHORITYURLPARSER_CID,
"component://netscape/network/no-authority-urlparser",
nsNoAuthURLParser::Create },
nsLoadGroup::Create }
};
NS_IMPL_NSGETMODULE("net", gNetModuleInfo)

Двоичные данные
netwerk/macbuild/netwerk.mcp

Двоичный файл не отображается.

Двоичные данные
netwerk/macbuild/netwerkIDL.mcp

Двоичный файл не отображается.

Двоичные данные
netwerk/protocol/file/macbuild/file.mcp

Двоичный файл не отображается.

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

@ -34,8 +34,7 @@
#include "nsFileSpec.h"
#include "nsAutoLock.h"
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kNoAuthUrlParserCID, NS_NOAUTHORITYURLPARSER_CID);
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
////////////////////////////////////////////////////////////////////////////////
@ -104,31 +103,17 @@ nsFileProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
// file: URLs (currently) have no additional structure beyond that provided by standard
// URLs, so there is no "outer" given to CreateInstance
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
nsIURI* url;
if (aBaseURI) {
rv = aBaseURI->Clone(&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kNoAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
rv = url->SetSpec((char*)aSpec);
}

Двоичные данные
netwerk/protocol/ftp/macbuild/ftp.mcp

Двоичный файл не отображается.

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

@ -46,8 +46,7 @@ PRLogModuleInfo* gFTPLog = nsnull;
#endif /* PR_LOGGING */
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kAuthUrlParserCID, NS_AUTHORITYURLPARSER_CID);
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
////////////////////////////////////////////////////////////////////////////////
@ -131,31 +130,17 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsresult rv;
PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("FTP attempt at %s ", aSpec));
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
nsIURI* url;
if (aBaseURI) {
rv = aBaseURI->Clone(&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
rv = url->SetSpec((char*)aSpec);
}
if (NS_FAILED(rv)) {

Двоичные данные
netwerk/protocol/http/macbuild/http.mcp

Двоичный файл не отображается.

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

@ -39,7 +39,6 @@
#include "nsHTTPEncodeStream.h"
#include "nsHTTPAtoms.h"
#include "nsFileSpec.h"
#include "nsIPref.h" // preferences stuff
#ifdef DEBUG_gagan
#include "nsUnixColorPrintf.h"
@ -64,7 +63,6 @@ PRLogModuleInfo* gHTTPLog = nsnull;
#define MAX_NUMBER_OF_OPEN_TRANSPORTS 8
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kAuthUrlParserCID, NS_AUTHORITYURLPARSER_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
@ -266,7 +264,6 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsresult rv;
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
if (aBaseURI)
{
rv = aBaseURI->Clone(&url);
@ -275,23 +272,10 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
}
else
{
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec((char*)aSpec);
}
if (NS_FAILED(rv)) {

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

@ -157,30 +157,6 @@ nsJARURI::SetPreHost(const char * aPreHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetUsername(char * *aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetUsername(const char * aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetPassword(char * *aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetPassword(const char * aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetHost(char * *aHost)
{
@ -217,18 +193,6 @@ nsJARURI::SetPath(const char * aPath)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetURLParser(nsIURLParser * *aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetURLParser(nsIURLParser * aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::Equals(nsIURI *other, PRBool *_retval)
{

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

@ -121,7 +121,7 @@ nsResChannel::Substitutions::Init()
NS_ASSERTION(mSubstitutions == nsnull, "failed to call destructor");
char* root = nsnull;
char* root;
rv = channel->mResourceURI->GetHost(&root);
if (NS_SUCCEEDED(rv)) {
rv = channel->mHandler->GetSubstitutions(root, &mSubstitutions);

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

@ -637,7 +637,7 @@ static const char kResourceURIPrefix[] = "resource:";
// XXX this is a hack: any "file:" URI is considered writable. All
// others are considered read-only.
char* realURL = nsnull;
char* realURL;
mURL->GetSpec(&realURL);
if ((PL_strncmp(realURL, kFileURIPrefix, sizeof(kFileURIPrefix) - 1) != 0) &&
(PL_strncmp(realURL, kResourceURIPrefix, sizeof(kResourceURIPrefix) - 1) != 0)) {