BOOL CMapiApi::GetStringFromProp( LPSPropValue pVal, nsCString& val, BOOL delVal) { BOOL bResult = TRUE; if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_STRING8)) val = pVal->Value.lpszA; else if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_UNICODE)) LossyCopyUTF16toASCII((PRUnichar *) pVal->Value.lpszW, val); else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) val.Truncate(); else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) { val.Truncate(); bResult = FALSE; } else { if (pVal) { MAPI_TRACE1( "GetStringFromProp: invalid value, expecting string - %d\n", (int) PROP_TYPE( pVal->ulPropTag)); } else { MAPI_TRACE0( "GetStringFromProp: invalid value, expecting string, got null pointer\n"); } val.Truncate(); bResult = FALSE; } if (pVal && delVal) MAPIFreeBuffer( pVal); return( bResult); }
void ExtractMetaCharset(const wchar_t* body, int bodySz, /*out*/nsCString& charset) { charset.Truncate(); const wchar_t* body_end = body+bodySz; const wchar_t str_eohd[] = L"/head"; const wchar_t *str_eohd_end = str_eohd+sizeof(str_eohd)/sizeof(str_eohd[0])-1; const wchar_t* eohd_pos = std::search(body, body_end, str_eohd, str_eohd_end, CaseInsensitiveComp); if (eohd_pos == body_end) // No header! return; const wchar_t str_chset[] = L"charset="; const wchar_t *str_chset_end = str_chset + sizeof(str_chset)/sizeof(str_chset[0])-1; const wchar_t* chset_pos = std::search(body, eohd_pos, str_chset, str_chset_end, CaseInsensitiveComp); if (chset_pos == eohd_pos) // No charset! return; chset_pos += 8; // remove everything from the string after the next ; or " or space, // whichever comes first. // The inital sting looks something like // <META content="text/html; charset=utf-8" http-equiv=Content-Type> // <META content="text/html; charset=utf-8;" http-equiv=Content-Type> // <META content="text/html; charset=utf-8 ;" http-equiv=Content-Type> // <META content="text/html; charset=utf-8 " http-equiv=Content-Type> const wchar_t term[] = L";\" ", *term_end= term+sizeof(term)/sizeof(term[0])-1; const wchar_t* chset_end = std::find_first_of(chset_pos, eohd_pos, term, term_end); if (chset_end != eohd_pos) LossyCopyUTF16toASCII(Substring(chset_pos, chset_end), charset); }
void nsEudoraAddress::ExtractNoteField( nsCString& note, nsCString& value, const char *pFieldName) { value.Truncate(); nsCString field("<"); field.Append( pFieldName); field.Append( ':'); /* this is a bit of a cheat, but there's no reason it won't work fine for us, even better than Eudora in some cases! */ PRInt32 idx = note.Find( field); if (idx != -1) { idx += field.Length(); PRInt32 endIdx = note.FindChar( '>', idx); if (endIdx == -1) endIdx = note.Length() - 1; note.Mid( value, idx, endIdx - idx); idx -= field.Length(); nsCString tempL; if (idx) note.Left( tempL, idx); nsCString tempR; note.Right( tempR, note.Length() - endIdx - 1); note = tempL; note.Append( tempR); } }
void nsOutlookMail::SetDefaultContentType(CMapiMessage &msg, nsCString &cType) { cType.Truncate(); // MAPI doesn't seem to return the entire body data (ie, multiple parts) for // content type "multipart/alternative", instead it only returns the body data // for a particular part. For this reason we'll need to set the content type // here. Same thing when conten type is not being set at all. if (msg.GetMimeContentLen()) { // If content type is not multipart/alternative or mixed or related, return. // for a multipart alternative with attachments, we get multipart mixed! if (PL_strcasecmp(msg.GetMimeContent(), "multipart/alternative") && PL_strcasecmp(msg.GetMimeContent(), "multipart/mixed") && PL_strcasecmp(msg.GetMimeContent(), "multipart/related")) return; // For multipart/alternative, if no body or boundary, // or boundary is found in body then return. const char *body = msg.GetBody(); const char *boundary = msg.GetMimeBoundary(); if (!body || !boundary || strstr(body, boundary)) return; } // Now default the content type to text/html or text/plain // depending whether or not the body data is html. cType = msg.BodyIsHtml() ? "text/html" : "text/plain"; }
static nsresult ExtractAttribute(nsIDOMNode* aNode, const char* aAttribute, const char* aNamespaceURI, nsCString& aValue) { nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode); MOZ_ASSERT(element); // Find the named URI attribute on the (element) node and store // a reference to the URI that maps onto a local file name nsCOMPtr<nsIDOMMozNamedAttrMap> attrMap; nsresult rv = element->GetAttributes(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); NS_ConvertASCIItoUTF16 namespaceURI(aNamespaceURI); NS_ConvertASCIItoUTF16 attribute(aAttribute); nsCOMPtr<nsIDOMAttr> attr; rv = attrMap->GetNamedItemNS(namespaceURI, attribute, getter_AddRefs(attr)); NS_ENSURE_SUCCESS(rv, rv); if (attr) { nsAutoString value; rv = attr->GetValue(value); NS_ENSURE_SUCCESS(rv, rv); aValue = NS_ConvertUTF16toUTF8(value); } else { aValue.Truncate(); } return NS_OK; }
// takes a string like ?size=32&contentType=text/html and returns a new string // containing just the attribute value. i.e you could pass in this string with // an attribute name of 'size=', this will return 32 // Assumption: attribute pairs in the string are separated by '&'. void extractAttributeValue(const char * searchString, const char * attributeName, nsCString& result) { //NS_ENSURE_ARG_POINTER(extractAttributeValue); result.Truncate(); if (searchString && attributeName) { // search the string for attributeName uint32_t attributeNameSize = strlen(attributeName); const char * startOfAttribute = PL_strcasestr(searchString, attributeName); if (startOfAttribute && ( *(startOfAttribute-1) == '?' || *(startOfAttribute-1) == '&') ) { startOfAttribute += attributeNameSize; // skip over the attributeName if (*startOfAttribute) // is there something after the attribute name { const char * endofAttribute = strchr(startOfAttribute, '&'); if (endofAttribute) result.Assign(Substring(startOfAttribute, endofAttribute)); else result.Assign(startOfAttribute); } // if we have a attribute value } // if we have a attribute name } // if we got non-null search string and attribute name values }
// i18n helper routines nsresult nsEncodingFormSubmission::EncodeVal(const nsAString& aStr, nsCString& aOut, bool aHeaderEncode) { if (mEncoder && !aStr.IsEmpty()) { aOut.Truncate(); nsresult rv = mEncoder->Convert(PromiseFlatString(aStr).get(), getter_Copies(aOut)); NS_ENSURE_SUCCESS(rv, rv); } else { // fall back to UTF-8 CopyUTF16toUTF8(aStr, aOut); } if (aHeaderEncode) { aOut.Adopt(nsLinebreakConverter:: ConvertLineBreaks(aOut.get(), nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakSpace)); aOut.ReplaceSubstring(NS_LITERAL_CSTRING("\""), NS_LITERAL_CSTRING("\\\"")); } return NS_OK; }
int32_t nsMsgBodyHandler::GetNextFilterLine(nsCString &buf) { // m_nextHdr always points to the next header in the list....the list is NULL terminated... uint32_t numBytesCopied = 0; if (m_headersSize > 0) { // #mscott. Ugly hack! filter headers list have CRs & LFs inside the NULL delimited list of header // strings. It is possible to have: To NULL CR LF From. We want to skip over these CR/LFs if they start // at the beginning of what we think is another header. while (m_headersSize > 0 && (m_headers[0] == '\r' || m_headers[0] == '\n' || m_headers[0] == ' ' || m_headers[0] == '\0')) { m_headers++; // skip over these chars... m_headersSize--; } if (m_headersSize > 0) { numBytesCopied = strlen(m_headers) + 1 ; buf.Assign(m_headers); m_headers += numBytesCopied; // be careful...m_headersSize is unsigned. Don't let it go negative or we overflow to 2^32....*yikes* if (m_headersSize < numBytesCopied) m_headersSize = 0; else m_headersSize -= numBytesCopied; // update # bytes we have read from the headers list return (int32_t) numBytesCopied; } } else if (m_headersSize == 0) { buf.Truncate(); } return -1; }
nsresult nsGopherContentStream::ParseTypeAndSelector(char &type, nsCString &selector) { nsCAutoString buffer; nsresult rv = mChannel->URI()->GetPath(buffer); // unescaped down below if (NS_FAILED(rv)) return rv; // No path given if (buffer[0] == '\0' || (buffer[0] == '/' && buffer[1] == '\0')) { type = '1'; selector.Truncate(); } else { NS_ENSURE_STATE(buffer[1] != '\0'); type = buffer[1]; // Ignore leading '/' // Do it this way in case selector contains embedded nulls after // unescaping. char *sel = buffer.BeginWriting() + 2; PRInt32 count = nsUnescapeCount(sel); selector.Assign(sel, count); // NOTE: FindCharInSet cannot be used to search for a null byte. if (selector.FindCharInSet("\t\n\r") != kNotFound || selector.FindChar('\0') != kNotFound) { // gopher selectors cannot containt tab, cr, lf, or \0 return NS_ERROR_MALFORMED_URI; } } return NS_OK; }
nsresult nsAboutCache::ParseURI(nsIURI * uri, nsCString &deviceID) { // // about:cache[?device=string] // nsresult rv; deviceID.Truncate(); nsCAutoString path; rv = uri->GetPath(path); if (NS_FAILED(rv)) return rv; nsACString::const_iterator start, valueStart, end; path.BeginReading(start); path.EndReading(end); valueStart = end; if (!FindInReadable(NS_LITERAL_CSTRING("?device="), start, valueStart)) return NS_OK; deviceID.Assign(Substring(valueStart, end)); return NS_OK; }
nsresult nsVCardAddress::ReadRecord( nsILineInputStream *aLineStream, nsCString &aRecord, bool *aMore) { bool more = true; nsresult rv; nsCString line; aRecord.Truncate(); // read BEGIN:VCARD rv = aLineStream->ReadLine(line, &more); if (!line.LowerCaseEqualsLiteral("begin:vcard")) { IMPORT_LOG0("*** Expected case-insensitive BEGIN:VCARD at start of vCard\n"); rv = NS_ERROR_FAILURE; *aMore = more; return rv; } aRecord.Append(line); // read until END:VCARD do { if (!more) { IMPORT_LOG0("*** Expected case-insensitive END:VCARD at start of vCard\n"); rv = NS_ERROR_FAILURE; break; } rv = aLineStream->ReadLine(line, &more); aRecord.AppendLiteral(MSG_LINEBREAK); aRecord.Append(line); } while (!line.LowerCaseEqualsLiteral("end:vcard")); *aMore = more; return rv; }
static void MorkUnescape(const nsCSubstring &aString, nsCString &aResult) { PRUint32 len = aString.Length(); // We optimize for speed over space here -- size the result buffer to // the size of the source, which is an upper bound on the size of the // unescaped string. // FIXME: Mork assume there will never be errors if (!EnsureStringLength(aResult, len)) { aResult.Truncate(); return; // out of memory. } char *result = aResult.BeginWriting(); const char *source = aString.BeginReading(); const char *sourceEnd = source + len; const char *startPos = nsnull; PRUint32 bytes; for (; source < sourceEnd; ++source) { char c = *source; if (c == '\\') { if (startPos) { bytes = source - startPos; memcpy(result, startPos, bytes); result += bytes; startPos = nsnull; } if (source < sourceEnd - 1) { *(result++) = *(++source); } } else if (c == '$') { if (startPos) { bytes = source - startPos; memcpy(result, startPos, bytes); result += bytes; startPos = nsnull; } if (source < sourceEnd - 2) { // Would be nice to use ToInteger() here, but it currently // requires a null-terminated string. char c2 = *(++source); char c3 = *(++source); if (ConvertChar(&c2) && ConvertChar(&c3)) { *(result++) = ((c2 << 4) | c3); } } } else if (!startPos) { startPos = source; } } if (startPos) { bytes = source - startPos; memcpy(result, startPos, bytes); result += bytes; } aResult.SetLength(result - aResult.BeginReading()); }
void nsUrlClassifierDBServiceWorker::ResetUpdate() { LOG(("ResetUpdate")); mUpdateWait = 0; mUpdateStatus = NS_OK; mUpdateObserver = nsnull; mUpdateClientKey.Truncate(); }
void nsEudoraWin32::GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff) { DWORD valSize; int idx; nsCString tStr; serverName.Truncate(); userName.Truncate(); valSize = ::GetPrivateProfileString( pSection, "PopServer", "", pBuff, kIniValueSize, pIni); if (valSize) serverName = pBuff; else { valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni); if (valSize) { serverName = pBuff; idx = serverName.FindChar( '@'); if (idx != -1) { serverName.Right( tStr, serverName.Length() - idx - 1); serverName = tStr; } } } valSize = ::GetPrivateProfileString( pSection, "LoginName", "", pBuff, kIniValueSize, pIni); if (valSize) userName = pBuff; else { valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni); if (valSize) { userName = pBuff; idx = userName.FindChar( '@'); if (idx != -1) { userName.Left( tStr, idx); userName = tStr; } } } }
NS_IMETHODIMP nsIncrementalDownload::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsIChannel *newChannel, uint32_t flags, nsIAsyncVerifyRedirectCallback *cb) { // In response to a redirect, we need to propagate the Range header. See bug // 311595. Any failure code returned from this function aborts the redirect. nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(oldChannel); NS_ENSURE_STATE(http); nsCOMPtr<nsIHttpChannel> newHttpChannel = do_QueryInterface(newChannel); NS_ENSURE_STATE(newHttpChannel); NS_NAMED_LITERAL_CSTRING(rangeHdr, "Range"); nsresult rv = ClearRequestHeader(newHttpChannel); if (NS_FAILED(rv)) return rv; // If we didn't have a Range header, then we must be doing a full download. nsAutoCString rangeVal; http->GetRequestHeader(rangeHdr, rangeVal); if (!rangeVal.IsEmpty()) { rv = newHttpChannel->SetRequestHeader(rangeHdr, rangeVal, false); NS_ENSURE_SUCCESS(rv, rv); } // A redirection changes the validator mPartialValidator.Truncate(); if (mCacheBust) { newHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Cache-Control"), NS_LITERAL_CSTRING("no-cache"), false); newHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Pragma"), NS_LITERAL_CSTRING("no-cache"), false); } // Prepare to receive callback mRedirectCallback = cb; mNewRedirectChannel = newChannel; // Give the observer a chance to see this redirect notification. nsCOMPtr<nsIChannelEventSink> sink = do_GetInterface(mObserver); if (sink) { rv = sink->AsyncOnChannelRedirect(oldChannel, newChannel, flags, this); if (NS_FAILED(rv)) { mRedirectCallback = nullptr; mNewRedirectChannel = nullptr; } return rv; } (void) OnRedirectVerifyCallback(NS_OK); return NS_OK; }
void nsMorkReader::NormalizeValue(nsCString &aValue) const { PRUint32 len = aValue.Length(); if (len == 0) { return; } const nsCSubstring &str = Substring(aValue, 1, len - 1); char c = aValue[0]; if (c == '^') { if (!mValueMap.Get(str, &aValue)) { aValue.Truncate(0); } } else if (c == '=') { aValue.Assign(str); } else { aValue.Truncate(0); } }
NS_INTERFACE_MAP_END NS_IMETHODIMP OperationStreamListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { LOG(("OperationStreamListener::OnStartRequest() entered")); mBody.Truncate(); return NS_OK; }
void nsIndexedToHTML::FormatSizeString(int64_t inSize, nsCString& outSizeString) { outSizeString.Truncate(); if (inSize > int64_t(0)) { // round up to the nearest Kilobyte int64_t upperSize = (inSize + int64_t(1023)) / int64_t(1024); outSizeString.AppendInt(upperSize); outSizeString.AppendLiteral(" KB"); } }
void SiteHSTSState::ToString(nsCString& aString) { aString.Truncate(); aString.AppendInt(mHSTSExpireTime); aString.Append(','); aString.AppendInt(mHSTSState); aString.Append(','); aString.AppendInt(static_cast<uint32_t>(mHSTSIncludeSubdomains)); }
static void NSResultToNameAndMessage(nsresult aNSResult, nsCString& aName, nsCString& aMessage, uint16_t* aCode) { aName.Truncate(); aMessage.Truncate(); *aCode = 0; for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) { if (aNSResult == sDOMErrorMsgMap[idx].mNSResult) { aName.Rebind(sDOMErrorMsgMap[idx].mName, strlen(sDOMErrorMsgMap[idx].mName)); aMessage.Rebind(sDOMErrorMsgMap[idx].mMessage, strlen(sDOMErrorMsgMap[idx].mMessage)); *aCode = sDOMErrorMsgMap[idx].mCode; return; } } NS_WARNING("Huh, someone is throwing non-DOM errors using the DOM module!"); }
/* void Init (in string uri); */ NS_IMETHODIMP nsRDFDataSourceDataSource::Init(const char *uri) { nsresult rv; mURI = uri; // cut off "rdf:datasource?" NS_NAMED_LITERAL_CSTRING(prefix, "rdf:datasource"); nsAutoCString mInnerURI; mInnerURI = Substring(mURI, prefix.Length() + 1); // bail if datasorce is empty or we're trying to inspect ourself if (mInnerURI.IsEmpty() || mInnerURI == prefix) { mURI.Truncate(); return NS_ERROR_INVALID_ARG; } nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv)); rv = rdf->GetDataSource(mInnerURI.get(), getter_AddRefs(mDataSource)); if (NS_FAILED(rv)) { mURI.Truncate(); NS_WARNING("Could not get inner datasource"); return rv; } // get RDF resources if (!kNC_Name) { rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Name), &kNC_Name); rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Child), &kNC_Child); rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Value), &kNC_Value); } #ifdef DEBUG_alecf printf("nsRDFDataSourceDataSource::Init(%s)\n", uri); #endif return NS_OK; }
static inline void GetAuthKey(const char *scheme, const char *host, int32_t port, uint32_t appId, bool inBrowserElement, nsCString &key) { key.Truncate(); key.AppendInt(appId); key.Append(':'); key.AppendInt(inBrowserElement); key.Append(':'); key.Append(scheme); key.AppendLiteral("://"); key.Append(host); key.Append(':'); key.AppendInt(port); }
static void getUTF8StringArgument(JSContext *cx, JSObject *obj, PRUint16 argNum, uintN argc, jsval *argv, nsCString& aRetval) { if (argc <= argNum || !JSVAL_IS_STRING(argv[argNum])) { JS_ReportError(cx, "String argument expected"); aRetval.Truncate(); return; } /* * We don't want to use JS_ValueToString because we want to be able * to have an object to represent a target in subsequent versions. */ JSString *str = JSVAL_TO_STRING(argv[argNum]); if (!str) { aRetval.Truncate(); return; } PRUnichar *data = (PRUnichar*)JS_GetStringChars(str); CopyUTF16toUTF8(data, aRetval); }
void SiteHPKPState::ToString(nsCString& aString) { aString.Truncate(); aString.AppendInt(mExpireTime); aString.Append(','); aString.AppendInt(mState); aString.Append(','); aString.AppendInt(static_cast<uint32_t>(mIncludeSubdomains)); aString.Append(','); for (unsigned int i = 0; i < mSHA256keys.Length(); i++) { aString.Append(mSHA256keys[i]); } }
nsresult ImportMessageRunnable::WriteHeaders(nsCString &aHeaders, nsIOutputStream *aOutputStream) { nsresult rv; uint32_t writtenBytes = 0; rv = aOutputStream->Write(FROM_LINE, strlen(FROM_LINE), &writtenBytes); NS_ENSURE_SUCCESS(rv, rv); rv = aOutputStream->Write(aHeaders.get(), aHeaders.Length(), &writtenBytes); NS_ENSURE_SUCCESS(rv, rv); rv = aOutputStream->Write(MSG_LINEBREAK, strlen(MSG_LINEBREAK), &writtenBytes); NS_ENSURE_SUCCESS(rv, rv); aHeaders.Truncate(); return NS_OK; }
/** * Free all used memory and close stream. */ NS_IMETHODIMP nsGIOInputStream::Close() { if (mStream) { g_object_unref(mStream); mStream = nullptr; } if (mHandle) { g_object_unref(mHandle); mHandle = nullptr; } if (mDirList) { // Destroy the list of GIOFileInfo objects... g_list_foreach(mDirList, (GFunc) g_object_unref, nullptr); g_list_free(mDirList); mDirList = nullptr; mDirListPtr = nullptr; } if (mChannel) { nsresult rv = NS_OK; nsCOMPtr<nsIThread> thread = do_GetMainThread(); if (thread) rv = NS_ProxyRelease(thread, mChannel); NS_ASSERTION(thread && NS_SUCCEEDED(rv), "leaking channel reference"); mChannel = nullptr; (void) rv; } mSpec.Truncate(); // free memory // Prevent future reads from re-opening the handle. if (NS_SUCCEEDED(mStatus)) mStatus = NS_BASE_STREAM_CLOSED; return NS_OK; }
static void ExtractAttribute(Element* aElement, const char* aAttribute, const char* aNamespaceURI, nsCString& aValue) { // Find the named URI attribute on the (element) node and store // a reference to the URI that maps onto a local file name RefPtr<nsDOMAttributeMap> attrMap = aElement->Attributes(); NS_ConvertASCIItoUTF16 namespaceURI(aNamespaceURI); NS_ConvertASCIItoUTF16 attribute(aAttribute); RefPtr<dom::Attr> attr = attrMap->GetNamedItemNS(namespaceURI, attribute); if (attr) { nsAutoString value; attr->GetValue(value); CopyUTF16toUTF8(value, aValue); } else { aValue.Truncate(); } }
nsresult GenerateGUID(nsCString& _guid) { _guid.Truncate(); // Request raw random bytes and base64url encode them. For each set of three // bytes, we get one character. const PRUint32 kRequiredBytesLength = static_cast<PRUint32>(GUID_LENGTH / 4 * 3); PRUint8 buffer[kRequiredBytesLength]; nsresult rv = GenerateRandomBytes(kRequiredBytesLength, buffer); NS_ENSURE_SUCCESS(rv, rv); rv = Base64urlEncode(buffer, kRequiredBytesLength, _guid); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(_guid.Length() == GUID_LENGTH, "GUID is not the right size!"); return NS_OK; }
nsresult nsTextAddress::ReadRecord(nsILineInputStream *aLineStream, nsCString &aLine, bool *aMore) { bool more = true; PRUint32 numQuotes = 0; nsresult rv; nsCString line; // ensure aLine is empty aLine.Truncate(); do { if (!more) { // No more, so we must have an incorrect file. rv = NS_ERROR_FAILURE; } else { // Read the line and append it rv = aLineStream->ReadLine(line, &more); if (NS_SUCCEEDED(rv)) { if (!aLine.IsEmpty()) aLine.AppendLiteral(MSG_LINEBREAK); aLine.Append(line); #ifdef MOZILLA_INTERNAL_API numQuotes += line.CountChar('"'); #else const char *begin, *end; line.BeginReading(&begin, &end); for (const char *current = begin; current < end; ++current) { if (*current == '"') ++numQuotes; } #endif } } // Continue whilst everything is ok, and we have an odd number of quotes. } while (NS_SUCCEEDED(rv) && (numQuotes % 2 != 0)); *aMore = more; return rv; }
PRInt32 nsEudoraAddress::GetAliasName( const char *pLine, PRInt32 len, nsCString& name) { name.Truncate(); if (!len) return( 0); const char *pStart = pLine; char end[2] = {' ', '\t'}; if (*pLine == '"') { pLine++; pStart++; len--; end[0] = '"'; end[1] = 0; } PRInt32 cnt = 0; while (len) { if ((*pLine == end[0]) || (*pLine == end[1])) break; len--; pLine++; cnt++; } if (cnt) name.Append( pStart, cnt); if (end[0] == '"') { cnt++; if (len && (*pLine == '"')) { cnt++; pLine++; len--; } } cnt += CountWhiteSpace( pLine, len); return( cnt); }