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


C++ PL_strdup函数代码示例

本文整理汇总了C++中PL_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ PL_strdup函数的具体用法?C++ PL_strdup怎么用?C++ PL_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PL_strdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: PL_strdup

/* str is the string which needs to be unserialized.
   If prefixes is NULL, simply returns the number of namespaces in str.  (len is ignored)
   If prefixes is not NULL, it should be an array of length len which is to be filled in
   with newly-allocated string.  Returns the number of strings filled in.
*/
int nsIMAPNamespaceList::UnserializeNamespaces(const char *str, char **prefixes, int len)
{
    if (!str)
        return 0;
    if (!prefixes)
    {
        if (str[0] != '"')
            return 1;
        else
        {
            int count = 0;
            char *ourstr = PL_strdup(str);
            char *origOurStr = ourstr;
            if (ourstr)
            {
                char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
                while (token != nullptr)
                {
                    token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
                    count++;
                }
                PR_Free(origOurStr);
            }
            return count;
        }
    }
    else
    {
        if ((str[0] != '"') && (len >= 1))
        {
            prefixes[0] = PL_strdup(str);
            return 1;
        }
        else
        {
            int count = 0;
            char *ourstr = PL_strdup(str);
            char *origOurStr = ourstr;
            if (ourstr)
            {
                char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
                while ((count < len) && (token != nullptr))
                {

                    char *current = PL_strdup(token), *where = current;
                    if (where[0] == '"')
                        where++;
                    if (where[PL_strlen(where)-1] == '"')
                        where[PL_strlen(where)-1] = 0;
                    prefixes[count] = PL_strdup(where);
                    PR_FREEIF(current);
                    token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
                    count++;
                }
                PR_Free(origOurStr);
            }
            return count;
        }
    }
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:65,代码来源:nsIMAPNamespace.cpp

示例3: NS_ENSURE_TRUE

nsresult
GConfProxy::GetCharPref(const char *aMozKey, char **retval)
{
    NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE);

    const gchar *gconfkey = MozKey2GConfKey(aMozKey);

    if (!strcmp (aMozKey, "network.proxy.no_proxies_on")) {
        GSList *s;
        nsCString noproxy;
        GSList *gslist = GConfClientGetList(mGConfClient, gconfkey,
                                            GCONF_VALUE_STRING, NULL);

        for (s = gslist; s; s = g_slist_next(s)) {
            noproxy += (char *)s->data;
            noproxy += ", ";
            g_free ((char *)s->data);
        }
        g_slist_free (gslist);

        *retval = PL_strdup(noproxy.get());
    } else {
        gchar *str = GConfClientGetString(mGConfClient, gconfkey, NULL);
        if (str) {
            *retval = PL_strdup(str);
            g_free (str);
        }
    }

    return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:31,代码来源:nsSystemPrefService.cpp

示例4: Mark

// static 
void Mark(PRUint32 aType, void * aItem, const char * aText, const char * aText2)
{
#ifdef MOZ_VISUAL_EVENT_TRACER
  if (!gInitialized)
    return;

  if (aType == eNone)
    return;

  if (!CheckEventFilters(aType, aItem, aText)) // Events use just aText
    return;

  RecordBatch * threadLogPrivate = static_cast<RecordBatch *>(
      PR_GetThreadPrivate(gThreadPrivateIndex));
  if (!threadLogPrivate) {
    // Deletion is made by the flushing thread
    threadLogPrivate = new RecordBatch();
    PR_SetThreadPrivate(gThreadPrivateIndex, threadLogPrivate);
  }

  Record * record = threadLogPrivate->mNextRecord;
  record->mType = aType;
  record->mTime = (mozilla::TimeStamp::Now() - gProfilerStart).ToMilliseconds();
  record->mItem = aItem;
  record->mText = PL_strdup(aText);
  record->mText2 = aText2 ? PL_strdup(aText2) : nsnull;

  ++threadLogPrivate->mNextRecord;
  if (threadLogPrivate->mNextRecord == threadLogPrivate->mRecordsTail) {
    // This calls RecordBatch::FlushBatch(threadLogPrivate)
    PR_SetThreadPrivate(gThreadPrivateIndex, nsnull);
  }
#endif
}
开发者ID:mozilla,项目名称:pjs,代码行数:35,代码来源:VisualEventTracer.cpp

示例5: DosLoadModule

// Obtains all of the information currently available for this plugin.
nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
{
   nsresult   rv = NS_ERROR_FAILURE;
   HMODULE    hPlug = 0; // Need a HMODULE to query resource statements
   char       failure[ CCHMAXPATH] = "";
   APIRET     ret;

   nsCAutoString path;
   if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
     return rv;

   nsCAutoString fileName;
   if (NS_FAILED(rv = mPlugin->GetNativeLeafName(fileName)))
     return rv;

   ret = DosLoadModule( failure, CCHMAXPATH, path.get(), &hPlug);
   info.fVersion = nsnull;

   while( ret == NO_ERROR)
   {
      info.fName = LoadRCDATAString( hPlug, NS_INFO_ProductName);

      info.fVersion = LoadRCDATAVersion( hPlug, NS_INFO_ProductVersion);

      // get description (doesn't matter if it's missing)...
      info.fDescription = LoadRCDATAString( hPlug, NS_INFO_FileDescription);

      char * mimeType = LoadRCDATAString( hPlug, NS_INFO_MIMEType);
      if( nsnull == mimeType) break;

      char * mimeDescription = LoadRCDATAString( hPlug, NS_INFO_FileOpenName);
      if( nsnull == mimeDescription) break;

      char * extensions = LoadRCDATAString( hPlug, NS_INFO_FileExtents);
      if( nsnull == extensions) break;

      info.fVariantCount = CalculateVariantCount(mimeType);

      info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
      if( info.fMimeTypeArray == nsnull) break;

      info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
      if( nsnull == info.fMimeDescriptionArray) break;

      info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
      if( nsnull == info.fExtensionArray) break;

      info.fFullPath = PL_strdup(path.get());
      info.fFileName = PL_strdup(fileName.get());

      rv = NS_OK;
      break;
   }

   if( 0 != hPlug)
      DosFreeModule( hPlug);

   return rv;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:60,代码来源:nsPluginsDirOS2.cpp

示例6: SECU_GetModulePassword

char *
SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg) 
{
#if(0)
    char prompt[255];
#endif
    secuPWData *pwdata = (secuPWData *)arg;
    secuPWData pwnull = { PW_NONE, 0 };
    secuPWData pwxtrn = { PW_EXTERNAL, "external" };
    char *pw;

    if (pwdata == NULL)
        pwdata = &pwnull;

    if (PK11_ProtectedAuthenticationPath(slot)) {
        pwdata = &pwxtrn;
    }
    if (retry && pwdata->source != PW_NONE) {
        PR_fprintf(PR_STDERR, "Incorrect password/PIN entered.\n");
        return NULL;
    }

    switch (pwdata->source) {
#if(0)
    case PW_NONE:
        sprintf(prompt, "Enter Password or Pin for \"%s\":",
	            PK11_GetTokenName(slot));
        return SECU_GetPasswordString(NULL, prompt);
#endif

    case PW_FROMFILE:
	    /* Instead of opening and closing the file every time, get the pw
	     * once, then keep it in memory (duh).
	     */
	    pw = SECU_FilePasswd(slot, retry, pwdata->data);
	    pwdata->source = PW_PLAINTEXT;
	    pwdata->data = PL_strdup(pw);
	    /* it's already been dup'ed */
	    return pw;
#if(0)
    case PW_EXTERNAL:
        sprintf(prompt, 
	            "Press Enter, then enter PIN for \"%s\" on external device.\n",
                PK11_GetTokenName(slot));
        (void) SECU_GetPasswordString(NULL, prompt);
    	/* Fall Through */
#endif
   case PW_PLAINTEXT:
	    return PL_strdup(pwdata->data);
    default:
	    break;
    }

    PR_fprintf(PR_STDERR, "Password check failed:  No password found.\n");
    return NULL;
}
开发者ID:gooselinux,项目名称:crypto-utils,代码行数:56,代码来源:secutil.c

示例7: NS_ASSERTION

int nsMsgSendPart::CopyString(char** dest, const char* src)
{
  NS_ASSERTION(src, "src null");
  
  PR_FREEIF(*dest);
  if (!src)
    *dest = PL_strdup("");
  else
    *dest = PL_strdup(src);
  
  return *dest? 0 : NS_ERROR_OUT_OF_MEMORY;
}
开发者ID:vanto,项目名称:comm-central,代码行数:12,代码来源:nsMsgSendPart.cpp

示例8: SetValue

 SKERR SetValue(const char* pKey, const char* pValue)
 {
     char * pOldValue;
     if((pOldValue = (char*) PL_HashTableLookup(m_pHash, pKey)))
     {
         PL_HashTableRemove(m_pHash, pKey);
     }
     char* pHashKey = PL_strdup(pKey);
     char* pHashValue = PL_strdup(pValue);
     PL_HashTableAdd(m_pHash, pHashKey, pHashValue);
     return noErr;
 }
开发者ID:developercyrus,项目名称:skmobile,代码行数:12,代码来源:envir.cpp

示例9: GetValue

    SKERR GetValue(const char* pKey, char **pValue)
    {
        *pValue = (char *)PL_HashTableLookup(m_pHash, pKey);

        if(*pValue)
        {
            *pValue = PL_strdup(*pValue);
        }
        else
            *pValue = PL_strdup("");

        return noErr;
    }
开发者ID:developercyrus,项目名称:skmobile,代码行数:13,代码来源:envir.cpp

示例10: PR_Lock

void ConfigStore::Add(const char *name, const char *value)
{
	if (IsNameDefined(name)) {
          PR_Lock(m_lock);
	  PL_HashTableRemove(m_root->getSet(), name);
	  PL_HashTableAdd(m_root->getSet(), PL_strdup(name), PL_strdup(value));
          PR_Unlock(m_lock);
	} else {
          PR_Lock(m_lock);
	  PL_HashTableAdd(m_root->getSet(), PL_strdup(name), PL_strdup(value));
          PR_Unlock(m_lock);
	}
}
开发者ID:encukou,项目名称:pki,代码行数:13,代码来源:ConfigStore.cpp

示例11: PL_strdup

/**
 * Constructs a base class for HttpConnection
 */
TPS_PUBLIC HttpConnection::HttpConnection(const char *id, ConnectionInfo *cinfo, int retries, int timeout,
  bool isSSL, const char *nickname, bool keepAlive, NameValueSet *headers)
{
    m_failoverList = cinfo;
    m_retries = retries;
    m_timeout = timeout;
    m_Id = PL_strdup(id);
    m_isSSL = isSSL;
    m_clientnickname = PL_strdup(nickname);
    m_keepAlive = keepAlive;
    m_headers = headers;
    m_curr = 0;
    m_lock = PR_NewLock();
}
开发者ID:encukou,项目名称:pki,代码行数:17,代码来源:HttpConnection.cpp

示例12: OrderLoop

/**
 * Called from PL_HashTableEnumerateEntries
 * A pointer to a PRCList (circular linked list) is passed in. 
 * Once enumeration is complete, the PRCList will contain a lexically
 * ordered list of a copy of the keys in the hash.  
 * The caller needs to free the copies
 */ 
static PRIntn OrderLoop(PLHashEntry *he, PRIntn index, void *arg)
{
    PRCList *qp = (PRCList *)arg;
    OrderedEntry_t *entry;

    if (he != NULL) {
        entry = (OrderedEntry_t *) PR_Malloc(sizeof(OrderedEntry_t));
        entry->key = PL_strdup((char *) he->key);
        if (index ==0) {
            PR_APPEND_LINK((PRCList *)entry, qp);
            return HT_ENUMERATE_NEXT;
        }
        PRCList *head = PR_LIST_HEAD(qp);
        PRCList *next;
        while (head != qp) {
            OrderedEntry_t *current = (OrderedEntry_t *) head;
            if (strcmp((char *) he->key, (char *) current->key) <=0) 
                break;
            next = PR_NEXT_LINK(head);
            head = next;
        }
        PR_INSERT_BEFORE((PRCList*) entry, head);
        return HT_ENUMERATE_NEXT;
    } else {
        return HT_ENUMERATE_STOP;
    }
}
开发者ID:encukou,项目名称:pki,代码行数:34,代码来源:ConfigStore.cpp

示例13: NS_ASSERTION

/*
  GetFolderNameWithoutNamespace takes as input a folder name
  in canonical form, and the namespace for the given folder.  It returns an allocated
  string of the folder's path with the namespace string stripped out.  For instance,
  when passed the folder Folders/a/b where the namespace is "Folders/", it will return
  "a/b".  Similarly, if the folder name is "#news/comp/mail/imap" in canonical form,
  with a real delimiter of "." and a namespace of "#news.", it will return "comp/mail/imap".
  The return value is always in canonical form.
*/
char* nsIMAPNamespaceList::GetFolderNameWithoutNamespace(nsIMAPNamespace *namespaceForFolder, const char *canonicalFolderName)
{
    NS_ASSERTION(canonicalFolderName, "null folder name");
#ifdef DEBUG
    NS_ASSERTION(namespaceForFolder || !PL_strcasecmp(canonicalFolderName, "INBOX"), "need namespace or INBOX");
#endif

    char *retFolderName = nullptr;

    if (!PL_strcasecmp(canonicalFolderName, "INBOX"))
        return PL_strdup(canonicalFolderName);

    // convert the canonical path to the online path
    char *convertedFolderName = nsIMAPNamespaceList::AllocateServerFolderName(canonicalFolderName, namespaceForFolder->GetDelimiter());
    if (convertedFolderName)
    {
        char *beginFolderPath = nullptr;
        if (strlen(convertedFolderName) <= strlen(namespaceForFolder->GetPrefix()))
            beginFolderPath = convertedFolderName;
        else
            beginFolderPath = convertedFolderName + strlen(namespaceForFolder->GetPrefix());
        NS_ASSERTION(beginFolderPath, "empty folder path");
        retFolderName = nsIMAPNamespaceList::AllocateCanonicalFolderName(beginFolderPath, namespaceForFolder->GetDelimiter());
        PR_Free(convertedFolderName);
    }

    NS_ASSERTION(retFolderName, "returning null folder name");
    return retFolderName;
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:38,代码来源:nsIMAPNamespace.cpp

示例14: PL_strdup

char *passwdcb(PK11SlotInfo *info, PRBool retry, void *arg)
{
  if (!retry)
    return PL_strdup("test");
  else
    return NULL;
}
开发者ID:levisjani,项目名称:code--sinppets,代码行数:7,代码来源:symetric+key.cpp

示例15: PL_strdup

ConfigStore::ConfigStore(ConfigStoreRoot* root, const char *subStoreName)
{ 
	m_substore_name = PL_strdup(subStoreName);
	m_root = root;
	root->addref();
        m_lock = PR_NewLock();
}
开发者ID:encukou,项目名称:pki,代码行数:7,代码来源:ConfigStore.cpp


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