当前位置: 首页>>代码示例>>C++>>正文


C++ nsCString::Adopt方法代码示例

本文整理汇总了C++中nsCString::Adopt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::Adopt方法的具体用法?C++ nsCString::Adopt怎么用?C++ nsCString::Adopt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsCString的用法示例。


在下文中一共展示了nsCString::Adopt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConvertLineBreaks

// 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;
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:28,代码来源:nsFormSubmission.cpp

示例2: StripHtml

void nsMsgBodyHandler::StripHtml (nsCString &pBufInOut)
{
  char *pBuf = (char*) PR_Malloc (pBufInOut.Length() + 1);
  if (pBuf)
  {
    char *pWalk = pBuf;
    
    char *pWalkInOut = (char *) pBufInOut.get();
    bool inTag = false;
    while (*pWalkInOut) // throw away everything inside < >
    {
      if (!inTag)
        if (*pWalkInOut == '<')
          inTag = true;
        else
          *pWalk++ = *pWalkInOut;
        else
          if (*pWalkInOut == '>')
            inTag = false;
          pWalkInOut++;
    }
    *pWalk = 0; // null terminator
    
    pBufInOut.Adopt(pBuf);
  }
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:26,代码来源:nsMsgBodyHandler.cpp

示例3:

nsresult nsMsgProtocol::DoNtlmStep1(const char *username, const char *password, nsCString &response)
{
    nsresult rv;

    m_authModule = do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "ntlm", &rv);
    // if this fails, then it means that we cannot do NTLM auth.
    if (NS_FAILED(rv) || !m_authModule)
        return rv;

    m_authModule->Init(nullptr, 0, nullptr, NS_ConvertUTF8toUTF16(username).get(),
                       NS_ConvertUTF8toUTF16(password).get());

    void *outBuf;
    uint32_t outBufLen;
    rv = m_authModule->GetNextToken((void *)nullptr, 0, &outBuf, &outBufLen);
    if (NS_SUCCEEDED(rv) && outBuf)
    {
        char *base64Str = PL_Base64Encode((char *)outBuf, outBufLen, nullptr);
        if (base64Str)
          response.Adopt(base64Str);
        else
          rv = NS_ERROR_OUT_OF_MEMORY;
        nsMemory::Free(outBuf);
    }

    return rv;
}
开发者ID:klainfo,项目名称:releases-comm-central,代码行数:27,代码来源:nsMsgProtocol.cpp

示例4: printf

nsresult nsMsgProtocol::DoGSSAPIStep1(const char *service, const char *username, nsCString &response)
{
    nsresult rv;
#ifdef DEBUG_BenB
    printf("GSSAPI step 1 for service %s, username %s\n", service, username);
#endif

    // if this fails, then it means that we cannot do GSSAPI SASL.
    m_authModule = do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "sasl-gssapi", &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    m_authModule->Init(service, nsIAuthModule::REQ_DEFAULT, nullptr, NS_ConvertUTF8toUTF16(username).get(), nullptr);

    void *outBuf;
    uint32_t outBufLen;
    rv = m_authModule->GetNextToken((void *)nullptr, 0, &outBuf, &outBufLen);
    if (NS_SUCCEEDED(rv) && outBuf)
    {
        char *base64Str = PL_Base64Encode((char *)outBuf, outBufLen, nullptr);
        if (base64Str)
            response.Adopt(base64Str);
        else
            rv = NS_ERROR_OUT_OF_MEMORY;
        nsMemory::Free(outBuf);
    }

#ifdef DEBUG_BenB
    printf("GSSAPI step 1 succeeded\n");
#endif
    return rv;
}
开发者ID:klainfo,项目名称:releases-comm-central,代码行数:31,代码来源:nsMsgProtocol.cpp

示例5: MangleKeywordIntoURI

static nsresult MangleKeywordIntoURI(const char *aKeyword, const char *aURL,
                                     nsCString& query)
{
    query = (*aKeyword == '?') ? (aKeyword + 1) : aKeyword;
    query.Trim(" "); // pull leading/trailing spaces.

    // encode
    char * encQuery = nsEscape(query.get(), url_XPAlphas);
    if (!encQuery) return NS_ERROR_OUT_OF_MEMORY;
    query.Adopt(encQuery);

    // prepend the query with the keyword url
    // XXX this url should come from somewhere else
    query.Insert(aURL, 0);
    return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:16,代码来源:nsDefaultURIFixup.cpp

示例6: while

/**
 * Decodes the given base64 string.
 *
 * It returns its decoded string in its input.
 *
 * @param pBufInOut   (inout) a buffer of the string
 */
void nsMsgBodyHandler::Base64Decode (nsCString &pBufInOut)
{
  char *decodedBody = PL_Base64Decode(pBufInOut.get(), pBufInOut.Length(), nullptr);
  if (decodedBody)
    pBufInOut.Adopt(decodedBody);

  int32_t offset = pBufInOut.FindChar('\n');
  while (offset != -1) {
    pBufInOut.Replace(offset, 1, ' ');
    offset = pBufInOut.FindChar('\n', offset);
  }
  offset = pBufInOut.FindChar('\r');
  while (offset != -1) {
    pBufInOut.Replace(offset, 1, ' ');
    offset = pBufInOut.FindChar('\r', offset);
  } 
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:24,代码来源:nsMsgBodyHandler.cpp

示例7: ConvertLineBreaks

// i18n helper routines
nsresult
nsEncodingFormSubmission::EncodeVal(const nsAString& aStr, nsCString& aOut,
                                    bool aHeaderEncode)
{
  if (!mEncoder.Encode(aStr, aOut)) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (aHeaderEncode) {
    aOut.Adopt(nsLinebreakConverter::
               ConvertLineBreaks(aOut.get(),
                                 nsLinebreakConverter::eLinebreakAny,
                                 nsLinebreakConverter::eLinebreakSpace));
    aOut.ReplaceSubstring(NS_LITERAL_CSTRING("\""),
                          NS_LITERAL_CSTRING("\\\""));
  }


  return NS_OK;
}
开发者ID:Shaif95,项目名称:gecko-dev,代码行数:21,代码来源:nsFormSubmission.cpp

示例8:

static nsresult
GetCertFingerprintByOidTag(CERTCertificate* nsscert,
                           SECOidTag aOidTag, 
                           nsCString &fp)
{
  unsigned int hash_len = HASH_ResultLenByOidTag(aOidTag);
  nsRefPtr<nsStringBuffer> fingerprint = nsStringBuffer::Alloc(hash_len);
  if (!fingerprint)
    return NS_ERROR_OUT_OF_MEMORY;

  PK11_HashBuf(aOidTag, (unsigned char*)fingerprint->Data(), 
               nsscert->derCert.data, nsscert->derCert.len);

  SECItem fpItem;
  fpItem.data = (unsigned char*)fingerprint->Data();
  fpItem.len = hash_len;

  fp.Adopt(CERT_Hexify(&fpItem, 1));
  return NS_OK;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:20,代码来源:nsClientAuthRemember.cpp

示例9: EncodeVal

// i18n helper routines
nsresult
nsFSURLEncoded::URLEncode(const nsAString& aStr, nsCString& aEncoded)
{
  // convert to CRLF breaks
  char16_t* convertedBuf =
    nsLinebreakConverter::ConvertUnicharLineBreaks(PromiseFlatString(aStr).get(),
                                                   nsLinebreakConverter::eLinebreakAny,
                                                   nsLinebreakConverter::eLinebreakNet);
  NS_ENSURE_TRUE(convertedBuf, NS_ERROR_OUT_OF_MEMORY);

  nsAutoCString encodedBuf;
  nsresult rv = EncodeVal(nsDependentString(convertedBuf), encodedBuf, false);
  free(convertedBuf);
  NS_ENSURE_SUCCESS(rv, rv);

  char* escapedBuf = nsEscape(encodedBuf.get(), url_XPAlphas);
  NS_ENSURE_TRUE(escapedBuf, NS_ERROR_OUT_OF_MEMORY);
  aEncoded.Adopt(escapedBuf);

  return NS_OK;
}
开发者ID:Shaif95,项目名称:gecko-dev,代码行数:22,代码来源:nsFormSubmission.cpp

示例10: size

nsresult nsMsgProtocol::DoNtlmStep2(nsCString &commandResponse, nsCString &response)
{
    nsresult rv;
    void *inBuf, *outBuf;
    uint32_t inBufLen, outBufLen;
    uint32_t len = commandResponse.Length();

    // decode into the input secbuffer
    inBufLen = (len * 3)/4;      // sufficient size (see plbase64.h)
    inBuf = nsMemory::Alloc(inBufLen);
    if (!inBuf)
        return NS_ERROR_OUT_OF_MEMORY;

    // strip off any padding (see bug 230351)
    const char *challenge = commandResponse.get();
    while (challenge[len - 1] == '=')
        len--;

    rv = (PL_Base64Decode(challenge, len, (char *)inBuf))
         ? m_authModule->GetNextToken(inBuf, inBufLen, &outBuf, &outBufLen)
         : NS_ERROR_FAILURE;

    nsMemory::Free(inBuf);
    if (NS_SUCCEEDED(rv) && outBuf)
    {
        char *base64Str = PL_Base64Encode((char *)outBuf, outBufLen, nullptr);
        if (base64Str)
          response.Adopt(base64Str);
        else
          rv = NS_ERROR_OUT_OF_MEMORY;
    }

    if (NS_FAILED(rv))
        response = "*";

    return rv;
}
开发者ID:klainfo,项目名称:releases-comm-central,代码行数:37,代码来源:nsMsgProtocol.cpp

示例11:

void
MimeHeaders_convert_header_value(MimeDisplayOptions *opt, nsCString &value,
                                 bool convert_charset_only)
{
  char        *converted;

  if (value.IsEmpty())
    return;

  if (convert_charset_only)
  {
    nsCAutoString output;
    ConvertRawBytesToUTF8(value, opt->default_charset, output);
    value.Assign(output);
    return;
  }

  if (opt && opt->rfc1522_conversion_p)
  {
    converted = MIME_DecodeMimeHeader(value.get(), opt->default_charset,
                                      opt->override_charset, true);

    if (converted)
    {
      value.Adopt(converted);
    }
  }
  else
  {
    // This behavior, though highly unusual, was carefully preserved
    // from the previous implementation.  It may be that this is dead
    // code, in which case opt->rfc1522_conversion_p is no longer
    // needed.
    value.Truncate();
  }
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:36,代码来源:mimehdrs.cpp


注:本文中的nsCString::Adopt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。