本文整理汇总了C++中PL_strchr函数的典型用法代码示例。如果您正苦于以下问题:C++ PL_strchr函数的具体用法?C++ PL_strchr怎么用?C++ PL_strchr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PL_strchr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS_ENSURE_ARG_MAX
NS_IMETHODIMP
nsCommandLine::Init(int32_t argc, const char* const* argv, nsIFile* aWorkingDir,
uint32_t aState)
{
NS_ENSURE_ARG_MAX(aState, 2);
int32_t i;
mWorkingDir = aWorkingDir;
// skip argv[0], we don't want it
for (i = 1; i < argc; ++i) {
const char* curarg = argv[i];
#ifdef DEBUG_COMMANDLINE
printf("Testing native arg %i: '%s'\n", i, curarg);
#endif
#if defined(XP_WIN)
if (*curarg == '/') {
char* dup = PL_strdup(curarg);
if (!dup) return NS_ERROR_OUT_OF_MEMORY;
*dup = '-';
char* colon = PL_strchr(dup, ':');
if (colon) {
*colon = '\0';
appendArg(dup);
appendArg(colon+1);
} else {
appendArg(dup);
}
PL_strfree(dup);
continue;
}
#endif
if (*curarg == '-') {
if (*(curarg+1) == '-') ++curarg;
char* dup = PL_strdup(curarg);
if (!dup) return NS_ERROR_OUT_OF_MEMORY;
char* eq = PL_strchr(dup, '=');
if (eq) {
*eq = '\0';
appendArg(dup);
appendArg(eq + 1);
} else {
appendArg(dup);
}
PL_strfree(dup);
continue;
}
appendArg(curarg);
}
mState = aState;
return NS_OK;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:60,代码来源:nsCommandLine.cpp
示例2: ParseVersion
void
nsHttpResponseHead::ParseStatusLine(const char *line)
{
//
// Parse Status-Line:: HTTP-Version SP Status-Code SP Reason-Phrase CRLF
//
// HTTP-Version
ParseVersion(line);
if ((mVersion == NS_HTTP_VERSION_0_9) || !(line = PL_strchr(line, ' '))) {
mStatus = 200;
mStatusText.AssignLiteral("OK");
}
else {
// Status-Code
mStatus = (PRUint16) atoi(++line);
if (mStatus == 0) {
LOG(("mal-formed response status; assuming status = 200\n"));
mStatus = 200;
}
// Reason-Phrase is whatever is remaining of the line
if (!(line = PL_strchr(line, ' '))) {
LOG(("mal-formed response status line; assuming statusText = 'OK'\n"));
mStatusText.AssignLiteral("OK");
}
else
mStatusText = ++line;
}
LOG(("Have status line [version=%u status=%u statusText=%s]\n",
PRUintn(mVersion), PRUintn(mStatus), mStatusText.get()));
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:34,代码来源:nsHttpResponseHead.cpp
示例3: LogHeaders
static void
LogHeaders(const char *lines)
{
nsCAutoString buf;
char *p;
while ((p = PL_strstr(lines, "\r\n")) != nsnull) {
buf.Assign(lines, p - lines);
if (PL_strcasestr(buf.get(), "authorization: ") != nsnull) {
char *p = PL_strchr(PL_strchr(buf.get(), ' ')+1, ' ');
while (*++p) *p = '*';
}
LOG3((" %s\n", buf.get()));
lines = p + 2;
}
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:15,代码来源:nsHttpTransaction.cpp
示例4: while
char *nsMsgSearchAdapter::TransformSpacesToStars (const char *spaceString, msg_TransformType transformType)
{
char *starString;
if (transformType == kOverwrite)
{
if ((starString = strdup(spaceString)) != nsnull)
{
char *star = starString;
while ((star = PL_strchr(star, ' ')) != nsnull)
*star = '*';
}
}
else
{
int i, count;
for (i = 0, count = 0; spaceString[i]; )
{
if (spaceString[i++] == ' ')
{
count++;
while (spaceString[i] && spaceString[i] == ' ') i++;
}
}
if (transformType == kSurround)
count *= 2;
if (count > 0)
{
if ((starString = (char *)PR_Malloc(i + count + 1)) != nsnull)
{
int j;
for (i = 0, j = 0; spaceString[i]; )
{
if (spaceString[i] == ' ')
{
starString[j++] = '*';
starString[j++] = ' ';
if (transformType == kSurround)
starString[j++] = '*';
i++;
while (spaceString[i] && spaceString[i] == ' ')
i++;
}
else
starString[j++] = spaceString[i++];
}
starString[j] = 0;
}
}
else
starString = strdup(spaceString);
}
return starString;
}
开发者ID:alanyjw,项目名称:comm-central,代码行数:60,代码来源:nsMsgSearchAdapter.cpp
示例5: extractAttributeValue
// Assumption: attribute pairs in the string are separated by '&'.
char * extractAttributeValue(const char * searchString, const char * attributeName)
{
char * attributeValue = nullptr;
if (searchString && attributeName)
{
// search the string for attributeName
uint32_t attributeNameSize = PL_strlen(attributeName);
char * startOfAttribute = PL_strcasestr(searchString, attributeName);
if (startOfAttribute)
{
startOfAttribute += attributeNameSize; // skip over the attributeName
if (startOfAttribute) // is there something after the attribute name
{
char * endOfAttribute = startOfAttribute ? PL_strchr(startOfAttribute, '&') : nullptr;
nsDependentCString attributeValueStr;
if (startOfAttribute && endOfAttribute) // is there text after attribute value
attributeValueStr.Assign(startOfAttribute, endOfAttribute - startOfAttribute);
else // there is nothing left so eat up rest of line.
attributeValueStr.Assign(startOfAttribute);
// now unescape the string...
nsCString unescapedValue;
MsgUnescapeString(attributeValueStr, 0, unescapedValue);
attributeValue = PL_strdup(unescapedValue.get());
} // if we have a attribute value
} // if we have a attribute name
} // if we got non-null search string and attribute name values
return attributeValue;
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:33,代码来源:nsMailboxUrl.cpp
示例6: writeStr
NS_IMETHODIMP
nsMsgFilterList::WriteStrAttr(nsMsgFilterFileAttribValue attrib,
const char *aStr, nsIOutputStream *aStream)
{
nsresult rv = NS_OK;
if (aStr && *aStr && aStream) // only proceed if we actually have a string to write out.
{
char *escapedStr = nullptr;
if (PL_strchr(aStr, '"'))
escapedStr = nsMsgSearchTerm::EscapeQuotesInStr(aStr);
const char *attribStr = GetStringForAttrib(attrib);
if (attribStr)
{
uint32_t bytesWritten;
nsAutoCString writeStr(attribStr);
writeStr.AppendLiteral("=\"");
writeStr.Append((escapedStr) ? escapedStr : aStr);
writeStr.AppendLiteral("\"" MSG_LINEBREAK);
rv = aStream->Write(writeStr.get(), writeStr.Length(), &bytesWritten);
}
PR_Free(escapedStr);
}
return rv;
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:25,代码来源:nsMsgFilterList.cpp
示例7: lexSkipWhite
static char *lexLookaheadWord() {
/* this function can lookahead word with max size of PR_MAX_LEX_LOOKAHEAD_0
/ and thing bigger than that will stop the lookahead and return 0;
/ leading white spaces are not recoverable.
*/
int c;
int len = 0;
int curgetptr = 0;
lexSkipWhite();
lexClearToken();
curgetptr = (int)lexBuf.getPtr; /* remember! */
while (len < (PR_MAX_LEX_LOOKAHEAD_0)) {
c = lexGetc();
len++;
if (c == EOF || PL_strchr("\t\n ;:=", (char)c)) {
lexAppendc(0);
/* restore lookahead buf. */
lexBuf.len += len;
lexBuf.getPtr = curgetptr;
return lexStr();
} else
lexAppendc(c);
}
lexBuf.len += len; /* char that has been moved to lookahead buffer */
lexBuf.getPtr = curgetptr;
return 0;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:27,代码来源:nsVCard.cpp
示例8: lexLookahead
static char *lexGetStrUntil(char *termset) {
int c = lexLookahead();
lexClearToken();
while (c != EOF && !PL_strchr(termset, c)) {
lexAppendc(c);
lexSkipLookahead();
c = lexLookahead();
}
lexAppendc(0);
return c == EOF ? 0 : lexStr();
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:11,代码来源:nsVCard.cpp
示例9: Is7bitNonAsciiString
NS_IMETHODIMP
nsMIMEHeaderParamImpl::DecodeRFC2047Header(const char* aHeaderVal,
const char* aDefaultCharset,
PRBool aOverrideCharset,
PRBool aEatContinuations,
nsACString& aResult)
{
aResult.Truncate();
if (!aHeaderVal)
return NS_ERROR_INVALID_ARG;
if (!*aHeaderVal)
return NS_OK;
// If aHeaderVal is RFC 2047 encoded or is not a UTF-8 string but
// aDefaultCharset is specified, decodes RFC 2047 encoding and converts
// to UTF-8. Otherwise, just strips away CRLF.
if (PL_strstr(aHeaderVal, "=?") ||
aDefaultCharset && (!IsUTF8(nsDependentCString(aHeaderVal)) ||
Is7bitNonAsciiString(aHeaderVal, PL_strlen(aHeaderVal)))) {
DecodeRFC2047Str(aHeaderVal, aDefaultCharset, aOverrideCharset, aResult);
} else if (aEatContinuations &&
(PL_strchr(aHeaderVal, '\n') || PL_strchr(aHeaderVal, '\r'))) {
aResult = aHeaderVal;
} else {
aEatContinuations = PR_FALSE;
aResult = aHeaderVal;
}
if (aEatContinuations) {
nsCAutoString temp(aResult);
temp.ReplaceSubstring("\n\t", " ");
temp.ReplaceSubstring("\r\t", " ");
temp.StripChars("\r\n");
aResult = temp;
}
return NS_OK;
}
开发者ID:mmmulani,项目名称:v8monkey,代码行数:39,代码来源:nsMIMEHeaderParamImpl.cpp
示例10: GetTarget
// We use an rdf attribute to mark if this is a container or not.
// Note that we still have to do string comparisons as a fallback
// because stuff like the personal toolbar and bookmarks check whether
// a URL is a container, and we have no attribute in that case.
PRBool
nsHTTPIndex::isWellknownContainerURI(nsIRDFResource *r)
{
nsCOMPtr<nsIRDFNode> node;
GetTarget(r, kNC_IsContainer, PR_TRUE, getter_AddRefs(node));
PRBool isContainerFlag = PR_FALSE;
if (node && NS_SUCCEEDED(node->EqualsNode(kTrueLiteral, &isContainerFlag))) {
return isContainerFlag;
} else {
nsXPIDLCString uri;
// For gopher, we need to follow the URL attribute to get the
// real destination
GetDestination(r,uri);
if ((uri.get()) && (!strncmp(uri, kFTPProtocol, sizeof(kFTPProtocol) - 1))) {
if (uri.Last() == '/') {
isContainerFlag = PR_TRUE;
}
}
// A gopher url is of the form:
// gopher://example.com/xFileNameToGet
// where x is a single character representing the type of file
// 1 is a directory, and 7 is a search.
// Searches will cause a dialog to be popped up (asking the user what
// to search for), and so even though searches return a directory as a
// result, don't treat it as a directory here.
// The isContainerFlag test above will correctly handle this when a
// search url is passed in as the baseuri
if ((uri.get()) &&
(!strncmp(uri,kGopherProtocol, sizeof(kGopherProtocol)-1))) {
char* pos = PL_strchr(uri+sizeof(kGopherProtocol)-1, '/');
if (!pos || pos[1] == '\0' || pos[1] == '1')
isContainerFlag = PR_TRUE;
}
}
return isContainerFlag;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:46,代码来源:nsDirectoryViewer.cpp
示例11: NS_ENSURE_TRUE
//.........这里部分代码省略.........
caseAResult = res;
// keep going, we may find a RFC 2231/5987 encoded alternative
}
// case B, C, and D
else if (nameLen > paramLen &&
!nsCRT::strncasecmp(nameStart, aParamName, paramLen) &&
*(nameStart + paramLen) == '*') {
// 1st char past '*'
const char *cp = nameStart + paramLen + 1;
// if param name ends in "*" we need do to RFC5987 "ext-value" decoding
bool needExtDecoding = *(nameEnd - 1) == '*';
bool caseB = nameLen == paramLen + 1;
bool caseCStart = (*cp == '0') && needExtDecoding;
// parse the segment number
PRInt32 segmentNumber = -1;
if (!caseB) {
PRInt32 segLen = (nameEnd - cp) - (needExtDecoding ? 1 : 0);
segmentNumber = parseSegmentNumber(cp, segLen);
if (segmentNumber == -1) {
acceptContinuations = false;
goto increment_str;
}
}
// CaseB and start of CaseC: requires charset and optional language
// in quotes (quotes required even if lang is blank)
if (caseB || (caseCStart && acceptContinuations)) {
// look for single quotation mark(')
const char *sQuote1 = PL_strchr(valueStart, 0x27);
const char *sQuote2 = sQuote1 ? PL_strchr(sQuote1 + 1, 0x27) : nullptr;
// Two single quotation marks must be present even in
// absence of charset and lang.
if (!sQuote1 || !sQuote2) {
NS_WARNING("Mandatory two single quotes are missing in header parameter\n");
}
const char *charsetStart = NULL;
PRInt32 charsetLength = 0;
const char *langStart = NULL;
PRInt32 langLength = 0;
const char *rawValStart = NULL;
PRInt32 rawValLength = 0;
if (sQuote2 && sQuote1) {
// both delimiters present: charSet'lang'rawVal
rawValStart = sQuote2 + 1;
rawValLength = valueEnd - rawValStart;
langStart = sQuote1 + 1;
langLength = sQuote2 - langStart;
charsetStart = valueStart;
charsetLength = sQuote1 - charsetStart;
}
else if (sQuote1) {
// one delimiter; assume charset'rawVal
rawValStart = sQuote1 + 1;
rawValLength = valueEnd - rawValStart;
charsetStart = valueStart;
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:67,代码来源:nsMIMEHeaderParamImpl.cpp
示例12: ProcessCommandFile
/*********************************************************************
*
* P r o c e s s C o m m a n d F i l e
*/
int
ProcessCommandFile()
{
PRFileDesc *fd;
#define CMD_FILE_BUFSIZE 1024
char buf[CMD_FILE_BUFSIZE];
char *equals;
int linenum = 0;
int retval = -1;
OPT_TYPE type;
fd = PR_Open(cmdFile, PR_RDONLY, 0777);
if (!fd) {
PR_fprintf(errorFD, "ERROR: Unable to open command file %s.\n");
errorCount++;
return -1;
}
while (pr_fgets(buf, CMD_FILE_BUFSIZE, fd)) {
char *eol;
linenum++;
/* Chop off final newline */
eol = PL_strchr(buf, '\r');
if (!eol) {
eol = PL_strchr(buf, '\n');
}
if (eol)
*eol = '\0';
equals = PL_strchr(buf, '=');
if (!equals) {
continue;
}
*equals = '\0';
equals++;
/* Now buf points to the attribute, and equals points to the value. */
/* This is pretty straightforward, just deal with whatever attribute
* this is */
if (!PL_strcasecmp(buf, "basename")) {
type = BASE_OPT;
} else if (!PL_strcasecmp(buf, "compression")) {
type = COMPRESSION_OPT;
} else if (!PL_strcasecmp(buf, "certdir")) {
type = CERT_DIR_OPT;
} else if (!PL_strcasecmp(buf, "extension")) {
type = EXTENSION_OPT;
} else if (!PL_strcasecmp(buf, "generate")) {
type = GENKEY_OPT;
} else if (!PL_strcasecmp(buf, "installScript")) {
type = INSTALL_SCRIPT_OPT;
} else if (!PL_strcasecmp(buf, "javascriptdir")) {
type = SCRIPTDIR_OPT;
} else if (!PL_strcasecmp(buf, "htmldir")) {
type = JAVASCRIPT_OPT;
if (jartree) {
PR_fprintf(errorFD,
"warning: directory to be signed specified more than once."
" Only last specification will be used.\n");
warningCount++;
PR_Free(jartree);
jartree = NULL;
}
jartree = PL_strdup(equals);
} else if (!PL_strcasecmp(buf, "certname")) {
type = CERTNAME_OPT;
} else if (!PL_strcasecmp(buf, "signdir")) {
type = SIGNDIR_OPT;
} else if (!PL_strcasecmp(buf, "list")) {
type = LIST_OBJSIGN_CERTS_OPT;
} else if (!PL_strcasecmp(buf, "listall")) {
type = LIST_ALL_CERTS_OPT;
} else if (!PL_strcasecmp(buf, "metafile")) {
type = METAFILE_OPT;
} else if (!PL_strcasecmp(buf, "modules")) {
type = MODULES_OPT;
} else if (!PL_strcasecmp(buf, "optimize")) {
type = OPTIMIZE_OPT;
} else if (!PL_strcasecmp(buf, "ocsp")) {
type = ENABLE_OCSP_OPT;
} else if (!PL_strcasecmp(buf, "password")) {
type = PASSWORD_OPT;
} else if (!PL_strcasecmp(buf, "verify")) {
type = VERIFY_OPT;
} else if (!PL_strcasecmp(buf, "who")) {
type = WHO_OPT;
} else if (!PL_strcasecmp(buf, "exclude")) {
type = EXCLUDE_OPT;
} else if (!PL_strcasecmp(buf, "notime")) {
type = NO_TIME_OPT;
} else if (!PL_strcasecmp(buf, "jarfile")) {
type = ZIPFILE_OPT;
} else if (!PL_strcasecmp(buf, "outfile")) {
//.........这里部分代码省略.........
开发者ID:emaldona,项目名称:nss,代码行数:101,代码来源:signtool.c
示例13: SetupMsgWriteStream
NS_IMETHODIMP nsMsgSaveAsListener::OnDataAvailable(nsIRequest* request,
nsISupports* aSupport,
nsIInputStream* inStream,
uint64_t srcOffset,
uint32_t count)
{
nsresult rv;
uint64_t available;
rv = inStream->Available(&available);
if (!m_writtenData)
{
m_writtenData = true;
rv = SetupMsgWriteStream(m_outputFile, m_addDummyEnvelope);
NS_ENSURE_SUCCESS(rv, rv);
}
bool useCanonicalEnding = false;
nsCOMPtr <nsIMsgMessageUrl> msgUrl = do_QueryInterface(aSupport);
if (msgUrl)
msgUrl->GetCanonicalLineEnding(&useCanonicalEnding);
const char *lineEnding = (useCanonicalEnding) ? CRLF : MSG_LINEBREAK;
uint32_t lineEndingLength = (useCanonicalEnding) ? 2 : MSG_LINEBREAK_LEN;
uint32_t readCount, maxReadCount = SAVE_BUF_SIZE - m_leftOver;
uint32_t writeCount;
char *start, *end, lastCharInPrevBuf = '\0';
uint32_t linebreak_len = 0;
while (count > 0)
{
if (count < maxReadCount)
maxReadCount = count;
rv = inStream->Read(m_dataBuffer + m_leftOver,
maxReadCount,
&readCount);
if (NS_FAILED(rv)) return rv;
m_leftOver += readCount;
m_dataBuffer[m_leftOver] = '\0';
start = m_dataBuffer;
// make sure we don't insert another LF, accidentally, by ignoring
// second half of CRLF spanning blocks.
if (lastCharInPrevBuf == '\r' && *start == '\n')
start++;
end = PL_strchr(start, '\r');
if (!end)
end = PL_strchr(start, '\n');
else if (*(end+1) == '\n' && linebreak_len == 0)
linebreak_len = 2;
if (linebreak_len == 0) // not initialize yet
linebreak_len = 1;
count -= readCount;
maxReadCount = SAVE_BUF_SIZE - m_leftOver;
if (!end && count > maxReadCount)
// must be a very very long line; sorry cannot handle it
return NS_ERROR_FAILURE;
while (start && end)
{
if (m_outputStream &&
PL_strncasecmp(start, "X-Mozilla-Status:", 17) &&
PL_strncasecmp(start, "X-Mozilla-Status2:", 18) &&
PL_strncmp(start, "From - ", 7))
{
rv = m_outputStream->Write(start, end-start, &writeCount);
nsresult tmp = m_outputStream->Write(lineEnding, lineEndingLength, &writeCount);
if (NS_FAILED(tmp)) {
rv = tmp;
}
}
start = end+linebreak_len;
if (start >= m_dataBuffer + m_leftOver)
{
maxReadCount = SAVE_BUF_SIZE;
m_leftOver = 0;
break;
}
end = PL_strchr(start, '\r');
if (!end)
end = PL_strchr(start, '\n');
if (start && !end)
{
m_leftOver -= (start - m_dataBuffer);
memcpy(m_dataBuffer, start,
m_leftOver+1); // including null
maxReadCount = SAVE_BUF_SIZE - m_leftOver;
}
}
if (NS_FAILED(rv)) return rv;
if (end)
lastCharInPrevBuf = *end;
}
return rv;
//.........这里部分代码省略.........
开发者ID:stonewell,项目名称:exchange-ews-thunderbird,代码行数:101,代码来源:MsgMailNewsUrlBase.cpp
示例14: LoadExtraSharedLibs
static void LoadExtraSharedLibs()
{
// check out if user's prefs.js has libs name
nsresult res;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
if (NS_SUCCEEDED(res) && (prefs != nsnull)) {
char *sonameList = NULL;
PRBool prefSonameListIsSet = PR_TRUE;
res = prefs->GetCharPref(PREF_PLUGINS_SONAME, &sonameList);
if (!sonameList) {
// pref is not set, lets use hardcoded list
prefSonameListIsSet = PR_FALSE;
sonameList = PL_strdup(DEFAULT_EXTRA_LIBS_LIST);
}
if (sonameList) {
char *arrayOfLibs[PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS] = {0};
int numOfLibs = 0;
char *nextToken;
char *p = nsCRT::strtok(sonameList,":",&nextToken);
if (p) {
while (p && numOfLibs < PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS) {
arrayOfLibs[numOfLibs++] = p;
p = nsCRT::strtok(nextToken,":",&nextToken);
}
} else // there is just one lib
arrayOfLibs[numOfLibs++] = sonameList;
char sonameListToSave[PLUGIN_MAX_LEN_OF_TMP_ARR] = "";
for (int i=0; i<numOfLibs; i++) {
// trim out head/tail white spaces (just in case)
PRBool head = PR_TRUE;
p = arrayOfLibs[i];
while (*p) {
if (*p == ' ' || *p == '\t') {
if (head) {
arrayOfLibs[i] = ++p;
} else {
*p = 0;
}
} else {
head = PR_FALSE;
p++;
}
}
if (!arrayOfLibs[i][0]) {
continue; // null string
}
PRBool tryToGetSoname = PR_TRUE;
if (PL_strchr(arrayOfLibs[i], '/')) {
//assuming it's real name, try to stat it
struct stat st;
if (stat((const char*) arrayOfLibs[i], &st)) {
//get just a file name
arrayOfLibs[i] = PL_strrchr(arrayOfLibs[i], '/') + 1;
} else
tryToGetSoname = PR_FALSE;
}
char *soname = NULL;
if (LoadExtraSharedLib(arrayOfLibs[i], &soname, tryToGetSoname)) {
//construct soname's list to save in prefs
p = soname ? soname : arrayOfLibs[i];
int n = PLUGIN_MAX_LEN_OF_TMP_ARR -
(PL_strlen(sonameListToSave) + PL_strlen(p));
if (n > 0) {
PL_strcat(sonameListToSave, p);
PL_strcat(sonameListToSave,":");
}
if (soname) {
PL_strfree(soname); // it's from strdup
}
if (numOfLibs > 1)
arrayOfLibs[i][PL_strlen(arrayOfLibs[i])] = ':'; //restore ":" in sonameList
}
}
// Check whether sonameListToSave is a empty String, Bug: 329205
if (sonameListToSave[0])
for (p = &sonameListToSave[PL_strlen(sonameListToSave) - 1]; *p == ':'; p--)
*p = 0; //delete tail ":" delimiters
if (!prefSonameListIsSet || PL_strcmp(sonameList, sonameListToSave)) {
// if user specified some bogus soname I overwrite it here,
// otherwise it'll decrease performance by calling popen() in SearchForSoname
// every time for each bogus name
prefs->SetCharPref(PREF_PLUGINS_SONAME, (const char *)sonameListToSave);
}
PL_strfree(sonameList);
}
}
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:90,代码来源:nsPluginsDirUnix.cpp
示例15: SetupMsgWriteStream
NS_IMETHODIMP nsMsgSaveAsListener::OnDataAvailable(nsIRequest* request,
nsISupports* aSupport,
nsIInputStream* inStream,
PRUint32 srcOffset,
PRUint32 count)
{
nsresult rv;
PRUint32 available;
rv = inStream->Available(&available);
if (!m_writtenData)
{
m_writtenData = PR_TRUE;
rv = SetupMsgWriteStream(m_outputFile, m_addDummyEnvelope);
NS_ENSURE_SUCCESS(rv, rv);
}
PRBool useCanonicalEnding = PR_FALSE;
nsCOMPtr <nsIMsgMessageUrl> msgUrl = do_QueryInterface(aSupport);
if (msgUrl)
msgUrl->GetCanonicalLineEnding(&useCanonicalEnding);
const char *lineEnding = (useCanonicalEnding) ? CRLF : MSG_LINEBREAK;
PRUint32 lineEndingLength = (useCanonicalEnding) ? 2 : MSG_LINEBREAK_LEN;
PRUint32 readCount, maxReadCount = SAVE_BUF_SIZE - m_leftOver;
PRUint32 writeCount;
char *start, *end;
PRUint32 linebreak_len = 0;
while (count > 0)
{
if (count < maxReadCount)
maxReadCount = count;
rv = inStream->Read(m_dataBuffer + m_leftOver,
maxReadCount,
&readCount);
if (NS_FAILED(rv)) return rv;
m_leftOver += readCount;
m_dataBuffer[m_leftOver] = '\0';
start = m_dataBuffer;
end = PL_strchr(start, '\r');
if (!end)
end = PL_strchr(start, '\n');
else if (*(end+1) == '\n' && linebreak_len == 0)
linebreak_len = 2;
if (linebreak_len == 0) // not initialize yet
linebreak_len = 1;
count -= readCount;
maxReadCount = SAVE_BUF_SIZE - m_leftOver;
if (!end && count > maxReadCount)
// must be a very very long line; sorry cannot handle it
return NS_ERROR_FAILURE;
while (start && end)
{
if (PL_strncasecmp(start, "X-Mozilla-Status:", 17) &&
PL_strncasecmp(start, "X-Mozilla-Status2:", 18) &&
PL_strncmp(start, "From - ", 7))
{
rv = m_outputStream->Write(start, end-start, &writeCount);
rv = m_outputStream->Write(lineEnding, lineEndingLength, &writeCount);
}
start = end+linebreak_len;
if (start >= m_dataBuffer + m_leftOver)
{
maxReadCount = SAVE_BUF_SIZE;
m_leftOver = 0;
break;
}
end = PL_strchr(start, '\r');
if (!end)
end = PL_strchr(start, '\n');
if (start && !end)
{
m_leftOver -= (start - m_dataBuffer);
memcpy(m_dataBuffer, start,
m_leftOver+1); // including null
maxReadCount = SAVE_BUF_SIZE - m_leftOver;
}
}
if (NS_FAILED(rv)) return rv;
}
return rv;
// rv = m_outputStream->WriteFrom(inStream, PR_MIN(available, count), &bytesWritten);
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:91,代码来源:nsMsgMailNewsUrl.cpp
示例16: MimeMultipartRelated_output_child_p
static bool
MimeMultipartRelated_output_child_p(MimeObject *obj, MimeObject* child)
{
MimeMultipartRelated *relobj = (MimeMultipartRelated *) obj;
/* rhp - Changed from "if (relobj->head_loaded)" alone to support the
start parameter
*/
if (
(relobj->head_loaded) ||
(MimeStartParamExists(obj, child) && !MimeThisIsStartPart(obj, child))
)
{
/* This is a child part. Just remember the mapping between the URL
it represents and the part-URL to get it back. */
char* location = MimeHeaders_get(child->headers, HEADER_CONTENT_LOCATION,
false, false);
if (!location) {
char* tmp = MimeHeaders_get(child->headers, HEADER_CONTENT_ID,
false, false);
if (tmp) {
char* tmp2 = tmp;
if (*tmp2 == '<') {
int length;
tmp2++;
length = strlen(tmp2);
if (length > 0 && tmp2[length - 1] == '>') {
tmp2[length - 1] = '\0';
}
}
location = PR_smprintf("cid:%s", tmp2);
PR_Free(tmp);
}
}
if (location) {
char *absolute;
char *base_url = MimeHeaders_get(child->headers, HEADER_CONTENT_BASE,
false, false);
absolute = MakeAbsoluteURL(base_url ? base_url : relobj->base_url, location);
PR_FREEIF(base_url);
PR_Free(location);
if (absolute) {
nsCAutoString partnum;
nsCAutoString imappartnum;
partnum.Adopt(mime_part_address(child));
if (!partnum.IsEmpty()) {
if (obj->options->missing_parts)
{
char * imappart = mime_imap_part_address(child);
if (imappart)
imappartnum.Adopt(imappart);
}
/*
AppleDouble part need special care: we need to output only the data fork part of it.
The problem at this point is that we haven't yet decoded the children of the AppleDouble
part therfore we will have to hope the datafork is the second one!
*/
if (mime_typep(child, (MimeObjectClass *) &mimeMultipartAppleDoubleClass))
partnum.Append(".2");
char* part;
if (!imappartnum.IsEmpty())
part = mime_set_url_imap_part(obj->options->url, imappartnum.get(), partnum.get());
else
{
char *no_part_url = nullptr;
if (obj->options->part_to_load && obj->options->format_out == nsMimeOutput::nsMimeMessageBodyDisplay)
no_part_url = mime_get_base_url(obj->options->url);
if (no_part_url)
{
part = mime_set_url_part(no_part_url, partnum.get(), false);
PR_Free(no_part_url);
}
else
part = mime_set_url_part(obj->options->url, partnum.get(), false);
}
if (part)
{
char *name = MimeHeaders_get_name(child->headers, child->options);
// let's stick the filename in the part so save as will work.
if (name)
{
//char *savePart = part;
//part = PR_smprintf("%s&filename=%s", savePart, name);
//PR_Free(savePart);
PR_Free(name);
}
char *temp = part;
/* If there's a space in the url, escape the url.
(This happens primarily on Windows and Unix.) */
if (PL_strchr(part, ' ') || PL_strchr(part, '>') || PL_strchr(part, '%'))
temp = escape_for_mrel_subst(part);
MimeHashValue * value = new MimeHashValue(child, temp);
PL_HashTableAdd(relobj->hash, absolute, value);
/* rhp - If this part ALSO has a Content-ID we need to put that into
//.........这里部分代码省略.........
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:101,代码来源:mimemrel.cpp
示例17: NS_ENSURE_ARG_POINTER
// parse condition like "(subject, contains, fred) AND (body, isn't, "foo)")"
// values with close parens will be quoted.
// what about values with close parens and quotes? e.g., (body, isn't, "foo")")
// I guess interior quotes will need to be escaped - ("foo\")")
// which will get written out as (\"foo\\")\") and read in as ("foo\")"
// ALL means match all messages.
NS_IMETHODIMP nsMsgFilterList::ParseCondition(nsIMsgFilter *aFilter, const char *aCondition)
{
NS_ENSURE_ARG_POINTER(aFilter);
bool done = false;
nsresult err = NS_OK;
const char *curPtr = aCondition;
if (!strcmp(aCondition, "ALL"))
{
nsMsgSearchTerm *newTerm = new nsMsgSearchTerm;
if (newTerm)
{
newTerm->m_matchAll = true;
aFilter->AppendTerm(newTerm);
}
return (newTerm) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
while (!done)
{
// insert code to save the boolean operator if there is one for this search term....
const char *openParen = PL_strchr(curPtr, '(');
const char *orTermPos = PL_strchr(curPtr, 'O'); // determine if an "OR" appears b4 the openParen...
bool ANDTerm = true;
if (orTermPos && orTermPos < openParen) // make sure OR term falls before the '('
ANDTerm = false;
char *termDup = nullptr;
if (openParen)
{
bool foundEndTerm = false;
bool inQuote = false;
for (curPtr = openParen +1; *curPtr; curPtr++)
{
if (*curPtr == '\\' && *(curPtr + 1) == '"')
curPtr++;
else if (*curPtr == ')' && !inQuote)
{
foundEndTerm = true;
break;
}
else if (*curPtr == '"')
inQuote = !inQuote;
}
if (foundEndTerm)
{
int termLen = curPtr - openParen - 1;
termDup = (char *) PR_Malloc(termLen + 1);
if (termDup)
{
PL_strncpy(termDup, openParen + 1, termLen + 1);
termDup[termLen] = '\0';
}
else
{
err = NS_ERROR_OUT_OF_MEMORY;
break;
}
}
}
else
break;
if (termDup)
{
nsMsgSearchTerm *newTerm = new nsMsgSearchTerm;
if (newTerm)
{
/* Invert nsMsgSearchTerm::EscapeQuotesInStr() */
for (char *to = termDup, *from = termDup;;)
{
if (*from == '\\' && from[1] == '"') from++;
if (!(*to++ = *from++)) break;
}
newTerm->m_booleanOp = (ANDTerm) ? nsMsgSearchBooleanOp::BooleanAND
: nsMsgSearchBooleanOp::BooleanOR;
err = newTerm->DeStreamNew(termDup, PL_strlen(termDup));
NS_ENSURE_SUCCESS(err, err);
aFilter->AppendTerm(newTerm);
}
PR_FREEIF(termDup);
}
else
break;
}
return err;
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:95,代码来源:nsMsgFilterList.cpp
示例18: DecodeRFC2047Str
// |decode_mime_part2_str| taken from comi18n.c
// Decode RFC2047-encoded words in the input and convert the result to UTF-8.
// If aOverrideCharset is true, charset in RFC2047-encoded words is
// ignored and aDefaultCharset is assumed, instead. aDefaultCharset
// is also used to convert raw octets (without RFC 2047 encoding) to UTF-8.
//static
nsresult DecodeRFC2047Str(const char *aHeader, const char *aDefaultCharset,
PRBool aOverrideCharset, nsACString &aResult)
{
const char *p, *q, *r;
char *decodedText;
const char *begin; // tracking pointer for where we are in the input buffer
PRInt32 isLastEncodedWord = 0;
const char *charsetStart, *charsetEnd;
char charset[80];
// initialize charset name to an empty string
charset[0] = '\0';
begin = aHeader;
// To avoid buffer realloc, if possible, set capacity in advance. No
// matter what, more than 3x expansion can never happen for all charsets
// supported by Mozilla. SCSU/BCSU with the sliding window set to a
// non-BMP block may be exceptions, but Mozilla does not support them.
// Neither any known mail/news program use them. Even if there's, we're
// safe because we don't use a raw *char any more.
aResult.SetCapacity(3 * strlen(aHeader));
while ((p = PL_strstr(begin, "=?")) != 0) {
if (isLastEncodedWord) {
// See if it's all whitespace.
for (q = begin; q < p; ++q) {
if (!PL_strchr(" \t\r\n", *q)) break;
}
}
if (!isLastEncodedWord || q < p) {
// copy the part before the encoded-word
CopyRawHeader(begin, p - begin, aDefaultCharset, aResult);
begin = p;
}
p += 2;
// Get charset info
charsetStart = p;
charsetEnd = 0;
for (q = p; *q != '?'; q++) {
if (*q <= ' ' || PL_strchr(especials, *q)) {
goto badsyntax;
}
// RFC 2231 section 5
if (!charsetEnd && *q == '*') {
charsetEnd = q;
}
}
if (!charsetEnd) {
charsetEnd = q;
}
// Check for too-long charset name
if (PRUint32(charsetEnd - charsetStart) >= sizeof(charset))
goto badsyntax;
memcpy(charset, charsetStart, charsetEnd - charsetStart);
charset[charsetEnd - charsetStart] = 0;
q++;
if (*q != 'Q' && *q != 'q' && *q != 'B' && *q != 'b')
goto badsyntax;
if (q[1] != '?')
goto badsyntax;
r = q;
for (r = q + 2; *r != '?'; r++) {
if (*r < ' ') goto badsyntax;
}
if (r[1] != '=')
goto badsyntax;
else if (r == q + 2) {
// it's empty, skip
begin = r + 2;
isLastEncodedWord = 1;
continue;
}
if(*q == 'Q' || *q == 'q')
decodedText = DecodeQ(q + 2, r - (q + 2));
else {
// bug 227290. ignore an extraneous '=' at the end.
// (# of characters in B-encoded part has to be a multiple of 4)
PRInt32 n = r - (q + 2);
n -= (n % 4 == 1 && !PL_strncmp(r - 3, "===", 3)) ? 1 : 0;
decodedText = PL_Base64Decode(q + 2, n, nsnull);
}
if (decodedText == nsnull)
//.........这里部分代码省略.........
开发者ID:mmmulani,项目名称:v8monkey,代码行数:101,代码来源:nsMIMEHeaderParamImpl.cpp
示例19: nsMsgI18NParseMetaCharset
// Simple parser to parse META charset.
// It only supports the case when the description is within one line.
const char *
nsMsgI18NParseMetaCharset(nsIFile* file)
{
static char charset[nsIMimeConverter::MAX_CHARSET_NAME_LENGTH+1];
*charset = '\0';
bool isDirectory = false;
file->IsDirectory(&isDirectory);
if (isDirectory) {
NS_ERROR("file is a directory");
return charset;
}
nsresult rv;
nsCOMPtr <nsIFileInputStream> fileStream = do_CreateInstance(NS_LOCALFILEINPUTSTREAM_CONTRACTID, &rv);
NS_ENSURE_
|
请发表评论