Пример #1
0
void nsHTMLTags::AddTag(int aEnum, const char *aTagName) {
  if (!kExpandedTagUnicodeTableInited) {
    memset(kExpandedTagUnicodeTable, 0, sizeof(kExpandedTagUnicodeTable));
    kExpandedTagUnicodeTableInited = true;
  }

  int len = strlen(aTagName);
  NS_ASSERTION(len <= NS_HTMLTAG_NAME_MAX_LENGTH, "bad tag");

  PRUnichar *buf = (PRUnichar*)malloc((NS_HTMLTAG_NAME_MAX_LENGTH + 1)
                                      * sizeof(PRUnichar));
  PRUnichar *buf_under = (PRUnichar*)malloc((NS_HTMLTAG_NAME_MAX_LENGTH + 1)
                                            * sizeof(PRUnichar));
  int i = 0;
  bool hasUnderScore = false;
  for (const char *p = aTagName; *p; p++) {
    char ch = *p;
    if (ch <= 'Z' && ch >= 'A') ch |= 0x20;
    if (ch == '_') ch = '-';
    buf[i] = ch;
    if (ch == '-') {
      ch = '_';
      hasUnderScore = true;
    }
    buf_under[i] = ch;
    if (++i >= NS_HTMLTAG_NAME_MAX_LENGTH - 1) break;
  }
  buf[i] = 0;
  buf_under[i] = 0;

  int index = aEnum - eHTMLTag_userdefined;
  if (index < 0 || index >= sizeof(kExpandedTagUnicodeTable)/sizeof(kExpandedTagUnicodeTable[0])) {
    free(buf);
    free(buf_under);
    return;
  }

  // remove old tags that are maapped to the enum
  RemoveExpandedTag(index);

  // add new tags
  PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, buf));
  if (tag == eHTMLTag_unknown) {
    kExpandedTagUnicodeTable[index] = buf;
    PL_HashTableAdd(gTagTable, buf, NS_INT32_TO_PTR(aEnum));
    if (hasUnderScore) {
      kExpandedTagUnicodeUnderScoreTable[index] = buf_under;
      PL_HashTableAdd(gTagTable, buf_under, NS_INT32_TO_PTR(aEnum));
    } else {
      free(buf_under);
    }
  } else {
    free(buf);
    free(buf_under);
  }

  if (len > sMaxTagNameLength) {
    sMaxTagNameLength = len;
  }
}
Пример #2
0
// static
nsHTMLTag
nsHTMLTags::CaseSensitiveLookupTag(const PRUnichar* aTagName)
{
  NS_ASSERTION(gTagTable, "no lookup table, needs addref");
  NS_ASSERTION(aTagName, "null tagname!");

  PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));

  return tag == eHTMLTag_unknown ? eHTMLTag_userdefined : (nsHTMLTag)tag;
}
Пример #3
0
// retrieve the series saved in SetTokenName above
PRUint32
SmartCardMonitoringThread::GetTokenSeries(CK_SLOT_ID slotid)
{
  PRUint32 series = 0;
  const char *entry;

  if (mHash) {
    entry = (const char *)PL_HashTableLookupConst(mHash,(void *)slotid);
    if (entry) {
      memcpy(&series,entry,sizeof(PRUint32));
    }
  }
  return series;
}
Пример #4
0
// retrieve the name saved above
const char *
SmartCardMonitoringThread::GetTokenName(CK_SLOT_ID slotid)
{
  const char *tokenName = nsnull;
  const char *entry;

  if (mHash) {
    entry = (const char *)PL_HashTableLookupConst(mHash,(void *)slotid);
    if (entry) {
      tokenName = &entry[sizeof(PRUint32)];
    }
  }
  return tokenName;
}
Пример #5
0
PRBool
replica_updatedn_list_ismember(ReplicaUpdateDNList list, const Slapi_DN *dn)
{
	PLHashTable *hash = list;
	PRBool ret = PR_FALSE;

	const char *ndn = slapi_sdn_get_ndn(dn);

	/* Bug 605169 - null ndn would cause core dump */
	if ( ndn ) {
		if ((uintptr_t)PL_HashTableLookupConst(hash, ndn))
                    ret = PR_TRUE;
                else
                    ret = PR_FALSE;
	}

	return ret;
}
Пример #6
0
const char *ConfigStore::GetConfig(const char *name)
{ 
	char buf[256];
        char *ret;
	if (m_root->getSet() ==NULL) {
		return NULL;
	}
	if (PL_strlen(m_substore_name) == 0) {
		PL_strncpy(buf,name,256);
	} else {
		PR_snprintf(buf,256,"%s.%s",m_substore_name,name);
	}

        PR_Lock(m_lock);
        ret = (char *)PL_HashTableLookupConst(m_root->getSet(), buf);
        PR_Unlock(m_lock);

	return ret;
}