start to consolidate URL and URI parsing into the base classes: remove a whole bunch of protocol-specific code in favor of generalization

basically, more fixes for #14437
r=scottip
This commit is contained in:
alecf%netscape.com 1999-10-22 01:02:08 +00:00
Родитель e60ab7bac3
Коммит 4bd03fe287
15 изменённых файлов: 81 добавлений и 428 удалений

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

@ -45,7 +45,6 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
nsMsgFolder::nsMsgFolder(void)
: nsRDFResource(),
mName(""),
mFlags(0),
mParent(nsnull),
mNumUnreadMessages(-1),
@ -114,29 +113,55 @@ NS_IMETHODIMP nsMsgFolder::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsMsgFolder::Init(const char* aURI)
{
// for now, just initialize everything during Init()
// this parsing is totally hacky. we really should generalize this,
// but I'm not going to do this until we can eliminate the
// nsXXX2Name/etc routines
// -alecf
nsresult rv;
rv = nsRDFResource::Init(aURI);
nsCOMPtr<nsIURL> url;
rv = nsComponentManager::CreateInstance(kStandardUrlCID, nsnull,
NS_GET_IID(nsIURL),
(void **)getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
// do initial parsing of the URI
const char *cp=aURI;
rv = url->SetSpec(aURI);
if (NS_FAILED(rv)) return rv;
// empty path => server
nsXPIDLCString path;
rv = url->GetPath(getter_Copies(path));
if (NS_SUCCEEDED(rv)) {
if (!nsCRT::strcmp(path, "/"))
mIsServer = PR_TRUE;
else
mIsServer = PR_FALSE;
}
// skip to initial //
while (*cp && (*cp != '/'))
cp++;
// mUsername:
nsXPIDLCString userName;
rv = url->GetPreHost(getter_Copies(userName));
if (NS_SUCCEEDED(rv)) {
mUsername = userName;
}
// skip past //
while (*cp && (*cp == '/'))
cp++;
// mHostname
nsXPIDLCString hostName;
rv = url->GetHost(getter_Copies(hostName));
if (NS_SUCCEEDED(rv)) {
mHostname = hostName;
}
// mName:
// the name is the trailing directory in the path
nsXPIDLCString fileName;
rv = url->GetFileName(getter_Copies(fileName));
if (NS_SUCCEEDED(rv)) {
// XXX conversion to unicode here? is fileName in UTF8?
mName = fileName;
}
if (PL_strchr(cp, '/'))
mIsServer = PR_FALSE;
else
mIsServer = PR_TRUE;
return nsRDFResource::Init(aURI);
return NS_OK;
}
@ -252,6 +277,7 @@ nsMsgFolder::FindSubFolder(const char *subFolderName, nsIFolder **aFolder)
if(NS_FAILED(rv))
return rv;
// XXX use necko here
nsCAutoString uri;
uri.Append(mURI);
uri.Append('/');
@ -468,21 +494,6 @@ NS_IMETHODIMP nsMsgFolder::GetName(PRUnichar **name)
if (!name)
return NS_ERROR_NULL_POINTER;
*name = nsnull;
// cache the name in mName
if (mName.IsEmpty()) {
// return the leaf of this URI
char *lastSlash = PL_strrchr(mURI, '/');
if (lastSlash) {
lastSlash++;
mName = lastSlash;
} else {
// no slashes, return the whole URI
mName = mURI;
}
}
*name = mName.ToNewUnicode();
if (!(*name)) return NS_ERROR_OUT_OF_MEMORY;
@ -1414,25 +1425,20 @@ NS_IMETHODIMP nsMsgFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly,
return NS_OK;
}
#if 0
NS_IMETHODIMP nsMsgFolder::GetUsername(char **userName)
{
nsCOMPtr<nsIMsgIncomingServer> server;
nsresult rv = GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
return server->GetUsername(userName);
NS_ENSURE_ARG_POINTER(userName);
*userName = mUsername.ToNewCString();
return NS_OK;
}
NS_IMETHODIMP nsMsgFolder::GetHostname(char **hostName)
{
nsCOMPtr<nsIMsgIncomingServer> server;
nsresult rv = GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
return server->GetHostname(hostName);
NS_ENSURE_ARG_POINTER(hostName);
*hostName = mHostname.ToNewCString();
return NS_OK;
}
#endif
NS_IMETHODIMP nsMsgFolder::GetNewMessages()
{
@ -1742,7 +1748,6 @@ nsresult nsMsgFolder::NotifyFolderLoaded()
return NS_OK;
}
nsresult
nsGetMailFolderSeparator(nsString& result)
{

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

@ -32,7 +32,7 @@
#include "nsIMsgDatabase.h"
#include "nsIMsgIncomingServer.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
/*
* MsgFolder
*/
@ -103,8 +103,8 @@ public:
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char * *aRememberedPassword);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval);
// NS_IMETHOD GetUsername(char * *aUsername);
// NS_IMETHOD GetHostname(char * *aHostname);
NS_IMETHOD GetUsername(char * *aUsername);
NS_IMETHOD GetHostname(char * *aHostname);
NS_IMETHOD SetFlag(PRUint32 flag);
NS_IMETHOD ClearFlag(PRUint32 flag);
NS_IMETHOD GetFlag(PRUint32 flag, PRBool *_retval);
@ -205,19 +205,9 @@ public:
void UpdateMoveCopyStatus(MWContext *context, PRBool isMove, int32 curMsgCount, int32 totMessages);
#endif
#if 0
NS_IMETHOD GetUsername(char **userName);
NS_IMETHOD GetHostname(char **hostName);
#endif
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db) = 0;
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
@ -236,7 +226,6 @@ protected:
virtual const char* GetIncomingServerType() = 0;
protected:
nsString mName;
PRUint32 mFlags;
nsIFolder *mParent; //This won't be refcounted for ownership reasons.
PRInt32 mNumUnreadMessages; /* count of unread messages (-1 means
@ -266,7 +255,16 @@ protected:
PRInt32 mNumNewBiffMessages;
PRBool mIsCachable;
//
// stuff from the uri
//
PRBool mIsServer;
nsCString mUsername;
nsCString mHostname;
nsString mName;
};
#endif

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

@ -798,83 +798,6 @@ nsresult nsImapMailFolder::GetServerKey(char **serverKey)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetUsername(char** userName)
{
nsresult rv = NS_ERROR_NULL_POINTER;
NS_PRECONDITION (userName, "Oops ... null userName pointer");
if (!userName)
return rv;
*userName = nsnull;
char *uri = nsnull;
rv = GetURI(&uri);
if (NS_FAILED(rv)) return rv;
nsAutoString aName = uri;
PR_FREEIF(uri);
if (aName.Find(kImapRootURI) != 0)
return NS_ERROR_FAILURE;
aName.Cut(0, PL_strlen(kImapRootURI));
while (aName[0] == '/')
aName.Cut(0, 1);
PRInt32 userEnd = aName.FindChar('@');
if (userEnd < 1)
return NS_ERROR_NULL_POINTER;
aName.SetLength(userEnd);
char *tmpCString = aName.ToNewCString();
if (tmpCString && *tmpCString)
{
*userName = PL_strdup(tmpCString);
rv = NS_OK;
nsAllocator::Free(tmpCString);
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetHostname(char** hostName)
{
nsresult rv = NS_ERROR_NULL_POINTER;
NS_PRECONDITION (hostName, "Oops ... null hostName pointer");
if (!hostName)
return rv;
else
*hostName = nsnull;
nsCOMPtr<nsIFolder> aFolder = do_QueryInterface((nsIMsgFolder *) this, &rv);
if (NS_FAILED(rv)) return rv;
char *uri = nsnull;
rv = aFolder->GetURI(&uri);
if (NS_FAILED(rv)) return rv;
nsAutoString aName = uri;
PR_FREEIF(uri);
if (aName.Find(kImapRootURI) == 0)
aName.Cut(0, PL_strlen(kImapRootURI));
else
return NS_ERROR_FAILURE;
while (aName[0] == '/')
aName.Cut(0, 1);
// cut out user name ### alec, when you clean up url parsing, please get this too!
PRInt32 userNameEnd = aName.FindChar('@');
if (userNameEnd > 0)
aName.Cut(0, userNameEnd + 1);
PRInt32 hostEnd = aName.FindChar('/');
if (hostEnd > 0) // must have at least one valid charater
aName.SetLength(hostEnd);
char *tmpCString = aName.ToNewCString();
if (tmpCString && *tmpCString)
{
*hostName = PL_strdup(tmpCString);
rv = NS_OK;
nsAllocator::Free(tmpCString);
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::UserNeedsToAuthenticateForFolder(PRBool
displayOnly,
PRBool

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

@ -129,8 +129,6 @@ public:
NS_IMETHOD GetSizeOnDisk(PRUint32 * size);
NS_IMETHOD GetUsername(char** userName);
NS_IMETHOD GetHostname(char** hostName);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char ** password);

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

@ -184,42 +184,6 @@ nsImapURI2FullName(const char* rootURI, const char* hostname, char* uriStr,
return NS_OK;
}
nsresult
nsImapURI2UserName(const char* rootURI, const char* uriStr,
nsString& username)
{
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) return NS_ERROR_FAILURE;
PRInt32 userStart = PL_strlen(rootURI);
while (uri[userStart] == '/') userStart++;
uri.Cut(0, userStart);
PRInt32 userEnd = uri.FindChar('@');
if (userEnd < 1)
return NS_ERROR_FAILURE;
uri.SetLength(userEnd);
username = uri;
return NS_OK;
}
nsresult
nsImapURI2HostName(const char* rootURI, const char* uriStr,
nsString& hostname)
{
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) return NS_ERROR_FAILURE;
PRInt32 hostStart = PL_strlen(rootURI);
while (uri[hostStart] == '/') hostStart++;
uri.Cut(0, hostStart);
hostStart = uri.FindChar('@'); // skip username
if (hostStart > 0)
uri.Cut(0, hostStart+1);
PRInt32 hostEnd = uri.FindChar('/');
if (hostEnd > 0)
uri.SetLength(hostEnd);
hostname = uri;
return NS_OK;
}
nsresult
nsURI2ProtocolType(const char* uriStr, nsString& type)
{

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

@ -34,21 +34,10 @@ extern nsresult
nsImapURI2Path(const char* rootURI, const char* uriStr,
nsFileSpec& pathResult);
extern nsresult
nsPath2ImapURI(const char* rootURI, const nsFileSpec& path, char* *uri);
extern nsresult
nsImapURI2FullName(const char* rootURI, const char* hostname, char* uriStr,
nsString& name);
extern nsresult
nsImapURI2HostName(const char *rootURI, const char* uriStr,
nsString& hostname);
extern nsresult
nsImapURI2UserName(const char *rootURI, const char* uriStr,
nsString& username);
extern nsresult
nsURI2ProtocolType(const char* uriStr, nsString& type);

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

@ -1003,28 +1003,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetSizeOnDisk(PRUint32* size)
return NS_OK;
}
NS_IMETHODIMP nsMsgLocalMailFolder::GetUsername(char** userName)
{
return nsGetMailboxUserName(kMailboxRootURI, mURI, userName);
}
NS_IMETHODIMP nsMsgLocalMailFolder::GetHostname(char** hostName)
{
nsresult rv;
char *host;
rv = nsGetMailboxHostName(kMailboxRootURI, mURI, &host);
//I'm recopying it because otherwise we'll have a free mismatched memory.
//We should really be using allocators to do all of this.
if(NS_SUCCEEDED(rv) && host)
{
*hostName = PL_strdup(host);
PL_strfree(host);
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
}
return rv;
}
NS_IMETHODIMP nsMsgLocalMailFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate)
{
#ifdef HAVE_PORT
@ -1116,44 +1094,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetPath(nsIFileSpec ** aPathName)
return rv;
}
// OK, this is kind of silly, but for now, we'll just tack the subFolderName
// onto our URI, and ask RDF to find it for us.
NS_IMETHODIMP
nsMsgLocalMailFolder::FindSubFolder(const char *subFolderName, nsIFolder **aFolder)
{
return nsMsgFolder::FindSubFolder(subFolderName, aFolder);
/* nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
if(NS_FAILED(rv))
return rv;
nsCString uri;
uri.Append(mURI);
uri.Append('/');
uri.Append(subFolderName);
nsCOMPtr<nsIRDFResource> res;
rv = rdf->GetResource(uri.GetBuffer(), getter_AddRefs(res));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIFolder> folder(do_QueryInterface(res, &rv));
if (NS_FAILED(rv))
return rv;
if (aFolder)
{
*aFolder = folder;
NS_ADDREF(*aFolder);
return NS_OK;
}
else
return NS_ERROR_NULL_POINTER;
*/
}
nsresult
nsMsgLocalMailFolder::GetTrashFolder(nsIMsgFolder** result)
{
@ -1650,7 +1590,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
{
char* start = mCopyState->m_dataBuffer;
char* end = nsnull;
char* strPtr = nsnull;
PRUint32 linebreak_len = 1;
end = PL_strstr(mCopyState->m_dataBuffer, "\r");
if (!end)

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

@ -107,8 +107,6 @@ public:
NS_IMETHOD GetSizeOnDisk(PRUint32* size);
NS_IMETHOD GetUsername(char** userName);
NS_IMETHOD GetHostname(char** hostName);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char ** password);
@ -131,8 +129,6 @@ public:
// nsIMsgMailFolder
NS_IMETHOD GetPath(nsIFileSpec ** aPathName);
NS_IMETHOD FindSubFolder(const char *subFolderName, nsIFolder **folder);
// overriding nsMsgDBFolder::GetMsgDatabase() method
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase **aMsgDatabase);

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

@ -271,63 +271,3 @@ nsresult nsBuildLocalMessageURI(const char *baseURI, PRUint32 key, char** uri)
*uri = PR_smprintf("%s%s#%u", kMailboxMessageRootURI, tailURI.GetBuffer(), key);
return NS_OK;
}
nsresult
nsGetMailboxHostName(const char *rootURI, const char *uriStr, char **hostName)
{
if(!hostName)
return NS_ERROR_NULL_POINTER;
nsresult rv;
// verify that rootURI starts with "mailbox:/" or "mailbox_message:/"
if ((PL_strcmp(rootURI, kMailboxRootURI) != 0) &&
(PL_strcmp(rootURI, kMailboxMessageRootURI) != 0)) {
return NS_ERROR_FAILURE;
}
// verify that uristr starts with rooturi
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = nsLocalURI2Server(uriStr, getter_AddRefs(server));
if (NS_FAILED(rv))
return rv;
return server->GetHostName(hostName);
}
nsresult nsGetMailboxUserName(const char *rootURI, const char* uriStr,
char **userName)
{
if(!userName)
return NS_ERROR_NULL_POINTER;
nsresult rv;
// verify that rootURI starts with "mailbox:/" or "mailbox_message:/"
if ((PL_strcmp(rootURI, kMailboxRootURI) != 0) &&
(PL_strcmp(rootURI, kMailboxMessageRootURI) != 0)) {
return NS_ERROR_FAILURE;
}
// verify that uristr starts with rooturi
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = nsLocalURI2Server(uriStr, getter_AddRefs(server));
if (NS_FAILED(rv))
return rv;
return server->GetUsername(userName);
}

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

@ -38,10 +38,4 @@ nsParseLocalMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key);
nsresult
nsBuildLocalMessageURI(const char* baseURI, PRUint32 key, char** uri);
nsresult
nsGetMailboxHostName(const char *rootURI, const char *uriStr, char **hostName);
nsresult
nsGetMailboxUserName(const char *rootURI, const char *uriStr, char **userName);
#endif //NS_LOCALUTILS_H

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

@ -470,9 +470,20 @@ nsresult nsNNTPProtocol::Initialize(nsIURI * aURL)
rv = aURL->GetPreHost(getter_Copies(m_userName));
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsIMsgIncomingServer> server;
rv = nsGetNewsServer((const char *)m_userName, (const char *)m_hostName, getter_AddRefs(server));
// retrieve the AccountManager
NS_WITH_SERVICE(nsIMsgMailSession, session, kCMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgAccountManager> accountManager;
rv = session->GetAccountManager(getter_AddRefs(accountManager));
if (NS_FAILED(rv)) return rv;
// find the news host
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(m_userName,
m_hostName,
"nntp",
getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server) {
nsCOMPtr <nsINntpIncomingServer> nntpServer = do_QueryInterface(server, &rv);
if (NS_SUCCEEDED(rv) && nntpServer) {

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

@ -75,7 +75,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
nsMsgNewsFolder::nsMsgNewsFolder(void) : nsMsgLineBuffer(nsnull, PR_FALSE),
mPath(nsnull), mExpungedBytes(0), mGettingNews(PR_FALSE),
mInitialized(PR_FALSE), mOptionLines(nsnull), mHostname(nsnull)
mInitialized(PR_FALSE), mOptionLines(nsnull)
{
/* we're parsing the newsrc file, and the line breaks are platform specific.
* if MSG_LINEBREAK != CRLF, then we aren't looking for CRLF
@ -93,12 +93,6 @@ nsMsgNewsFolder::~nsMsgNewsFolder(void)
mPath = nsnull;
}
// mHostname allocated in nsGetNewsHostName() with new char[]
if (mHostname) {
delete [] mHostname;
mHostname = nsnull;
}
PR_FREEIF(mOptionLines);
mOptionLines = nsnull;
}
@ -813,33 +807,6 @@ NS_IMETHODIMP nsMsgNewsFolder::GetSizeOnDisk(PRUint32 *size)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgNewsFolder::GetUsername(char** userName)
{
return nsGetNewsUsername(kNewsRootURI, mURI, userName);
}
NS_IMETHODIMP nsMsgNewsFolder::GetHostname(char** hostName)
{
nsresult rv = NS_OK;
if (!mHostname) {
// mHostname gets freed in the destructor
rv = nsGetNewsHostName(kNewsRootURI, mURI, &mHostname);
if (NS_FAILED(rv)) return rv;
}
if (mHostname) {
*hostName = PL_strdup(mHostname);
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
}
else {
return NS_ERROR_FAILURE;
}
return rv;
}
NS_IMETHODIMP nsMsgNewsFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate)
{
return NS_OK;

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

@ -79,8 +79,6 @@ public:
NS_IMETHOD GetSizeOnDisk(PRUint32 *size);
NS_IMETHOD GetUsername(char** userName);
NS_IMETHOD GetHostname(char** hostName);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate);
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char ** password);
@ -122,8 +120,7 @@ protected:
PRBool mInitialized;
nsISupportsArray *mMessages;
char *mOptionLines;
char *mHostname;
// cache this until we open the db.
nsCString m_unreadSet;

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

@ -34,7 +34,7 @@
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
nsresult
static nsresult
nsGetNewsServer(const char* username, const char *hostname,
nsIMsgIncomingServer** aResult)
{
@ -64,65 +64,6 @@ nsGetNewsServer(const char* username, const char *hostname,
return rv;
}
// copy-and-paste from nsGetMailboxHostName()
// we could probably combine them in a common place to save
// space.
nsresult nsGetNewsHostName(const char *rootURI, const char *uriStr, char **hostName)
{
if(!hostName)
return NS_ERROR_NULL_POINTER;
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
return NS_ERROR_FAILURE;
// start parsing the uriStr
const char* curPos = uriStr;
// skip past schema
while (*curPos != ':') curPos++;
curPos++;
while (*curPos == '/') curPos++;
char *atPos = PL_strchr(curPos, '@');
if (atPos) curPos = atPos+1;
char *slashPos = PL_strchr(curPos, '/');
int length;
// if there are no more /'s then we just copy the rest of the string
if (slashPos)
length = (slashPos - curPos) + 1;
else
length = PL_strlen(curPos) + 1;
*hostName = new char[length];
if(!*hostName)
return NS_ERROR_OUT_OF_MEMORY;
PL_strncpyz(*hostName, curPos, length);
return NS_OK;
}
nsresult
nsGetNewsUsername(const char *rootURI, const char *uriStr, char **userName)
{
const char *curPos = uriStr;
while (*curPos != ':') curPos++;
curPos++;
while (*curPos == '/') curPos++;
char *atPos = PL_strchr(curPos, '@');
if (atPos) {
*userName = PL_strndup(curPos, (atPos - curPos));
} else {
*userName = PL_strdup("");
}
return NS_OK;
}
nsresult
nsNewsURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)

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

@ -29,15 +29,6 @@ static const char kNewsMessageRootURI[] = "news_message:/";
#define kNewsRootURILen 6
#define kNewsMessageRootURILen 14
extern nsresult
nsGetNewsServer(const char* username, const char *hostname, nsIMsgIncomingServer** aResult);
extern nsresult
nsGetNewsHostName(const char *rootURI, const char *uriStr, char **hostName);
extern nsresult
nsGetNewsUsername(const char *rootURI, const char *uriStr, char **userName);
extern nsresult
nsNewsURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult);