本文整理汇总了C++中PL_strlen函数的典型用法代码示例。如果您正苦于以下问题:C++ PL_strlen函数的具体用法?C++ PL_strlen怎么用?C++ PL_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PL_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decode
nsresult nsCMSSecureMessage::
decode(const char *data, unsigned char **result, PRInt32 * _retval)
{
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::decode\n"));
nsresult rv = NS_OK;
PRUint32 len = PL_strlen(data);
int adjust = 0;
/* Compute length adjustment */
if (data[len-1] == '=') {
adjust++;
if (data[len-2] == '=') adjust++;
}
*result = (unsigned char *)PL_Base64Decode(data, len, NULL);
if (!*result) {
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::decode - error decoding base64\n"));
rv = NS_ERROR_ILLEGAL_VALUE;
goto loser;
}
*_retval = (len*3)/4 - adjust;
loser:
return rv;
}
示例2: DeliverQueuedLine
// Stream is done...drive on!
NS_IMETHODIMP
nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status)
{
nsresult rv;
// First, this shouldn't happen, but if
// it does, flush the buffer and move on.
if (mLeftoverBuffer)
{
DeliverQueuedLine(mLeftoverBuffer, PL_strlen(mLeftoverBuffer));
}
if (mOutFile)
mOutFile->Close();
// See if we succeeded on reading the message from the message store?
//
if (NS_SUCCEEDED(status))
{
// Message is done...send it!
rv = CompleteMailFileSend();
#ifdef NS_DEBUG
printf("nsMsgSendLater: Success on getting message...\n");
#endif
// If the send operation failed..try the next one...
if (NS_FAILED(rv))
{
rv = StartNextMailFileSend(rv);
if (NS_FAILED(rv))
EndSendMessages(rv, nullptr, mTotalSendCount, mTotalSentSuccessfully);
}
}
else
{
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if(!channel) return NS_ERROR_FAILURE;
// extract the prompt object to use for the alert from the url....
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIPrompt> promptObject;
if (channel)
{
channel->GetURI(getter_AddRefs(uri));
nsCOMPtr<nsISmtpUrl> smtpUrl (do_QueryInterface(uri));
if (smtpUrl)
smtpUrl->GetPrompt(getter_AddRefs(promptObject));
}
nsMsgDisplayMessageByID(promptObject, NS_ERROR_QUEUED_DELIVERY_FAILED);
// Getting the data failed, but we will still keep trying to send the rest...
rv = StartNextMailFileSend(status);
if (NS_FAILED(rv))
EndSendMessages(rv, nullptr, mTotalSendCount, mTotalSentSuccessfully);
}
return rv;
}
示例3: PL_strlen
// returns -1 if this box is not part of this namespace,
// or the length of the prefix if it is part of this namespace
int nsIMAPNamespace::MailboxMatchesNamespace(const char *boxname)
{
if (!boxname) return -1;
// If the namespace is part of the boxname
if (!m_prefix || !*m_prefix)
return 0;
if (PL_strstr(boxname, m_prefix) == boxname)
return PL_strlen(m_prefix);
// If the boxname is part of the prefix
// (Used for matching Personal mailbox with Personal/ namespace, etc.)
if (PL_strstr(m_prefix, boxname) == m_prefix)
return PL_strlen(boxname);
return -1;
}
示例4: appendsOFile
static void appendsOFile(OFile *fp, const char *s)
{
int i, slen;
slen = PL_strlen (s);
for (i=0; i<slen; i++) {
appendcOFile(fp,s[i]);
}
}
示例5: SetOtherHeaders
int nsMsgSendPart::AppendOtherHeaders(const char* more)
{
if (!m_other)
return SetOtherHeaders(more);
if (!more || !*more)
return 0;
char* tmp = (char *) PR_Malloc(sizeof(char) * (PL_strlen(m_other) + PL_strlen(more) + 2));
if (!tmp)
return NS_ERROR_OUT_OF_MEMORY;
PL_strcpy(tmp, m_other);
PL_strcat(tmp, more);
PR_FREEIF(m_other);
m_other = tmp;
return 0;
}
示例6: nsCreateImapBaseMessageURI
nsresult nsCreateImapBaseMessageURI(const nsACString& baseURI, nsCString &baseMessageURI)
{
nsCAutoString tailURI(baseURI);
// chop off imap:/
if (tailURI.Find(kImapRootURI) == 0)
tailURI.Cut(0, PL_strlen(kImapRootURI));
baseMessageURI = kImapMessageRootURI;
baseMessageURI += tailURI;
return NS_OK;
}
示例7: PL_strcaserstr
PL_strcaserstr(const char *big, const char *little)
{
const char *p;
PRUint32 ll;
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
ll = PL_strlen(little);
p = &big[ PL_strlen(big) - ll ];
if( p < big ) return (char *)0;
for( ; p >= big; p-- )
/* obvious improvement available here */
if( 0 == PL_strncasecmp(p, little, ll) )
return (char *)p;
return (char *)0;
}
示例8: QueuePrefetchMIMEHeader
int32_t nsIMAPBodypart::GenerateMIMEHeader(nsIMAPBodyShell *aShell, bool stream, bool prefetch)
{
if (prefetch && !m_headerData)
{
QueuePrefetchMIMEHeader(aShell);
return 0;
}
else if (m_headerData)
{
int32_t mimeHeaderLength = 0;
if (!ShouldFetchInline(aShell))
{
// if this part isn't inline, add the X-Mozilla-IMAP-Part header
char *xPartHeader = PR_smprintf("%s: %s", IMAP_EXTERNAL_CONTENT_HEADER, m_partNumberString);
if (xPartHeader)
{
if (stream)
{
aShell->GetConnection()->Log("SHELL","GENERATE-XHeader",m_partNumberString);
aShell->GetConnection()->HandleMessageDownLoadLine(xPartHeader, false);
}
mimeHeaderLength += PL_strlen(xPartHeader);
PR_Free(xPartHeader);
}
}
mimeHeaderLength += PL_strlen(m_headerData);
if (stream)
{
aShell->GetConnection()->Log("SHELL","GENERATE-MIMEHeader",m_partNumberString);
aShell->GetConnection()->HandleMessageDownLoadLine(m_headerData, false); // all one line? Can we do that?
}
return mimeHeaderLength;
}
else
{
SetIsValid(false); // prefetch didn't adopt a MIME header
return 0;
}
}
示例9: NS_ASSERTION
// static
xptiFileType::Type xptiFileType::GetType(const char* name)
{
NS_ASSERTION(name, "loser!");
int len = PL_strlen(name);
for(const xptiFileTypeEntry* p = g_Entries; p->name; p++)
{
if(len > p->len && 0 == PL_strcasecmp(p->name, &(name[len - p->len])))
return p->type;
}
return UNKNOWN;
}
示例10: COMfindComponent
COMclass
COMfindComponent (const char *className)
{
const char *prefix = "urn:";
const char *modulePrefix = "swarm/";
size_t prefixLen = PL_strlen (prefix);
size_t modulePrefixLen = PL_strlen (modulePrefix);
nsCID *cClass = new nsCID ();
size_t classNameLen = PL_strlen (className);
char *buf = (char *) malloc (prefixLen + classNameLen + 1);
if (!buf)
abort ();
nsresult rv;
PL_strcpy (buf, prefix);
PL_strcat (buf, className);
if (PL_strncmp (className, modulePrefix, modulePrefixLen) == 0)
{
unsigned i;
buf[prefixLen + 5] = ':';
for (i = modulePrefixLen; i < classNameLen; i++)
{
unsigned pos = prefixLen + i;
if (buf[pos] == '/')
buf[pos] = '.';
}
}
nsCOMPtr<nsIComponentManager> compMgr;
NS_GetComponentManager (getter_AddRefs (compMgr));
if (!compMgr)
abort ();
nsCOMPtr<nsIComponentManagerObsolete> compMgrO = do_QueryInterface (compMgr);
rv = compMgrO->ContractIDToClassID (buf, cClass);
free (buf);
if (NS_FAILED (rv))
abort ();
return (COMclass) cClass;
}
示例11: PL_strlen
int32_t nsIMAPBodypart::GenerateBoundary(nsIMAPBodyShell *aShell, bool stream, bool prefetch, bool lastBoundary)
{
if (prefetch)
return 0; // don't need to prefetch anything
if (m_boundaryData)
{
if (!lastBoundary)
{
if (stream)
{
aShell->GetConnection()->Log("SHELL","GENERATE-Boundary",m_partNumberString);
aShell->GetConnection()->HandleMessageDownLoadLine(m_boundaryData, false);
}
return PL_strlen(m_boundaryData);
}
else // the last boundary
{
char *lastBoundaryData = PR_smprintf("%s--", m_boundaryData);
if (lastBoundaryData)
{
if (stream)
{
aShell->GetConnection()->Log("SHELL","GENERATE-Boundary-Last",m_partNumberString);
aShell->GetConnection()->HandleMessageDownLoadLine(lastBoundaryData, false);
}
int32_t rv = PL_strlen(lastBoundaryData);
PR_Free(lastBoundaryData);
return rv;
}
else
{
//HandleMemoryFailure();
return 0;
}
}
}
else
return 0;
}
示例12: nsCreateNewsBaseMessageURI
nsresult nsCreateNewsBaseMessageURI(const char *baseURI, nsCString &baseMessageURI)
{
nsAutoCString tailURI(baseURI);
// chop off news:/
if (tailURI.Find(kNewsRootURI) == 0)
tailURI.Cut(0, PL_strlen(kNewsRootURI));
baseMessageURI = kNewsMessageRootURI;
baseMessageURI += tailURI;
return NS_OK;
}
示例13: pkix_pl_UInt32_Overflows
/*
* FUNCTION: pkix_pl_UInt32_Overflows
* DESCRIPTION:
*
* Returns a PKIX_Boolean indicating whether the unsigned integer
* represented by "string" is too large to fit in 32-bits (i.e.
* whether it overflows). With the exception of the string "0",
* all other strings are stripped of any leading zeros. It is assumed
* that every character in "string" is from the set {'0' - '9'}.
*
* PARAMETERS
* "string"
* Address of array of bytes representing PKIX_UInt32 that's being tested
* for 32-bit overflow
* THREAD SAFETY:
* Thread Safe (see Thread Safety Definitions in Programmer's Guide)
* RETURNS:
* PKIX_TRUE if PKIX_UInt32 represented by "string" overflows;
* PKIX_FALSE otherwise
*/
PKIX_Boolean
pkix_pl_UInt32_Overflows(char *string){
char *firstNonZero = NULL;
PKIX_UInt32 length, i;
char *MAX_UINT32_STRING = "4294967295";
PKIX_DEBUG_ENTER(OID);
PKIX_OID_DEBUG("\tCalling PL_strlen).\n");
length = PL_strlen(string);
if (length < MAX_DIGITS_32){
return (PKIX_FALSE);
}
firstNonZero = string;
for (i = 0; i < length; i++){
if (*string == '0'){
firstNonZero++;
}
}
PKIX_OID_DEBUG("\tCalling PL_strlen).\n");
length = PL_strlen(firstNonZero);
if (length > MAX_DIGITS_32){
return (PKIX_TRUE);
}
PKIX_OID_DEBUG("\tCalling PL_strlen).\n");
if (length == MAX_DIGITS_32){
PKIX_OID_DEBUG("\tCalling PORT_Strcmp).\n");
if (PORT_Strcmp(firstNonZero, MAX_UINT32_STRING) > 0){
return (PKIX_TRUE);
}
}
return (PKIX_FALSE);
}
示例14: AppendAndAlloc
static char *
AppendAndAlloc(char *string, const char *newSubstring, bool withComma)
{
if (!newSubstring) return NULL;
if (!string) return PL_strdup(newSubstring);
char *separator = (char *) (withComma ? ", " : " ");
char *oldString = string;
string = (char *)PR_Calloc(PL_strlen(oldString) +
PL_strlen(separator) +
PL_strlen(newSubstring) + 1,
sizeof(char));
PL_strcpy(string, oldString);
PL_strcat(string, separator);
PL_strcat(string, newSubstring);
PR_Free(oldString);
return string;
}
示例15: NSSBase64_DecodeBuffer
NS_IMETHODIMP
nsNSSCertificateDB::FindCertByDBKey(const char *aDBkey, nsISupports *aToken,
nsIX509Cert **_cert)
{
nsNSSShutDownPreventionLock locker;
SECItem keyItem = {siBuffer, nsnull, 0};
SECItem *dummy;
CERTIssuerAndSN issuerSN;
unsigned long moduleID,slotID;
*_cert = nsnull;
if (!aDBkey || !*aDBkey)
return NS_ERROR_INVALID_ARG;
dummy = NSSBase64_DecodeBuffer(nsnull, &keyItem, aDBkey,
(PRUint32)PL_strlen(aDBkey));
if (!dummy || keyItem.len < NS_NSS_LONG*4) {
PR_FREEIF(keyItem.data);
return NS_ERROR_INVALID_ARG;
}
CERTCertificate *cert;
// someday maybe we can speed up the search using the moduleID and slotID
moduleID = NS_NSS_GET_LONG(keyItem.data);
slotID = NS_NSS_GET_LONG(&keyItem.data[NS_NSS_LONG]);
// build the issuer/SN structure
issuerSN.serialNumber.len = NS_NSS_GET_LONG(&keyItem.data[NS_NSS_LONG*2]);
issuerSN.derIssuer.len = NS_NSS_GET_LONG(&keyItem.data[NS_NSS_LONG*3]);
if (issuerSN.serialNumber.len == 0 || issuerSN.derIssuer.len == 0
|| issuerSN.serialNumber.len + issuerSN.derIssuer.len
!= keyItem.len - NS_NSS_LONG*4) {
PR_FREEIF(keyItem.data);
return NS_ERROR_INVALID_ARG;
}
issuerSN.serialNumber.data= &keyItem.data[NS_NSS_LONG*4];
issuerSN.derIssuer.data= &keyItem.data[NS_NSS_LONG*4+
issuerSN.serialNumber.len];
cert = CERT_FindCertByIssuerAndSN(CERT_GetDefaultCertDB(), &issuerSN);
PR_FREEIF(keyItem.data);
if (cert) {
nsNSSCertificate *nssCert = new nsNSSCertificate(cert);
CERT_DestroyCertificate(cert);
if (nssCert == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(nssCert);
*_cert = static_cast<nsIX509Cert*>(nssCert);
}
return NS_OK;
}