diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 265aed0543e..3afb8031b6a 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -258,7 +258,7 @@ nsIOService::MakeAbsolute(const char *aSpec, if (aSpec == nsnull) return aBaseURI->GetSpec(result); - + char* scheme; rv = GetScheme(aSpec, &scheme); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/netwerk/base/src/nsLoadGroup.cpp b/mozilla/netwerk/base/src/nsLoadGroup.cpp index 707db3622f8..e85ef8cf55b 100644 --- a/mozilla/netwerk/base/src/nsLoadGroup.cpp +++ b/mozilla/netwerk/base/src/nsLoadGroup.cpp @@ -87,7 +87,7 @@ NS_METHOD nsLoadGroup::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) { NS_ENSURE_ARG_POINTER(aResult); - NS_ENSURE_PROPER_AGGREGATION(aOuter, aIID); + NS_ENSURE_PROPER_AGGREGATION(aOuter, aIID); nsLoadGroup* group = new nsLoadGroup(aOuter); if (group == nsnull) @@ -95,8 +95,8 @@ nsLoadGroup::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) nsresult rv = group->AggregatedQueryInterface(aIID, aResult); - if (NS_FAILED(rv)) - delete group; + if (NS_FAILED(rv)) + delete group; return rv; } @@ -134,19 +134,19 @@ nsLoadGroup::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) { NS_ENSURE_ARG_POINTER(aInstancePtr); - if (aIID.Equals(NS_GET_IID(nsISupports))) - *aInstancePtr = GetInner(); + if (aIID.Equals(NS_GET_IID(nsISupports))) + *aInstancePtr = GetInner(); else if (aIID.Equals(kLoadGroupCID) || // for internal use only (to set parent) aIID.Equals(nsCOMTypeInfo::GetIID()) || aIID.Equals(nsCOMTypeInfo::GetIID()) || aIID.Equals(nsCOMTypeInfo::GetIID())) *aInstancePtr = NS_STATIC_CAST(nsILoadGroup*, this); - else { + else { *aInstancePtr = nsnull; return NS_NOINTERFACE; } - NS_ADDREF((nsISupports*)*aInstancePtr); + NS_ADDREF((nsISupports*)*aInstancePtr); return NS_OK; } @@ -451,7 +451,7 @@ nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) nsCRT::free(uriStr); #endif - rv = mChannels->AppendElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool + rv = mChannels->AppendElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool if (NS_FAILED(rv)) return rv; nsLoadFlags flags; @@ -521,7 +521,7 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, // the channel was *not* in the group so do not update the foreground // count or it will get messed up... // - rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool + rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, ("LOADGROUP: %x Unable to remove channel %x. Not in group!\n", @@ -533,7 +533,7 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, rv = channel->GetLoadAttributes(&flags); if (NS_SUCCEEDED(rv)) { if (!(flags & nsIChannel::LOAD_BACKGROUND)) { - NS_ASSERTION(mForegroundCount > 0, "mForegroundCount messed up"); + NS_ASSERTION(mForegroundCount > 0, "mForegroundCount messed up"); --mForegroundCount; PRBool pending; @@ -600,7 +600,7 @@ nsLoadGroup::AddSubGroup(nsILoadGroup *group) PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, ("LOADGROUP: %x Adding sub-group %x.\n", this, group)); - return mSubGroups->AppendElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool + return mSubGroups->AppendElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool } NS_IMETHODIMP @@ -619,7 +619,7 @@ nsLoadGroup::RemoveSubGroup(nsILoadGroup *group) PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, ("LOADGROUP: %x Removing sub-group %x.\n", this, group)); - return mSubGroups->RemoveElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool + return mSubGroups->RemoveElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool } NS_IMETHODIMP diff --git a/mozilla/netwerk/base/src/nsNetModRegEntry.cpp b/mozilla/netwerk/base/src/nsNetModRegEntry.cpp index 78fdfc902ec..c058c258103 100644 --- a/mozilla/netwerk/base/src/nsNetModRegEntry.cpp +++ b/mozilla/netwerk/base/src/nsNetModRegEntry.cpp @@ -57,10 +57,10 @@ NS_IMETHODIMP nsNetModRegEntry::GetTopic(char **topic) { if (mTopic) - { - *topic = (char *) nsAllocator::Clone(mTopic, nsCRT::strlen(mTopic) + 1); - return NS_OK; - } + { + *topic = (char *) nsAllocator::Clone(mTopic, nsCRT::strlen(mTopic) + 1); + return NS_OK; + } return NS_ERROR_NULL_POINTER; } @@ -80,8 +80,8 @@ nsNetModRegEntry::Equals(nsINetModRegEntry* aEntry, PRBool *_retVal) if (topic) { nsAllocator::Free(topic); - topic=0; - } + topic=0; + } if (topic && PL_strcmp(topic, mTopic)) return NS_OK; diff --git a/mozilla/netwerk/base/src/nsSimpleURI.cpp b/mozilla/netwerk/base/src/nsSimpleURI.cpp index 7556a1d2540..f2681e46f77 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.cpp +++ b/mozilla/netwerk/base/src/nsSimpleURI.cpp @@ -52,15 +52,15 @@ nsSimpleURI::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) { NS_ENSURE_ARG_POINTER(aInstancePtr); - if (aIID.Equals(kISupportsIID)) - *aInstancePtr = GetInner(); + if (aIID.Equals(kISupportsIID)) + *aInstancePtr = GetInner(); else if (aIID.Equals(kThisSimpleURIImplementationCID) || // used by Equals aIID.Equals(nsIURI::GetIID())) *aInstancePtr = NS_STATIC_CAST(nsIURI*, this); - else { - *aInstancePtr = nsnull; - return NS_NOINTERFACE; - } + else { + *aInstancePtr = nsnull; + return NS_NOINTERFACE; + } NS_ADDREF((nsISupports*)*aInstancePtr); return NS_OK; } @@ -98,12 +98,12 @@ nsSimpleURI::SetSpec(char* aSpec) n = spec.Mid(path, pos + 1, count); NS_ASSERTION(n == count, "Mid failed"); if (mScheme) - nsCRT::free(mScheme); + nsCRT::free(mScheme); mScheme = scheme.ToNewCString(); if (mScheme == nsnull) return NS_ERROR_OUT_OF_MEMORY; if (mPath) - nsCRT::free(mPath); + nsCRT::free(mPath); mPath = path.ToNewCString(); if (mPath == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -222,7 +222,7 @@ NS_METHOD nsSimpleURI::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) { NS_ENSURE_ARG_POINTER(aResult); - NS_ENSURE_PROPER_AGGREGATION(aOuter, aIID); + NS_ENSURE_PROPER_AGGREGATION(aOuter, aIID); nsSimpleURI* url = new nsSimpleURI(aOuter); if (url == nsnull) @@ -230,8 +230,8 @@ nsSimpleURI::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) nsresult rv = url->AggregatedQueryInterface(aIID, aResult); - if (NS_FAILED(rv)) - delete url; + if (NS_FAILED(rv)) + delete url; return rv; } diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index 66709ef185c..f7656d46245 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -148,7 +148,7 @@ nsSocketTransport::nsSocketTransport() // Set up Internet defaults... // memset(&mNetAddress, 0, sizeof(mNetAddress)); - PR_InitializeNetAddr(PR_IpAddrNull, 0, &mNetAddress); + PR_InitializeNetAddr(PR_IpAddrNull, 0, &mNetAddress); // // Initialize the global connect timeout value if necessary... @@ -538,7 +538,7 @@ nsresult nsSocketTransport::doResolveHost(void) rv = NS_ERROR_UNKNOWN_HOST; // check this! } status = PR_GetHostByAddr(netAddr, dbbuf, sizeof(dbbuf), &hostEnt); - nsAllocator::Free(netAddr); + nsAllocator::Free(netAddr); } else { status = PR_GetHostByName(mHostName, dbbuf, sizeof(dbbuf), &hostEnt); } @@ -1643,10 +1643,10 @@ nsSocketTransport::OpenOutputStream(PRUint32 startPosition, nsIOutputStream* *re mWriteObserver = null_nsCOMPtr(); mWriteContext = null_nsCOMPtr(); - // We want a pipe here so the caller can "write" into one end - // and the other end (aWriteStream) gets the data. This data - // is then written to the underlying socket when nsSocketTransport::doWrite() - // is called. + // We want a pipe here so the caller can "write" into one end + // and the other end (aWriteStream) gets the data. This data + // is then written to the underlying socket when nsSocketTransport::doWrite() + // is called. nsCOMPtr out; nsCOMPtr in; diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index a5b6333cdc2..66ac7184944 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -34,10 +34,10 @@ void ReplaceDotMess(char* io_Path); class nsParsePath { public: - nsParsePath(nsStdURL* i_URL): mURL(i_URL) {} - virtual ~nsParsePath() {mURL->ParsePath();} + nsParsePath(nsStdURL* i_URL): mURL(i_URL) {} + virtual ~nsParsePath() {mURL->ParsePath();} private: - nsStdURL* mURL; + nsStdURL* mURL; }; nsStdURL::nsStdURL(const char* i_Spec, nsISupports* outer) @@ -46,18 +46,18 @@ nsStdURL::nsStdURL(const char* i_Spec, nsISupports* outer) mHost(nsnull), mPort(-1), mPath(nsnull), - mDirectory(nsnull), - mFileName(nsnull), - mParam(nsnull), + mDirectory(nsnull), + mFileName(nsnull), + mParam(nsnull), mQuery(nsnull), mRef(nsnull) { - mSpec = i_Spec ? nsCRT::strdup(i_Spec) : nsnull; - if (mSpec) - ReplaceDotMess(mSpec); + mSpec = i_Spec ? nsCRT::strdup(i_Spec) : nsnull; + if (mSpec) + ReplaceDotMess(mSpec); NS_INIT_AGGREGATED(outer); - if (i_Spec) - Parse(); + if (i_Spec) + Parse(); } nsStdURL::nsStdURL(const nsStdURL& otherURL) @@ -70,7 +70,7 @@ nsStdURL::nsStdURL(const nsStdURL& otherURL) mPath = otherURL.mPath ? nsCRT::strdup(otherURL.mPath) : nsnull; mDirectory = otherURL.mDirectory ? nsCRT::strdup(otherURL.mDirectory) : nsnull; mFileName = otherURL.mFileName ? nsCRT::strdup(otherURL.mFileName) : nsnull; - mParam = otherURL.mParam ? nsCRT::strdup(otherURL.mParam) : nsnull; + mParam = otherURL.mParam ? nsCRT::strdup(otherURL.mParam) : nsnull; mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; NS_INIT_AGGREGATED(nsnull); // Todo! How? @@ -86,19 +86,19 @@ nsStdURL::operator=(const nsStdURL& otherURL) mPath = otherURL.mPath ? nsCRT::strdup(otherURL.mPath) : nsnull; mDirectory = otherURL.mDirectory ? nsCRT::strdup(otherURL.mDirectory) : nsnull; mFileName = otherURL.mFileName ? nsCRT::strdup(otherURL.mFileName) : nsnull; - mParam = otherURL.mParam ? nsCRT::strdup(otherURL.mParam) : nsnull; + mParam = otherURL.mParam ? nsCRT::strdup(otherURL.mParam) : nsnull; mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; NS_INIT_AGGREGATED(nsnull); // Todo! How? - return *this; + return *this; } PRBool nsStdURL::operator==(const nsStdURL& otherURL) const { - PRBool retValue = PR_FALSE; - ((nsStdURL*)(this))->Equals((nsIURI*)&otherURL,&retValue); - return retValue; + PRBool retValue = PR_FALSE; + ((nsStdURL*)(this))->Equals((nsIURI*)&otherURL,&retValue); + return retValue; } nsStdURL::~nsStdURL() @@ -108,11 +108,11 @@ nsStdURL::~nsStdURL() CRTFREEIF(mHost); CRTFREEIF(mPath); CRTFREEIF(mRef); - CRTFREEIF(mParam); + CRTFREEIF(mParam); CRTFREEIF(mQuery); CRTFREEIF(mSpec); - CRTFREEIF(mDirectory); - CRTFREEIF(mFileName); + CRTFREEIF(mDirectory); + CRTFREEIF(mFileName); } NS_IMPL_AGGREGATED(nsStdURL); @@ -121,35 +121,35 @@ NS_IMETHODIMP nsStdURL::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) { NS_ASSERTION(aInstancePtr, "no instance pointer"); - if(!aInstancePtr) - return NS_ERROR_INVALID_POINTER; + if(!aInstancePtr) + return NS_ERROR_INVALID_POINTER; - if (aIID.Equals(nsCOMTypeInfo::GetIID())) - *aInstancePtr = GetInner(); + if (aIID.Equals(nsCOMTypeInfo::GetIID())) + *aInstancePtr = GetInner(); else if (aIID.Equals(kThisStdURLImplementationCID) || // used by Equals aIID.Equals(nsCOMTypeInfo::GetIID()) || aIID.Equals(nsCOMTypeInfo::GetIID())) *aInstancePtr = NS_STATIC_CAST(nsIURL*, this); - else { - *aInstancePtr = nsnull; - return NS_NOINTERFACE; + else { + *aInstancePtr = nsnull; + return NS_NOINTERFACE; } - NS_ADDREF((nsISupports*)*aInstancePtr); + NS_ADDREF((nsISupports*)*aInstancePtr); return NS_OK; } NS_IMETHODIMP nsStdURL::Equals(nsIURI *i_OtherURI, PRBool *o_Equals) { - PRBool eq = PR_FALSE; - if (i_OtherURI) { - nsXPIDLCString spec; - nsresult rv = i_OtherURI->GetSpec(getter_Copies(spec)); - if (NS_FAILED(rv)) return rv; - eq = nsAutoString(spec).Equals(this->mSpec); - } - *o_Equals = eq; - return NS_OK; + PRBool eq = PR_FALSE; + if (i_OtherURI) { + nsXPIDLCString spec; + nsresult rv = i_OtherURI->GetSpec(getter_Copies(spec)); + if (NS_FAILED(rv)) return rv; + eq = nsAutoString(spec).Equals(this->mSpec); + } + *o_Equals = eq; + return NS_OK; } NS_IMETHODIMP @@ -158,7 +158,7 @@ nsStdURL::Clone(nsIURI **o_URI) nsStdURL* url = new nsStdURL(*this); /// TODO check outer? if (url == nsnull) return NS_ERROR_OUT_OF_MEMORY; - nsresult rv= NS_OK; + nsresult rv= NS_OK; *o_URI = url; NS_ADDREF(url); @@ -168,9 +168,9 @@ nsStdURL::Clone(nsIURI **o_URI) nsresult nsStdURL::Parse(void) { - // Parse the path into its individual elements - // when we are done from here. - nsParsePath pp(this); + // Parse the path into its individual elements + // when we are done from here. + nsParsePath pp(this); NS_PRECONDITION( (nsnull != mSpec), "Parse called on empty url!"); if (!mSpec) return NS_ERROR_MALFORMED_URI; @@ -183,393 +183,393 @@ nsStdURL::Parse(void) if (!brk) // everything is a host { ExtractString(mSpec, &mHost, 0, len); - return NS_OK; + return NS_OK; } - switch (*brk) - { - case '/' : - case '?' : - // If the URL starts with a slash then everything is a path - if (brk == mSpec) - { - ExtractString(mSpec, &mPath, 0, len); - return NS_OK; - } - else // The first part is host, so its host/path - { - ExtractString(mSpec, &mHost, 0, (brk - mSpec)); - ExtractString(mSpec, &mPath, (brk - mSpec), (len - (brk - mSpec))); - return NS_OK; - } - break; - case ':' : - if (*(brk+1) == '/') - { - ExtractString(mSpec, &mScheme, 0, (brk - mSpec)); + switch (*brk) + { + case '/' : + case '?' : + // If the URL starts with a slash then everything is a path + if (brk == mSpec) + { + ExtractString(mSpec, &mPath, 0, len); + return NS_OK; + } + else // The first part is host, so its host/path + { + ExtractString(mSpec, &mHost, 0, (brk - mSpec)); + ExtractString(mSpec, &mPath, (brk - mSpec), (len - (brk - mSpec))); + return NS_OK; + } + break; + case ':' : + if (*(brk+1) == '/') + { + ExtractString(mSpec, &mScheme, 0, (brk - mSpec)); - if (*(brk+2) == '/') // e.g. http:// - // If the first colon is followed by // then its definitely a spec - { - lastbrk = brk+3; - brk = PL_strpbrk(lastbrk, delimiters); - if (!brk) // everything else is a host, as in http://host - { - ExtractString(mSpec, &mHost, - (lastbrk - mSpec), - len - (lastbrk - mSpec)); - return NS_OK; - } - switch (*brk) - { - case '/' : // standard case- http://host/path - case '?' : // missing path cases - ExtractString(mSpec, &mHost, - (lastbrk - mSpec), (brk - lastbrk)); - ExtractString(mSpec, &mPath, - (brk - mSpec), (len - (brk - mSpec))); - return NS_OK; - break; - case ':' : // http://user:... or http://host:... - { + if (*(brk+2) == '/') // e.g. http:// + // If the first colon is followed by // then its definitely a spec + { + lastbrk = brk+3; + brk = PL_strpbrk(lastbrk, delimiters); + if (!brk) // everything else is a host, as in http://host + { + ExtractString(mSpec, &mHost, + (lastbrk - mSpec), + len - (lastbrk - mSpec)); + return NS_OK; + } + switch (*brk) + { + case '/' : // standard case- http://host/path + case '?' : // missing path cases + ExtractString(mSpec, &mHost, + (lastbrk - mSpec), (brk - lastbrk)); + ExtractString(mSpec, &mPath, + (brk - mSpec), (len - (brk - mSpec))); + return NS_OK; + break; + case ':' : // http://user:... or http://host:... + { // It could be http://user:pass@host/path // or http://host:port/path we find that by checking further... char* nextbrk = PL_strpbrk(brk+1, delimiters); if (!nextbrk) // http://host:port { - ExtractString(mSpec, &mHost, - (lastbrk-mSpec), (brk-lastbrk)); - mPort = ExtractPortFrom(mSpec, - (brk-mSpec +1), len - (brk-mSpec +1)); - return NS_OK; + ExtractString(mSpec, &mHost, + (lastbrk-mSpec), (brk-lastbrk)); + mPort = ExtractPortFrom(mSpec, + (brk-mSpec +1), len - (brk-mSpec +1)); + return NS_OK; } switch (*nextbrk) { - case '/': // http://host:port/path - case '?': // http://host:port?path - ExtractString(mSpec, &mHost, - (lastbrk-mSpec), (brk-lastbrk)); - mPort = ExtractPortFrom(mSpec, (brk-mSpec+1),(nextbrk-brk-1)); - ExtractString(mSpec, &mPath, - (nextbrk-mSpec), len - (nextbrk-mSpec)); - return NS_OK; - break; - case '@': // http://user:pass@host... - ExtractString(mSpec, &mPreHost, - (lastbrk - mSpec), (nextbrk - lastbrk)); - brk = PL_strpbrk(nextbrk+1, delimiters); - if (!brk) // its just http://user:pass@host - { - ExtractString(mSpec, &mHost, - (nextbrk+1 - mSpec), - len - (nextbrk+1 - mSpec)); - return NS_OK; - } + case '/': // http://host:port/path + case '?': // http://host:port?path + ExtractString(mSpec, &mHost, + (lastbrk-mSpec), (brk-lastbrk)); + mPort = ExtractPortFrom(mSpec, (brk-mSpec+1),(nextbrk-brk-1)); + ExtractString(mSpec, &mPath, + (nextbrk-mSpec), len - (nextbrk-mSpec)); + return NS_OK; + break; + case '@': // http://user:pass@host... + ExtractString(mSpec, &mPreHost, + (lastbrk - mSpec), (nextbrk - lastbrk)); + brk = PL_strpbrk(nextbrk+1, delimiters); + if (!brk) // its just http://user:pass@host + { + ExtractString(mSpec, &mHost, + (nextbrk+1 - mSpec), + len - (nextbrk+1 - mSpec)); + return NS_OK; + } - ExtractString(mSpec, &mHost, - (nextbrk+1 - mSpec), brk - (nextbrk+1)); + ExtractString(mSpec, &mHost, + (nextbrk+1 - mSpec), brk - (nextbrk+1)); - switch (*brk) - { - case '/': // http://user:pass@host/path - case '?': - ExtractString(mSpec, &mPath, - (nextbrk+1 - mSpec), - len - (nextbrk+1 - mSpec)); - return NS_OK; - break; - case ':': // http://user:pass@host:port... - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, "/?"); - if (brk) // http://user:pass@host:port/path - { - mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec),(brk-lastbrk)); - ExtractString(mSpec, &mPath, (brk-mSpec), len - (brk-mSpec)); - return NS_OK; - } - else // http://user:pass@host:port - { - mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec), - len - (lastbrk-mSpec)); - return NS_OK; - } - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; - } - break; - case ':': // three colons! - return NS_ERROR_MALFORMED_URI; - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; + switch (*brk) + { + case '/': // http://user:pass@host/path + case '?': + ExtractString(mSpec, &mPath, + (nextbrk+1 - mSpec), + len - (nextbrk+1 - mSpec)); + return NS_OK; + break; + case ':': // http://user:pass@host:port... + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, "/?"); + if (brk) // http://user:pass@host:port/path + { + mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec),(brk-lastbrk)); + ExtractString(mSpec, &mPath, (brk-mSpec), len - (brk-mSpec)); + return NS_OK; + } + else // http://user:pass@host:port + { + mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec), + len - (lastbrk-mSpec)); + return NS_OK; + } + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; + } + break; + case ':': // three colons! + return NS_ERROR_MALFORMED_URI; + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; } - } - break; - case '@' : // http://user@host... - { - ExtractString(mSpec, &mPreHost, - (lastbrk-mSpec), (brk-lastbrk)); - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, delimiters); - if (!brk) // its just http://user@host - { - ExtractString(mSpec, &mHost, - (lastbrk+1 - mSpec), - len - (lastbrk+1 - mSpec)); - return NS_OK; - } - ExtractString(mSpec, &mHost, - (lastbrk-mSpec), (brk - lastbrk)); - switch (*brk) - { - case ':' : // http://user@host:port... - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, "/?"); - if (brk) // http://user@host:port/path - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec),(brk-lastbrk)); - ExtractString(mSpec, &mPath, - (brk-mSpec), - len - (brk-mSpec)); - return NS_OK; - } - else // http://user@host:port - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec), - len - (lastbrk-mSpec)); - return NS_OK; - } - break; - case '/' : // http://user@host/path - case '?' : // http://user@host?path - ExtractString(mSpec, &mPath, - (brk - mSpec), - len - (brk - mSpec)); - return NS_OK; - break; - case '@' : - return NS_ERROR_MALFORMED_URI; - default : NS_POSTCONDITION(0, - "This just can't be!"); - break; - } - } - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; - } - } - else // This is a no // path alone case like file:/path, - // there is never a prehost/host in this case. - { - ExtractString(mSpec, &mPath, (brk-mSpec+1), - len - (brk-mSpec+1)); - return NS_OK; - } - } - else // scheme:host or host:port... - { - lastbrk = brk+1; + } + break; + case '@' : // http://user@host... + { + ExtractString(mSpec, &mPreHost, + (lastbrk-mSpec), (brk-lastbrk)); + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, delimiters); + if (!brk) // its just http://user@host + { + ExtractString(mSpec, &mHost, + (lastbrk+1 - mSpec), + len - (lastbrk+1 - mSpec)); + return NS_OK; + } + ExtractString(mSpec, &mHost, + (lastbrk-mSpec), (brk - lastbrk)); + switch (*brk) + { + case ':' : // http://user@host:port... + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, "/?"); + if (brk) // http://user@host:port/path + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec),(brk-lastbrk)); + ExtractString(mSpec, &mPath, + (brk-mSpec), + len - (brk-mSpec)); + return NS_OK; + } + else // http://user@host:port + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec), + len - (lastbrk-mSpec)); + return NS_OK; + } + break; + case '/' : // http://user@host/path + case '?' : // http://user@host?path + ExtractString(mSpec, &mPath, + (brk - mSpec), + len - (brk - mSpec)); + return NS_OK; + break; + case '@' : + return NS_ERROR_MALFORMED_URI; + default : NS_POSTCONDITION(0, + "This just can't be!"); + break; + } + } + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; + } + } + else // This is a no // path alone case like file:/path, + // there is never a prehost/host in this case. + { + ExtractString(mSpec, &mPath, (brk-mSpec+1), + len - (brk-mSpec+1)); + return NS_OK; + } + } + else // scheme:host or host:port... + { + lastbrk = brk+1; - if ((*lastbrk >= '0') && (*lastbrk <= '9')) //host:port... - { - ExtractString(mSpec, &mHost, 0, (brk - mSpec)); - brk = PL_strpbrk(lastbrk, delimiters); - if (!brk) // Everything else is just the port - { - mPort = ExtractPortFrom(mSpec, lastbrk-mSpec, - len - (lastbrk-mSpec)); - return NS_OK; - } - switch (*brk) - { - case '/' : // The path, so its host:port/path - case '?' : // The path, so its host:port?path - mPort = ExtractPortFrom(mSpec, lastbrk-mSpec, - brk-lastbrk); - ExtractString(mSpec, &mPath, brk- mSpec, - len - (brk-mSpec)); - return NS_OK; - break; - case ':' : - return NS_ERROR_MALFORMED_URI; - break; - case '@' : - // This is a special case of user:pass@host... so - // Cleanout our earliar knowledge of host - ExtractString(mSpec, &mHost, -1, -1); + if ((*lastbrk >= '0') && (*lastbrk <= '9')) //host:port... + { + ExtractString(mSpec, &mHost, 0, (brk - mSpec)); + brk = PL_strpbrk(lastbrk, delimiters); + if (!brk) // Everything else is just the port + { + mPort = ExtractPortFrom(mSpec, lastbrk-mSpec, + len - (lastbrk-mSpec)); + return NS_OK; + } + switch (*brk) + { + case '/' : // The path, so its host:port/path + case '?' : // The path, so its host:port?path + mPort = ExtractPortFrom(mSpec, lastbrk-mSpec, + brk-lastbrk); + ExtractString(mSpec, &mPath, brk- mSpec, + len - (brk-mSpec)); + return NS_OK; + break; + case ':' : + return NS_ERROR_MALFORMED_URI; + break; + case '@' : + // This is a special case of user:pass@host... so + // Cleanout our earliar knowledge of host + ExtractString(mSpec, &mHost, -1, -1); - ExtractString(mSpec, &mPreHost, 0, (brk-mSpec)); - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, ":/?"); - // its user:pass@host so everthing else is just the host - if (!brk) - { - ExtractString(mSpec, &mHost, - (lastbrk-mSpec), len - (lastbrk-mSpec)); - return NS_OK; - } - ExtractString(mSpec, &mHost, - (lastbrk-mSpec), (brk-lastbrk)); - if (*brk == ':') // user:pass@host:port... - { - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, "/?"); - if (brk) // user:pass@host:port/path - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec),(brk-lastbrk)); - ExtractString(mSpec, &mPath, - (brk-mSpec), len - (brk-mSpec)); - return NS_OK; - } - else // user:pass@host:port - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec),len - (lastbrk-mSpec)); - return NS_OK; - } - } - else // (*brk == '/') || (*brk == '?') - // so user:pass@host/path - { - ExtractString(mSpec, &mPath, (brk - mSpec), - len - (brk - mSpec)); - return NS_OK; - } - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; - } - } - else // scheme:host... - { - ExtractString(mSpec, &mScheme, 0, (brk - mSpec)); - brk = PL_strpbrk(lastbrk, delimiters); - if (!brk) // its just scheme:host - { - ExtractString(mSpec, &mHost, (lastbrk-mSpec), - len - (lastbrk-mSpec)); - return NS_OK; - } - switch (*brk) - { - case '/' : // The path, so its scheme:host/path - case '?' : // The path, so its scheme:host?path - ExtractString(mSpec, &mHost, (lastbrk-mSpec), - (brk-lastbrk)); - ExtractString(mSpec, &mPath, (brk - mSpec), - len - (brk - mSpec)); - return NS_OK; - break; - case '@' : // scheme:user@host... - ExtractString(mSpec, &mPreHost, (lastbrk-mSpec), - (brk-lastbrk)); - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, delimiters); - if (!brk) // scheme:user@host only - { - ExtractString(mSpec, &mHost, (lastbrk - mSpec), - len - (lastbrk-mSpec)); - return NS_OK; - } - ExtractString(mSpec, &mHost, (lastbrk-mSpec), - (brk - lastbrk)); - switch (*brk) - { - case ':' : // scheme:user@host:port... - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, "/?"); - if (brk) // user:pass@host:port/path - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec),(brk-lastbrk)); - ExtractString(mSpec, &mPath, - (brk-mSpec), len - (brk-mSpec)); - return NS_OK; - } - else // user:pass@host:port - { - mPort = ExtractPortFrom(mSpec, - (lastbrk-mSpec),len - (lastbrk-mSpec)); - return NS_OK; - } - break; - case '/' : - case '?' : - ExtractString(mSpec, &mPath, - (brk-mSpec), len - (brk-mSpec)); - return NS_OK; - break; - case '@' : // bad case - return NS_ERROR_MALFORMED_URI; - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; - } - break; - case ':' : // scheme:user:pass@host...or scheme:host:port... - /* TODO - if you find @ in the remaining string - then // scheme:user:pass@host... - { - + ExtractString(mSpec, &mPreHost, 0, (brk-mSpec)); + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, ":/?"); + // its user:pass@host so everthing else is just the host + if (!brk) + { + ExtractString(mSpec, &mHost, + (lastbrk-mSpec), len - (lastbrk-mSpec)); + return NS_OK; + } + ExtractString(mSpec, &mHost, + (lastbrk-mSpec), (brk-lastbrk)); + if (*brk == ':') // user:pass@host:port... + { + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, "/?"); + if (brk) // user:pass@host:port/path + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec),(brk-lastbrk)); + ExtractString(mSpec, &mPath, + (brk-mSpec), len - (brk-mSpec)); + return NS_OK; + } + else // user:pass@host:port + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec),len - (lastbrk-mSpec)); + return NS_OK; + } + } + else // (*brk == '/') || (*brk == '?') + // so user:pass@host/path + { + ExtractString(mSpec, &mPath, (brk - mSpec), + len - (brk - mSpec)); + return NS_OK; + } + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; + } + } + else // scheme:host... + { + ExtractString(mSpec, &mScheme, 0, (brk - mSpec)); + brk = PL_strpbrk(lastbrk, delimiters); + if (!brk) // its just scheme:host + { + ExtractString(mSpec, &mHost, (lastbrk-mSpec), + len - (lastbrk-mSpec)); + return NS_OK; + } + switch (*brk) + { + case '/' : // The path, so its scheme:host/path + case '?' : // The path, so its scheme:host?path + ExtractString(mSpec, &mHost, (lastbrk-mSpec), + (brk-lastbrk)); + ExtractString(mSpec, &mPath, (brk - mSpec), + len - (brk - mSpec)); + return NS_OK; + break; + case '@' : // scheme:user@host... + ExtractString(mSpec, &mPreHost, (lastbrk-mSpec), + (brk-lastbrk)); + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, delimiters); + if (!brk) // scheme:user@host only + { + ExtractString(mSpec, &mHost, (lastbrk - mSpec), + len - (lastbrk-mSpec)); + return NS_OK; + } + ExtractString(mSpec, &mHost, (lastbrk-mSpec), + (brk - lastbrk)); + switch (*brk) + { + case ':' : // scheme:user@host:port... + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, "/?"); + if (brk) // user:pass@host:port/path + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec),(brk-lastbrk)); + ExtractString(mSpec, &mPath, + (brk-mSpec), len - (brk-mSpec)); + return NS_OK; + } + else // user:pass@host:port + { + mPort = ExtractPortFrom(mSpec, + (lastbrk-mSpec),len - (lastbrk-mSpec)); + return NS_OK; + } + break; + case '/' : + case '?' : + ExtractString(mSpec, &mPath, + (brk-mSpec), len - (brk-mSpec)); + return NS_OK; + break; + case '@' : // bad case + return NS_ERROR_MALFORMED_URI; + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; + } + break; + case ':' : // scheme:user:pass@host...or scheme:host:port... + /* TODO + if you find @ in the remaining string + then // scheme:user:pass@host... + { + - } - else // scheme:host:port - { - ExtractString(mSpec, &mHost, (lastbrk-mSpec), - (brk-lastbrk)); - } - */ - break; - default: NS_POSTCONDITION(0, "This just can't be!"); - break; - } - } - } - break; - case '@' : - //Everything before the @ is the prehost stuff - ExtractString(mSpec, &mPreHost, 0, brk-mSpec); - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, ":/"); - if (!brk) // its user@host so everything else is just the host - { - ExtractString(mSpec, &mHost, (lastbrk-mSpec), - (len - (lastbrk-mSpec))); - return NS_OK; - } - ExtractString(mSpec, &mHost, (lastbrk-mSpec), (brk-lastbrk)); - if (*brk == ':') // user@host:port... - { - lastbrk = brk+1; - brk = PL_strpbrk(lastbrk, "/?"); - if (brk) // user@host:port/path - { - mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec),(brk-lastbrk)); - ExtractString(mSpec, &mPath, (brk-mSpec), len - (brk-mSpec)); - return NS_OK; - } - else // user@host:port - { - mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec), - len - (lastbrk-mSpec)); - return NS_OK; - } - } - else // (*brk == '/') so user@host/path - { - ExtractString(mSpec, &mPath, (brk - mSpec), len - (brk - mSpec)); - return NS_OK; - } - break; - default: - NS_ASSERTION(0, "This just can't be!"); - break; - } + } + else // scheme:host:port + { + ExtractString(mSpec, &mHost, (lastbrk-mSpec), + (brk-lastbrk)); + } + */ + break; + default: NS_POSTCONDITION(0, "This just can't be!"); + break; + } + } + } + break; + case '@' : + //Everything before the @ is the prehost stuff + ExtractString(mSpec, &mPreHost, 0, brk-mSpec); + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, ":/"); + if (!brk) // its user@host so everything else is just the host + { + ExtractString(mSpec, &mHost, (lastbrk-mSpec), + (len - (lastbrk-mSpec))); + return NS_OK; + } + ExtractString(mSpec, &mHost, (lastbrk-mSpec), (brk-lastbrk)); + if (*brk == ':') // user@host:port... + { + lastbrk = brk+1; + brk = PL_strpbrk(lastbrk, "/?"); + if (brk) // user@host:port/path + { + mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec),(brk-lastbrk)); + ExtractString(mSpec, &mPath, (brk-mSpec), len - (brk-mSpec)); + return NS_OK; + } + else // user@host:port + { + mPort = ExtractPortFrom(mSpec, (lastbrk-mSpec), + len - (lastbrk-mSpec)); + return NS_OK; + } + } + else // (*brk == '/') so user@host/path + { + ExtractString(mSpec, &mPath, (brk - mSpec), len - (brk - mSpec)); + return NS_OK; + } + break; + default: + NS_ASSERTION(0, "This just can't be!"); + break; + } return NS_OK; } @@ -585,55 +585,55 @@ nsStdURL::ReconstructSpec() else { portBuffer[0] = '\0'; } - - nsString finalSpec; - if (mScheme) - { - finalSpec = mScheme; - finalSpec += "://"; - } - if (mPreHost) - { - finalSpec += mPreHost; - finalSpec += '@'; - } - if (mHost) - { - finalSpec += mHost; - } - if (-1 != mPort) - { - finalSpec += portBuffer; - } - if (mPath) - { - finalSpec += mPath; - } + + nsString finalSpec; + if (mScheme) + { + finalSpec = mScheme; + finalSpec += "://"; + } + if (mPreHost) + { + finalSpec += mPreHost; + finalSpec += '@'; + } + if (mHost) + { + finalSpec += mHost; + } + if (-1 != mPort) + { + finalSpec += portBuffer; + } + if (mPath) + { + finalSpec += mPath; + } mSpec = finalSpec.ToNewCString(); return (mSpec ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } NS_METHOD nsStdURL::Create(nsISupports *aOuter, - REFNSIID aIID, - void **aResult) + REFNSIID aIID, + void **aResult) { if (!aResult) - return NS_ERROR_INVALID_POINTER; + return NS_ERROR_INVALID_POINTER; - if (aOuter && !aIID.Equals(NS_GET_IID(nsISupports))) - return NS_ERROR_INVALID_ARG; + if (aOuter && !aIID.Equals(NS_GET_IID(nsISupports))) + return NS_ERROR_INVALID_ARG; nsStdURL* url = new nsStdURL(nsnull, aOuter); if (url == nsnull) return NS_ERROR_OUT_OF_MEMORY; nsresult rv = url->AggregatedQueryInterface(aIID, aResult); - if (NS_FAILED(rv)) { - delete url; - return rv; - } - + if (NS_FAILED(rv)) { + delete url; + return rv; + } + return rv; } @@ -641,43 +641,43 @@ nsresult nsStdURL::ExtractString(char* i_Source, char* *o_Destination, PRUint32 start, PRUint32 length) { NS_PRECONDITION( (nsnull != i_Source), "Exract called on empty string!"); - if (*o_Destination) - nsCRT::free(*o_Destination); + if (*o_Destination) + nsCRT::free(*o_Destination); *o_Destination = nsnull; if (0 == length) return NS_OK; - char* startPosition = i_Source + start; - *o_Destination = PL_strndup(startPosition, length); + char* startPosition = i_Source + start; + *o_Destination = PL_strndup(startPosition, length); return (*o_Destination ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } PRInt32 ExtractPortFrom(char* src, int start, int length) { char* port = new char[length +1]; - PRInt32 returnValue = -1; + PRInt32 returnValue = -1; if (!port) return returnValue; // ERROR! PL_strncpyz(port, src+start, length+1); returnValue = atoi(port); - delete[] port; + delete[] port; return returnValue; } nsresult nsStdURL::DupString(char* *o_Destination, char* i_Source) { - if (!o_Destination) - return NS_ERROR_NULL_POINTER; - if (i_Source) - { - *o_Destination = nsCRT::strdup(i_Source); - return (*o_Destination == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; - } - else - { - *o_Destination = nsnull; - return NS_OK; - } + if (!o_Destination) + return NS_ERROR_NULL_POINTER; + if (i_Source) + { + *o_Destination = nsCRT::strdup(i_Source); + return (*o_Destination == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; + } + else + { + *o_Destination = nsnull; + return NS_OK; + } } NS_IMETHODIMP @@ -710,7 +710,7 @@ nsStdURL::SetFileName(char* i_FileName) return NS_ERROR_NULL_POINTER; //Cleanout param, query and ref - CRTFREEIF(mParam); + CRTFREEIF(mParam); CRTFREEIF(mQuery); CRTFREEIF(mRef); @@ -726,11 +726,11 @@ nsStdURL::SetFileName(char* i_FileName) NS_IMETHODIMP nsStdURL::SetRef(char* i_Ref) { - nsresult status; + nsresult status; if (i_Ref && (*i_Ref == '#')) - status = DupString(&mRef, i_Ref+1); - else - status = DupString(&mRef, i_Ref); + status = DupString(&mRef, i_Ref+1); + else + status = DupString(&mRef, i_Ref); return (NS_FAILED(status) ? status : ReconstructPath()); } @@ -740,7 +740,7 @@ nsStdURL::SetParam(char* i_Param) nsresult status; if (i_Param && (*i_Param == ';')) status = DupString(&mParam, i_Param+1); - else + else status = DupString(&mParam, i_Param); return (NS_FAILED(status) ? status : ReconstructPath()); } @@ -751,7 +751,7 @@ nsStdURL::SetQuery(char* i_Query) nsresult status; if (i_Query && (*i_Query == '?')) status = DupString(&mQuery, i_Query+1); - else + else status = DupString(&mQuery, i_Query); return (NS_FAILED(status) ? status : ReconstructPath()); } @@ -817,7 +817,7 @@ nsStdURL::ReconstructPath(void) } mPath = path.ToNewCString(); - ReplaceDotMess(mPath); + ReplaceDotMess(mPath); return (mPath ? ReconstructSpec() : NS_ERROR_OUT_OF_MEMORY); } @@ -828,10 +828,10 @@ nsresult nsStdURL::ParsePath(void) { CRTFREEIF(mDirectory); - CRTFREEIF(mFileName); - CRTFREEIF(mParam); - CRTFREEIF(mQuery); - CRTFREEIF(mRef); + CRTFREEIF(mFileName); + CRTFREEIF(mParam); + CRTFREEIF(mQuery); + CRTFREEIF(mRef); if (!mPath) { @@ -857,17 +857,17 @@ nsStdURL::ParsePath(void) // First find the last slash char* file = PL_strrchr(mPath, '/'); if (!file) - { - // Treat the whole mPath as file -- this could still have ?, # etc. - file = mPath; - } + { + // Treat the whole mPath as file -- this could still have ?, # etc. + file = mPath; + } // If its not the same as the first slash then extract directory if (file != mPath) { ExtractString(mPath, &mDirectory, 0, (file - mPath)); } - else - DupString(&mDirectory, "/"); + else + DupString(&mDirectory, "/"); len = PL_strlen(file); if (len==1) @@ -879,33 +879,33 @@ nsStdURL::ParsePath(void) { return DupString(&mFileName, file+1); //+1 to skip the leading slash } - ExtractString(file, &mFileName, 1 /* skip the leading / */, (brk-file-1)); - //Keep pulling out other pieces... - while (brk) - { - char* lastbrk = brk; - brk = PL_strpbrk(lastbrk+1, delimiters); - switch (*lastbrk) - { - case ';' : ExtractString(lastbrk, &mParam, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); - break; - case '?' : ExtractString(lastbrk, &mQuery, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); - break; - case '#' : ExtractString(lastbrk, &mRef, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); - break; - default: - NS_ASSERTION(0, "This just can't be!"); - break; - } - } - return NS_OK; + ExtractString(file, &mFileName, 1 /* skip the leading / */, (brk-file-1)); + //Keep pulling out other pieces... + while (brk) + { + char* lastbrk = brk; + brk = PL_strpbrk(lastbrk+1, delimiters); + switch (*lastbrk) + { + case ';' : ExtractString(lastbrk, &mParam, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); + break; + case '?' : ExtractString(lastbrk, &mQuery, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); + break; + case '#' : ExtractString(lastbrk, &mRef, 1, (brk ? (brk-lastbrk-1) : (len - (lastbrk-file) -1))); + break; + default: + NS_ASSERTION(0, "This just can't be!"); + break; + } + } + return NS_OK; } NS_METHOD nsStdURL::SetSpec(char* i_Spec) { CRTFREEIF(mSpec); - nsresult status = DupString(&mSpec, i_Spec); + nsresult status = DupString(&mSpec, i_Spec); //If spec is being rewritten clean up everything- CRTFREEIF(mScheme); CRTFREEIF(mPreHost); @@ -914,7 +914,7 @@ nsStdURL::SetSpec(char* i_Spec) CRTFREEIF(mPath); CRTFREEIF(mDirectory); CRTFREEIF(mFileName); - CRTFREEIF(mParam); + CRTFREEIF(mParam); CRTFREEIF(mQuery); CRTFREEIF(mRef); return (NS_FAILED(status) ? status : Parse()); @@ -924,16 +924,16 @@ NS_METHOD nsStdURL::SetPath(char* i_Path) { if (mPath) nsCRT::free(mPath); - nsresult status = DupString(&mPath, i_Path); + nsresult status = DupString(&mPath, i_Path); ParsePath(); - ReconstructSpec(); - return status; + ReconstructSpec(); + return status; } void ReplaceDotMess(char* io_Path) { // Replace all /./ with a / - // Also changes all \ to / + // Also changes all \ to / /* Stolen from netlib's mkparse.c. * * modifies a url of the form /foo/../foo1 -> /foo1 @@ -944,18 +944,18 @@ void ReplaceDotMess(char* io_Path) for(; *fwdPtr != '\0'; ++fwdPtr) { - if (*fwdPtr == '\\') - *fwdPtr = '/'; + if (*fwdPtr == '\\') + *fwdPtr = '/'; if (*fwdPtr == '/' && *(fwdPtr+1) == '.' && - (*(fwdPtr+2) == '/' || *(fwdPtr+2) == '\\')) + (*(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) == '\\')) + *(fwdPtr+3) == '\0' || + *(fwdPtr+3) == '\\')) { // remove foo/.. // reverse the urlPtr to the previous slash @@ -979,23 +979,23 @@ void ReplaceDotMess(char* io_Path) NS_METHOD nsStdURL::DirFile(char **o_DirFile) { - if (!o_DirFile) - return NS_ERROR_NULL_POINTER; - - nsString temp; - if (mDirectory) - { - temp = mDirectory; + if (!o_DirFile) + return NS_ERROR_NULL_POINTER; + + nsString temp; + if (mDirectory) + { + temp = mDirectory; // if we have anything in the dir besides just the / if (mDirectory[1]) temp += '/'; - } - if (mFileName) - { - temp += mFileName; - } - *o_DirFile = temp.ToNewCString(); - if (!*o_DirFile) - return NS_ERROR_OUT_OF_MEMORY; - return NS_OK; + } + if (mFileName) + { + temp += mFileName; + } + *o_DirFile = temp.ToNewCString(); + if (!*o_DirFile) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsStdURL.h b/mozilla/netwerk/base/src/nsStdURL.h index 53b3d66a1d4..4ef1c1c948a 100644 --- a/mozilla/netwerk/base/src/nsStdURL.h +++ b/mozilla/netwerk/base/src/nsStdURL.h @@ -39,11 +39,11 @@ public: // nsStdURL methods: nsStdURL(const char* i_Spec, nsISupports* outer=nsnull); - nsStdURL(const nsStdURL& i_URL); + nsStdURL(const nsStdURL& i_URL); virtual ~nsStdURL(); - nsStdURL& operator =(const nsStdURL& otherURL); - PRBool operator ==(const nsStdURL& otherURL) const; + nsStdURL& operator =(const nsStdURL& otherURL); + PRBool operator ==(const nsStdURL& otherURL) const; static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); @@ -58,8 +58,8 @@ public: // nsIURL methods: NS_DECL_NSIURL - /* todo move this to protected later */ - nsresult ParsePath(void); + /* todo move this to protected later */ + nsresult ParsePath(void); protected: nsresult Parse(void); @@ -67,8 +67,8 @@ protected: nsresult ReconstructSpec(void); // Some handy functions - nsresult DupString(char* *o_Destination, char* i_Source); - nsresult ExtractString(char* i_Source, char* *o_Destination, PRUint32 start, PRUint32 length); + nsresult DupString(char* *o_Destination, char* i_Source); + nsresult ExtractString(char* i_Source, char* *o_Destination, PRUint32 start, PRUint32 length); protected: char* mScheme; @@ -77,10 +77,10 @@ protected: PRInt32 mPort; char* mPath; - char* mDirectory; - char* mFileName; - char* mParam; - char* mQuery; + char* mDirectory; + char* mFileName; + char* mParam; + char* mQuery; char* mRef; char* mSpec; @@ -90,107 +90,107 @@ protected: inline NS_METHOD nsStdURL::GetSpec(char* *o_Spec) { - return DupString(o_Spec, mSpec); + return DupString(o_Spec, mSpec); } inline NS_METHOD nsStdURL::GetScheme(char* *o_Scheme) { - return DupString(o_Scheme, mScheme); + return DupString(o_Scheme, mScheme); } inline NS_METHOD nsStdURL::GetPreHost(char* *o_PreHost) { - return DupString(o_PreHost, mPreHost); + return DupString(o_PreHost, mPreHost); } inline NS_METHOD nsStdURL::GetHost(char* *o_Host) { - return DupString(o_Host, mHost); + return DupString(o_Host, mHost); } inline NS_METHOD nsStdURL::GetPath(char* *o_Path) { - return DupString(o_Path, mPath); + return DupString(o_Path, mPath); } inline NS_METHOD nsStdURL::GetDirectory(char* *o_Directory) { - return DupString(o_Directory, mDirectory); + return DupString(o_Directory, mDirectory); } inline NS_METHOD nsStdURL::GetFileName(char* *o_FileName) { - return DupString(o_FileName, mFileName); + return DupString(o_FileName, mFileName); } inline NS_METHOD nsStdURL::GetRef(char* *o_Ref) { - return DupString(o_Ref, mRef); + return DupString(o_Ref, mRef); } inline NS_METHOD nsStdURL::GetParam(char **o_Param) { - return DupString(o_Param, mParam); + return DupString(o_Param, mParam); } inline NS_METHOD nsStdURL::GetQuery(char* *o_Query) { - return DupString(o_Query, mQuery); + return DupString(o_Query, mQuery); } inline NS_METHOD nsStdURL::SetScheme(char* i_Scheme) { if (mScheme) nsCRT::free(mScheme); - nsresult status = DupString(&mScheme, i_Scheme); - ReconstructSpec(); - return status; + nsresult status = DupString(&mScheme, i_Scheme); + ReconstructSpec(); + return status; } inline NS_METHOD nsStdURL::SetPreHost(char* i_PreHost) { if (mPreHost) nsCRT::free(mPreHost); - nsresult status = DupString(&mPreHost, i_PreHost); - ReconstructSpec(); - return status; + nsresult status = DupString(&mPreHost, i_PreHost); + ReconstructSpec(); + return status; } inline NS_METHOD nsStdURL::SetHost(char* i_Host) { if (mHost) nsCRT::free(mHost); - nsresult status = DupString(&mHost, i_Host); - ReconstructSpec(); - return status; + nsresult status = DupString(&mHost, i_Host); + ReconstructSpec(); + return status; } inline NS_METHOD nsStdURL::GetPort(PRInt32 *aPort) { - if (aPort) - { - *aPort = mPort; - return NS_OK; - } - return NS_ERROR_NULL_POINTER; + if (aPort) + { + *aPort = mPort; + return NS_OK; + } + return NS_ERROR_NULL_POINTER; } inline NS_METHOD nsStdURL::SetPort(PRInt32 aPort) { - mPort = aPort; - ReconstructSpec(); - return NS_OK; + mPort = aPort; + ReconstructSpec(); + return NS_OK; } #endif // nsStdURL_h__ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl index 207ad02de69..206907d217a 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl @@ -41,7 +41,7 @@ interface nsIHTTPChannel : nsIChannel */ string GetRequestHeader(in nsIAtom headerAtom); void SetRequestHeader(in nsIAtom headerAtom, in string value); - nsISimpleEnumerator GetRequestHeaderEnumerator(); + nsISimpleEnumerator GetRequestHeaderEnumerator(); void SetRequestMethod(in unsigned long method); // NS_IMETHOD SetRequestMethod(HTTPMethod i_Method=HM_GET) = 0; @@ -57,7 +57,7 @@ interface nsIHTTPChannel : nsIChannel protocol instance. */ string GetResponseHeader(in nsIAtom headerAtom); - nsISimpleEnumerator GetResponseHeaderEnumerator(); + nsISimpleEnumerator GetResponseHeaderEnumerator(); readonly attribute unsigned long ResponseStatus; diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl b/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl index 84ea04f72d9..e6d03fbdbf1 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl @@ -27,27 +27,27 @@ [uuid(8D9430E0-0FB4-11d3-9DE6-0010A4053FD0)] interface nsIHTTPNotify : nsINetNotify { /* Before an HTTP request is sent to the server, this method is called. - * The implementor of this method can the chose to set any additional - * headers for this request before the request is actually sent to the - * server. The HTTP PI (protocol interpreter) blocks on this call until - * it returns. + * The implementor of this method can the chose to set any additional + * headers for this request before the request is actually sent to the + * server. The HTTP PI (protocol interpreter) blocks on this call until + * it returns. * * ARGUMENTS: - * aContext: An nsISupports pointer, that should be queried for nsIHTTPChannel. + * aContext: An nsISupports pointer, that should be queried for nsIHTTPChannel. * * RETURNS: nsresult - */ + */ void ModifyRequest(in nsISupports aContext); - /* After an HTTP server response is received, this method is called - * asyncronously. The implementor can interrogate the nsIHTTPChannel as - * it deems necessary. The HTTP PI (protocol interpreter) doesn't wait - * for this method to return. - * - * ARGUMENTS: - * aContext: An nsISupport pointer, that should be queried for nsIHTTPChannel. - * - * RETURNS: nsresult - */ - void AsyncExamineResponse(in nsISupports aContext); -}; \ No newline at end of file + /* After an HTTP server response is received, this method is called + * asyncronously. The implementor can interrogate the nsIHTTPChannel as + * it deems necessary. The HTTP PI (protocol interpreter) doesn't wait + * for this method to return. + * + * ARGUMENTS: + * aContext: An nsISupport pointer, that should be queried for nsIHTTPChannel. + * + * RETURNS: nsresult + */ + void AsyncExamineResponse(in nsISupports aContext); +}; diff --git a/mozilla/netwerk/protocol/http/src/kHTTPStates.h b/mozilla/netwerk/protocol/http/src/kHTTPStates.h index d5ca621bd97..a00029c56d3 100644 --- a/mozilla/netwerk/protocol/http/src/kHTTPStates.h +++ b/mozilla/netwerk/protocol/http/src/kHTTPStates.h @@ -38,4 +38,5 @@ typedef enum _HTTPStates DONE } HTTPStates; -#endif //_kHTTPStates_h_ \ No newline at end of file +#endif //_kHTTPStates_h_ + diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index a0741838ae5..8f83540d849 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -287,8 +287,8 @@ nsHTTPChannel::GetContentType(char * *aContentType) } // if all else fails treat it as text/html? - if (!*aContentType) - *aContentType = nsCRT::strdup(DUMMY_TYPE); + if (!*aContentType) + *aContentType = nsCRT::strdup(DUMMY_TYPE); if (!*aContentType) { rv = NS_ERROR_OUT_OF_MEMORY; } else { @@ -372,8 +372,8 @@ nsHTTPChannel::GetResponseStatus(PRUint32 *o_Status) { if (!mConnected) Open(); - if (mResponse) - return mResponse->GetStatus(o_Status); + if (mResponse) + return mResponse->GetStatus(o_Status); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? } @@ -382,8 +382,8 @@ nsHTTPChannel::GetResponseString(char* *o_String) { if (!mConnected) Open(); - if (mResponse) - return mResponse->GetStatusString(o_String); + if (mResponse) + return mResponse->GetStatusString(o_String); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index 42cf5bbe196..0da9b5f1eae 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -47,7 +47,7 @@ class nsIChannel; class nsHTTPChannel; class nsHTTPHandler : public nsIHTTPProtocolHandler - //, public nsIProxy + //, public nsIProxy { public: @@ -69,7 +69,7 @@ public: /* The GetScheme function uniquely identifies the scheme this handler - is associated with. + is associated with. */ NS_IMETHOD GetScheme(char * *o_Scheme) { @@ -101,7 +101,7 @@ public: /* Get and Set the Proxy Port - -1 on Set call indicates switch to default port + -1 on Set call indicates switch to default port */ NS_IMETHOD_(PRInt32) GetProxyPort(void) const {return NS_ERROR_NOT_IMPLEMENTED;}; @@ -139,9 +139,9 @@ protected: nsHTTPHandler(void); virtual ~nsHTTPHandler(); - // This is the array of connections that the handler thread maintains to + // This is the array of connections that the handler thread maintains to // verify unique requests. - nsCOMPtr mConnections; + nsCOMPtr mConnections; nsCOMPtr mPendingChannelList; nsCOMPtr mTransportList; }; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp index 11d9f82ae13..6a58a57cbb3 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -43,7 +43,7 @@ extern PRLogModuleInfo* gHTTPLog; #endif /* PR_LOGGING */ nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURL, HTTPMethod i_Method, - nsIChannel* i_pTransport): + nsIChannel* i_pTransport): mMethod(i_Method), mVersion(HTTP_ONE_ZERO), mRequest(nsnull) @@ -58,14 +58,14 @@ nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURL, HTTPMethod i_Method, mTransport = i_pTransport; NS_IF_ADDREF(mTransport); - // Send Host header by default - if (HTTP_ZERO_NINE != mVersion) - { - nsXPIDLCString host; - NS_ASSERTION(mURI, "No URI for the request!!"); - mURI->GetHost(getter_Copies(host)); + // Send Host header by default + if (HTTP_ZERO_NINE != mVersion) + { + nsXPIDLCString host; + NS_ASSERTION(mURI, "No URI for the request!!"); + mURI->GetHost(getter_Copies(host)); SetHeader(nsHTTPAtoms::Host, host); - } + } } nsHTTPRequest::~nsHTTPRequest() @@ -284,10 +284,10 @@ nsHTTPRequest::Build() } } - nsCOMPtr stream; - NS_ASSERTION(mConnection, "Hee ha!"); - if (NS_FAILED(mConnection->GetPostDataStream(getter_AddRefs(stream)))) - return NS_ERROR_FAILURE; + nsCOMPtr stream; + NS_ASSERTION(mConnection, "Hee ha!"); + if (NS_FAILED(mConnection->GetPostDataStream(getter_AddRefs(stream)))) + return NS_ERROR_FAILURE; // Currently nsIPostStreamData contains the header info and the data. // So we are forced to putting this here in the end. @@ -295,34 +295,34 @@ nsHTTPRequest::Build() // TODO- Gagan if (stream) - { - NS_ASSERTION(mMethod == HM_POST, "Post data without a POST method?"); + { + NS_ASSERTION(mMethod == HM_POST, "Post data without a POST method?"); - PRUint32 length; - stream->GetLength(&length); + PRUint32 length; + stream->GetLength(&length); - // TODO Change reading from nsIInputStream to nsIBuffer - char* tempBuff = new char[length+1]; - if (!tempBuff) - return NS_ERROR_OUT_OF_MEMORY; - if (NS_FAILED(stream->Read(tempBuff, length, &length))) + // TODO Change reading from nsIInputStream to nsIBuffer + char* tempBuff = new char[length+1]; + if (!tempBuff) + return NS_ERROR_OUT_OF_MEMORY; + if (NS_FAILED(stream->Read(tempBuff, length, &length))) { NS_ASSERTION(0, "Failed to read post data!"); return NS_ERROR_FAILURE; } else - { + { tempBuff[length] = '\0'; PRUint32 writtenLength; - out->Write(tempBuff, length, &writtenLength); + out->Write(tempBuff, length, &writtenLength); #ifdef DEBUG_gagan printf(tempBuff); #endif - // ASSERT that you wrote length = stream's length + // ASSERT that you wrote length = stream's length NS_ASSERTION(writtenLength == length, "Failed to write post data!"); - } - delete[] tempBuff; - } + } + delete[] tempBuff; + } else { @@ -344,14 +344,14 @@ nsHTTPRequest::Build() NS_METHOD nsHTTPRequest::Clone(const nsHTTPRequest* *o_Request) const { - return NS_ERROR_FAILURE; + return NS_ERROR_FAILURE; } NS_METHOD nsHTTPRequest::SetMethod(HTTPMethod i_Method) { mMethod = i_Method; - return NS_OK; + return NS_OK; } HTTPMethod @@ -363,13 +363,13 @@ nsHTTPRequest::GetMethod(void) const NS_METHOD nsHTTPRequest::SetPriority() { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_NOT_IMPLEMENTED; } NS_METHOD nsHTTPRequest::GetPriority() { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp index 490a6c33af7..00ebf6f7a7f 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp @@ -58,7 +58,7 @@ nsresult nsHTTPResponse::GetContentLength(PRInt32* o_Value) nsXPIDLCString value; nsAutoString str; - mHeaders.GetHeader(nsHTTPAtoms::Content_Length, getter_Copies(value)); + mHeaders.GetHeader(nsHTTPAtoms::Content_Length, getter_Copies(value)); str = value; *o_Value = str.ToInteger(&err); return NS_OK; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index efb4d7e4392..64dcc870019 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -100,7 +100,7 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel, nsresult rv = NS_OK; PRUint32 actualBytesRead; NS_ASSERTION(i_pStream, "No stream supplied by the transport!"); - nsCOMPtr bufferInStream = do_QueryInterface(i_pStream); + nsCOMPtr bufferInStream = do_QueryInterface(i_pStream); PR_LOG(gHTTPLog, PR_LOG_DEBUG, ("nsHTTPResponseListener::OnDataAvailable [this=%x].\n" @@ -153,7 +153,7 @@ nsHTTPResponseListener::OnDataAvailable(nsIChannel* channel, #else rv = ParseHTTPHeader(bufferInStream, i_Length, &actualBytesRead); #endif - NS_ASSERTION(i_Length - actualBytesRead <= i_Length, "wrap around"); + NS_ASSERTION(i_Length - actualBytesRead <= i_Length, "wrap around"); i_Length -= actualBytesRead; } @@ -806,13 +806,12 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode) if (NS_SUCCEEDED(rv)) { #if defined(PR_LOGGING) - char *newURLSpec; - - newURLSpec = nsnull; + char *newURLSpec = nsnull; newURL->GetSpec(&newURLSpec); PR_LOG(gHTTPLog, PR_LOG_DEBUG, ("ProcessRedirect [this=%x].\tRedirecting to: %s.\n", this, newURLSpec)); + CRTFREEIF(newURLSpec); #endif /* PR_LOGGING */ #if 0 // Expanded inline to avoid linking with neckoutils.... (temporary)