/* AString createFilter (in unsigned long aMaxSize, in AString aPattern, in AString aPrefix, in AString aSuffix, in AString aAttr, in AString aValue); */ NS_IMETHODIMP nsLDAPService::CreateFilter(uint32_t aMaxSize, const nsACString & aPattern, const nsACString & aPrefix, const nsACString & aSuffix, const nsACString & aAttr, const nsACString & aValue, nsACString & _retval) { if (!aMaxSize) { return NS_ERROR_INVALID_ARG; } // figure out how big of an array we're going to need for the tokens, // including a trailing NULL, and allocate space for it. // const char *iter = aValue.BeginReading(); const char *iterEnd = aValue.EndReading(); uint32_t numTokens = CountTokens(iter, iterEnd); char **valueWords; valueWords = static_cast<char **>(nsMemory::Alloc((numTokens + 1) * sizeof(char *))); if (!valueWords) { return NS_ERROR_OUT_OF_MEMORY; } // build the array of values // uint32_t curToken = 0; while (iter != iterEnd && curToken < numTokens ) { valueWords[curToken] = NextToken(&iter, &iterEnd); if ( !valueWords[curToken] ) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(curToken, valueWords); return NS_ERROR_OUT_OF_MEMORY; } curToken++; } valueWords[numTokens] = 0; // end of array signal to LDAP C SDK // make buffer to be used for construction // char *buffer = static_cast<char *>(nsMemory::Alloc(aMaxSize * sizeof(char))); if (!buffer) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numTokens, valueWords); return NS_ERROR_OUT_OF_MEMORY; } // create the filter itself // nsresult rv; int result = ldap_create_filter(buffer, aMaxSize, const_cast<char *>(PromiseFlatCString(aPattern).get()), const_cast<char *>(PromiseFlatCString(aPrefix).get()), const_cast<char *>(PromiseFlatCString(aSuffix).get()), const_cast<char *>(PromiseFlatCString(aAttr).get()), const_cast<char *>(PromiseFlatCString(aValue).get()), valueWords); switch (result) { case LDAP_SUCCESS: rv = NS_OK; break; case LDAP_SIZELIMIT_EXCEEDED: PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("nsLDAPService::CreateFilter(): " "filter longer than max size of %d generated", aMaxSize)); rv = NS_ERROR_NOT_AVAILABLE; break; case LDAP_PARAM_ERROR: rv = NS_ERROR_INVALID_ARG; break; default: NS_ERROR("nsLDAPService::CreateFilter(): ldap_create_filter() " "returned unexpected error"); rv = NS_ERROR_UNEXPECTED; break; } _retval.Assign(buffer); // done with the array and the buffer // NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numTokens, valueWords); nsMemory::Free(buffer); return rv; }
void MediaEngineWebRTCMicrophoneSource::GetUUID(nsACString& aUUID) const { aUUID.Assign(mDeviceUUID); return; }
NS_IMETHODIMP nsGIOMimeApp::GetName(nsACString& aName) { aName.Assign(g_app_info_get_name(mApp)); return NS_OK; }
NS_CStringSetData(nsACString &aStr, const char *aData, uint32_t aDataLength) { aStr.Assign(aData, aDataLength); return NS_OK; // XXX report errors }
// who we're binding as // // readonly attribute AUTF8String bindName // NS_IMETHODIMP nsLDAPConnection::GetBindName(nsACString& _retval) { _retval.Assign(mBindName); return NS_OK; }
/* readonly attribute ACString platformVersion; */ NS_IMETHODIMP EphyXULAppInfo::GetPlatformVersion(nsACString & aPlatformVersion) { aPlatformVersion.Assign ("1.9"); return NS_OK; }
NS_IMETHODIMP nsGIOProtocolHandler::GetScheme(nsACString &aScheme) { aScheme.Assign(MOZ_GIO_SCHEME); return NS_OK; }
nsresult nsAboutCacheEntry::ParseURI(nsIURI *uri, nsACString &storageName, nsILoadContextInfo **loadInfo, nsCString &enahnceID, nsIURI **cacheUri) { // // about:cache-entry?storage=[string]&contenxt=[string]&eid=[string]&uri=[string] // nsresult rv; nsAutoCString path; rv = uri->GetPath(path); if (NS_FAILED(rv)) return rv; nsACString::const_iterator keyBegin, keyEnd, valBegin, begin, end; path.BeginReading(begin); path.EndReading(end); keyBegin = begin; keyEnd = end; if (!FindInReadable(NS_LITERAL_CSTRING("?storage="), keyBegin, keyEnd)) return NS_ERROR_FAILURE; valBegin = keyEnd; // the value of the storage key starts after the key keyBegin = keyEnd; keyEnd = end; if (!FindInReadable(NS_LITERAL_CSTRING("&context="), keyBegin, keyEnd)) return NS_ERROR_FAILURE; storageName.Assign(Substring(valBegin, keyBegin)); valBegin = keyEnd; // the value of the context key starts after the key keyBegin = keyEnd; keyEnd = end; if (!FindInReadable(NS_LITERAL_CSTRING("&eid="), keyBegin, keyEnd)) return NS_ERROR_FAILURE; nsAutoCString contextKey(Substring(valBegin, keyBegin)); valBegin = keyEnd; // the value of the eid key starts after the key keyBegin = keyEnd; keyEnd = end; if (!FindInReadable(NS_LITERAL_CSTRING("&uri="), keyBegin, keyEnd)) return NS_ERROR_FAILURE; enahnceID.Assign(Substring(valBegin, keyBegin)); valBegin = keyEnd; // the value of the uri key starts after the key nsAutoCString uriSpec(Substring(valBegin, end)); // uri is the last one // Uf... parsing done, now get some objects from it... nsCOMPtr<nsILoadContextInfo> info = CacheFileUtils::ParseKey(contextKey); if (!info) return NS_ERROR_FAILURE; info.forget(loadInfo); rv = NS_NewURI(cacheUri, uriSpec); if (NS_FAILED(rv)) return rv; return NS_OK; }
NS_IMETHODIMP nsMIMEInfoAndroid::GetMIMEType(nsACString & aMIMEType) { aMIMEType.Assign(mType); return NS_OK; }
/** * Allocates a C string into that contains a ISO 639 language list * notated with HTTP "q" values for output with a HTTP Accept-Language * header. Previous q values will be stripped because the order of * the langs imply the q value. The q values are calculated by dividing * 1.0 amongst the number of languages present. * * Ex: passing: "en, ja" * returns: "en,ja;q=0.5" * * passing: "en, ja, fr_CA" * returns: "en,ja;q=0.7,fr_CA;q=0.3" */ static nsresult PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLanguages) { if (!i_AcceptLanguages) return NS_OK; PRUint32 n, size, wrote; double q, dec; char *p, *p2, *token, *q_Accept, *o_Accept; const char *comma; PRInt32 available; o_Accept = nsCRT::strdup(i_AcceptLanguages); if (!o_Accept) return NS_ERROR_OUT_OF_MEMORY; for (p = o_Accept, n = size = 0; '\0' != *p; p++) { if (*p == ',') n++; size++; } available = size + ++n * 11 + 1; q_Accept = new char[available]; if (!q_Accept) { nsCRT::free(o_Accept); return NS_ERROR_OUT_OF_MEMORY; } *q_Accept = '\0'; q = 1.0; dec = q / (double) n; n = 0; p2 = q_Accept; for (token = nsCRT::strtok(o_Accept, ",", &p); token != (char *) 0; token = nsCRT::strtok(p, ",", &p)) { token = net_FindCharNotInSet(token, HTTP_LWS); char* trim; trim = net_FindCharInSet(token, ";" HTTP_LWS); if (trim != (char*)0) // remove "; q=..." if present *trim = '\0'; if (*token != '\0') { comma = n++ != 0 ? "," : ""; // delimiter if not first item PRUint32 u = QVAL_TO_UINT(q); if (u < 10) wrote = PR_snprintf(p2, available, "%s%s;q=0.%u", comma, token, u); else wrote = PR_snprintf(p2, available, "%s%s", comma, token); q -= dec; p2 += wrote; available -= wrote; NS_ASSERTION(available > 0, "allocated string not long enough"); } } nsCRT::free(o_Accept); o_AcceptLanguages.Assign((const char *) q_Accept); delete [] q_Accept; return NS_OK; }
NS_IMETHODIMP csTpMessagePart::GetKey(nsACString &aKey) { aKey.Assign(m_Key); return NS_OK; }
NS_IMETHODIMP csTpLocation::GetKey(nsACString &aKey) { aKey.Assign(m_Key); return NS_OK; }
NS_IMETHODIMP nsMsgFilterList::GetListId(nsACString &aListId) { aListId.Assign(m_listId); return NS_OK; }
// Parse a distinguished name (DN) and returns the relative DN, // base DN and the list of attributes that make up the relative DN. NS_IMETHODIMP nsLDAPService::ParseDn(const char *aDn, nsACString &aRdn, nsACString &aBaseDn, uint32_t *aRdnCount, char ***aRdnAttrs) { NS_ENSURE_ARG_POINTER(aRdnCount); NS_ENSURE_ARG_POINTER(aRdnAttrs); // explode the DN char **dnComponents = ldap_explode_dn(aDn, 0); if (!dnComponents) { NS_ERROR("nsLDAPService::ParseDn: parsing DN failed"); return NS_ERROR_UNEXPECTED; } // count DN components if (!*dnComponents || !*(dnComponents + 1)) { NS_ERROR("nsLDAPService::ParseDn: DN has too few components"); ldap_value_free(dnComponents); return NS_ERROR_UNEXPECTED; } // get the base DN nsAutoCString baseDn(nsDependentCString(*(dnComponents + 1))); for (char **component = dnComponents + 2; *component; ++component) { baseDn.AppendLiteral(","); baseDn.Append(nsDependentCString(*component)); } // explode the RDN char **rdnComponents = ldap_explode_rdn(*dnComponents, 0); if (!rdnComponents) { NS_ERROR("nsLDAPService::ParseDn: parsing RDN failed"); ldap_value_free(dnComponents); return NS_ERROR_UNEXPECTED; } // count RDN attributes uint32_t rdnCount = 0; for (char **component = rdnComponents; *component; ++component) ++rdnCount; if (rdnCount < 1) { NS_ERROR("nsLDAPService::ParseDn: RDN has too few components"); ldap_value_free(dnComponents); ldap_value_free(rdnComponents); return NS_ERROR_UNEXPECTED; } // get the RDN attribute names char **attrNameArray = static_cast<char **>( nsMemory::Alloc(rdnCount * sizeof(char *))); if (!attrNameArray) { NS_ERROR("nsLDAPService::ParseDn: out of memory "); ldap_value_free(dnComponents); ldap_value_free(rdnComponents); return NS_ERROR_OUT_OF_MEMORY; } uint32_t index = 0; for (char **component = rdnComponents; *component; ++component) { uint32_t len = 0; char *p; for (p = *component; *p != '\0' && *p != '='; ++p) ++len; if (*p != '=') { NS_ERROR("nsLDAPService::parseDn: " "could not find '=' in RDN component"); ldap_value_free(dnComponents); ldap_value_free(rdnComponents); return NS_ERROR_UNEXPECTED; } if (!(attrNameArray[index] = (char*)NS_Alloc(len + 1))) { NS_ERROR("nsLDAPService::ParseDn: out of memory "); ldap_value_free(dnComponents); ldap_value_free(rdnComponents); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(index, attrNameArray); return NS_ERROR_OUT_OF_MEMORY; } memcpy(attrNameArray[index], *component, len); *(attrNameArray[index] + len) = '\0'; ++index; } // perform assignments aRdn.Assign(*dnComponents); aBaseDn.Assign(baseDn); *aRdnCount = rdnCount; *aRdnAttrs = attrNameArray; ldap_value_free(dnComponents); ldap_value_free(rdnComponents); return NS_OK; }
/* readonly attribute ACString ID; */ NS_IMETHODIMP EphyXULAppInfo::GetID(nsACString & aID) { aID.Assign ("{8cbd4d83-3182-4d7e-9889-a8d77bf1f205}"); return NS_OK; }
// aOffset should be added to aCharsetStart and aCharsetEnd if this // function sets them. static void net_ParseMediaType(const nsACString &aMediaTypeStr, nsACString &aContentType, nsACString &aContentCharset, int32_t aOffset, bool *aHadCharset, int32_t *aCharsetStart, int32_t *aCharsetEnd) { const nsCString& flatStr = PromiseFlatCString(aMediaTypeStr); const char* start = flatStr.get(); const char* end = start + flatStr.Length(); // Trim LWS leading and trailing whitespace from type. We include '(' in // the trailing trim set to catch media-type comments, which are not at all // standard, but may occur in rare cases. const char* type = net_FindCharNotInSet(start, end, HTTP_LWS); const char* typeEnd = net_FindCharInSet(type, end, HTTP_LWS ";("); const char* charset = ""; const char* charsetEnd = charset; int32_t charsetParamStart = 0; int32_t charsetParamEnd = 0; // Iterate over parameters bool typeHasCharset = false; uint32_t paramStart = flatStr.FindChar(';', typeEnd - start); if (paramStart != uint32_t(kNotFound)) { // We have parameters. Iterate over them. uint32_t curParamStart = paramStart + 1; do { uint32_t curParamEnd = net_FindMediaDelimiter(flatStr, curParamStart, ';'); const char* paramName = net_FindCharNotInSet(start + curParamStart, start + curParamEnd, HTTP_LWS); static const char charsetStr[] = "charset="; if (PL_strncasecmp(paramName, charsetStr, sizeof(charsetStr) - 1) == 0) { charset = paramName + sizeof(charsetStr) - 1; charsetEnd = start + curParamEnd; typeHasCharset = true; charsetParamStart = curParamStart - 1; charsetParamEnd = curParamEnd; } curParamStart = curParamEnd + 1; } while (curParamStart < flatStr.Length()); } bool charsetNeedsQuotedStringUnescaping = false; if (typeHasCharset) { // Trim LWS leading and trailing whitespace from charset. We include // '(' in the trailing trim set to catch media-type comments, which are // not at all standard, but may occur in rare cases. charset = net_FindCharNotInSet(charset, charsetEnd, HTTP_LWS); if (*charset == '"') { charsetNeedsQuotedStringUnescaping = true; charsetEnd = start + net_FindStringEnd(flatStr, charset - start, *charset); charset++; NS_ASSERTION(charsetEnd >= charset, "Bad charset parsing"); } else { charsetEnd = net_FindCharInSet(charset, charsetEnd, HTTP_LWS ";("); } } // if the server sent "*/*", it is meaningless, so do not store it. // also, if type is the same as aContentType, then just update the // charset. however, if charset is empty and aContentType hasn't // changed, then don't wipe-out an existing aContentCharset. We // also want to reject a mime-type if it does not include a slash. // some servers give junk after the charset parameter, which may // include a comma, so this check makes us a bit more tolerant. if (type != typeEnd && strncmp(type, "*/*", typeEnd - type) != 0 && memchr(type, '/', typeEnd - type) != nullptr) { // Common case here is that aContentType is empty bool eq = !aContentType.IsEmpty() && aContentType.Equals(Substring(type, typeEnd), nsCaseInsensitiveCStringComparator()); if (!eq) { aContentType.Assign(type, typeEnd - type); ToLowerCase(aContentType); } if ((!eq && *aHadCharset) || typeHasCharset) { *aHadCharset = true; if (charsetNeedsQuotedStringUnescaping) { // parameters using the "quoted-string" syntax need // backslash-escapes to be unescaped (see RFC 2616 Section 2.2) aContentCharset.Truncate(); for (const char *c = charset; c != charsetEnd; c++) { if (*c == '\\' && c + 1 != charsetEnd) { // eat escape c++; } aContentCharset.Append(*c); } } else { aContentCharset.Assign(charset, charsetEnd - charset); } if (typeHasCharset) { *aCharsetStart = charsetParamStart + aOffset; *aCharsetEnd = charsetParamEnd + aOffset; } } // Only set a new charset position if this is a different type // from the last one we had and it doesn't already have a // charset param. If this is the same type, we probably want // to leave the charset position on its first occurrence. if (!eq && !typeHasCharset) { int32_t charsetStart = int32_t(paramStart); if (charsetStart == kNotFound) charsetStart = flatStr.Length(); *aCharsetEnd = *aCharsetStart = charsetStart + aOffset; } } }
/* readonly attribute ACString version; */ NS_IMETHODIMP EphyXULAppInfo::GetVersion(nsACString & aVersion) { aVersion.Assign (VERSION); return NS_OK; }
NS_IMETHODIMP nsRelativeFilePref::GetRelativeToKey(nsACString& aRelativeToKey) { aRelativeToKey.Assign(mRelativeToKey); return NS_OK; }
/* readonly attribute ACString platformBuildID; */ NS_IMETHODIMP EphyXULAppInfo::GetPlatformBuildID(nsACString & aPlatformBuildID) { aPlatformBuildID.Assign (EPHY_BUILD_ID); return NS_OK; }
/* readonly attribute AUTF8String OS; */ NS_IMETHODIMP EphyXULAppInfo::GetOS(nsACString & aOS) { aOS.Assign (EPHY_HOST_OS); return NS_OK; }
/* readonly attribute ACString data; */ NS_IMETHODIMP nsUDPMessage::GetData(nsACString & aData) { aData.Assign(reinterpret_cast<const char*>(mData.Elements()), mData.Length()); return NS_OK; }
/* readonly attribute AUTF8String XPCOMABI; */ NS_IMETHODIMP EphyXULAppInfo::GetXPCOMABI(nsACString & aXPCOMABI) { aXPCOMABI.Assign (EPHY_HOST_CPU "-gcc3"); return NS_OK; }
NS_CStringCopy(nsACString &aDest, const nsACString &aSrc) { aDest.Assign(aSrc); return NS_OK; // XXX report errors }
/* readonly attribute AUTF8String WidgetToolkit; */ NS_IMETHODIMP EphyXULAppInfo::GetWidgetToolkit(nsACString & aWidgetToolkit) { aWidgetToolkit.Assign ("gtk"); return NS_OK; }
/* attribute AUTF8String path; */ NS_IMETHODIMP MozJSDBusObjectPath::GetPath(nsACString & aPath) { aPath.Assign(mPath); return NS_OK; }
/* readonly attribute ACString vendor; */ NS_IMETHODIMP EphyXULAppInfo::GetVendor(nsACString & aVendor) { aVendor.Assign ("GNOME"); return NS_OK; }
NS_IMETHODIMP nsGIOMimeApp::GetId(nsACString& aId) { aId.Assign(g_app_info_get_id(mApp)); return NS_OK; }
/* readonly attribute ACString name; */ NS_IMETHODIMP EphyXULAppInfo::GetName(nsACString & aName) { aName.Assign ("GNOME Web Browser"); return NS_OK; }
void nsExpandedPrincipal::GetScriptLocation(nsACString& aStr) { // Is that a good idea to list it's principals? aStr.Assign(EXPANDED_PRINCIPAL_SPEC); }
NS_IMETHOD GetDescription(nsACString &desc) { desc.Assign(SurfaceMemoryReporterDescriptionForType(mType)); return NS_OK; }