--- a/ldap/xpcom/src/Makefile.in
+++ b/ldap/xpcom/src/Makefile.in
@@ -43,18 +43,24 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = mozldap
LIBRARY_NAME = mozldap
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsLDAPProtocolModule
+
+ifndef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
MOZILLA_INTERNAL_API = 1
LIBXUL_LIBRARY = 1
+else
+FORCE_SHARED_LIB = 1
+GRE_MODULE = 1
+endif
EXTRA_COMPONENTS = \
nsLDAPProtocolHandler.js \
ldapComponents.manifest \
$(NULL)
CPPSRCS = \
nsLDAPProtocolModule.cpp \
@@ -79,12 +85,18 @@ endif
ifdef MOZ_PSM
DEFINES += -DMOZ_PSM
CPPSRCS += \
nsLDAPSecurityGlue.cpp \
$(NULL)
endif
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(LDAP_LIBS)
+ifdef MOZ_INCOMPLETE_EXTERNAL_LINKAGE
+EXTRA_DSO_LDOPTS += \
+ $(XPCOM_GLUE_LDOPTS) \
+ $(NULL)
+endif
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = $(LDAP_CFLAGS)
+
--- a/ldap/xpcom/src/nsLDAPBERElement.cpp
+++ b/ldap/xpcom/src/nsLDAPBERElement.cpp
@@ -33,17 +33,17 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPBERElement.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsCOMPtr.h"
#include "nsLDAPBERValue.h"
NS_IMPL_ISUPPORTS1(nsLDAPBERElement, nsILDAPBERElement)
nsLDAPBERElement::nsLDAPBERElement()
: mElement(0)
{
--- a/ldap/xpcom/src/nsLDAPBERValue.cpp
+++ b/ldap/xpcom/src/nsLDAPBERValue.cpp
@@ -34,18 +34,17 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPBERValue.h"
#include "nsMemory.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
+#include "nsStringGlue.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPBERValue, nsILDAPBERValue)
nsLDAPBERValue::nsLDAPBERValue() : mValue(0), mSize(0)
{
}
nsLDAPBERValue::~nsLDAPBERValue()
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -40,34 +40,34 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPInternal.h"
#include "nsIServiceManager.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
+#include "nsStringGlue.h"
#include "nsIComponentManager.h"
#include "nsLDAPConnection.h"
#include "nsLDAPMessage.h"
#include "nsThreadUtils.h"
#include "nsIConsoleService.h"
#include "nsIDNSService.h"
#include "nsIDNSRecord.h"
#include "nsIRequestObserver.h"
#include "nsNetError.h"
#include "nsLDAPOperation.h"
#include "nsILDAPErrors.h"
#include "nsIClassInfoImpl.h"
#include "nsILDAPURL.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "nsCRT.h"
+#include "nsLDAPUtils.h"
const char kConsoleServiceContractId[] = "@mozilla.org/consoleservice;1";
const char kDNSServiceContractId[] = "@mozilla.org/network/dns-service;1";
// constructor
//
nsLDAPConnection::nsLDAPConnection()
: mConnectionHandle(0),
@@ -77,17 +77,17 @@ nsLDAPConnection::nsLDAPConnection()
{
}
// destructor
//
nsLDAPConnection::~nsLDAPConnection()
{
nsCOMPtr<nsIObserverService> obsServ =
- mozilla::services::GetObserverService();
+ do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
if (obsServ)
obsServ->RemoveObserver(this, "profile-change-net-teardown");
Close();
}
NS_IMPL_THREADSAFE_ADDREF(nsLDAPConnection)
NS_IMPL_THREADSAFE_RELEASE(nsLDAPConnection)
NS_IMPL_CLASSINFO(nsLDAPConnection, NULL, nsIClassInfo::THREADSAFE,
@@ -108,19 +108,20 @@ NS_IMPL_CI_INTERFACE_GETTER4(nsLDAPConne
NS_IMETHODIMP
nsLDAPConnection::Init(nsILDAPURL *aUrl, const nsACString &aBindName,
nsILDAPMessageListener *aMessageListener,
nsISupports *aClosure, PRUint32 aVersion)
{
NS_ENSURE_ARG_POINTER(aUrl);
NS_ENSURE_ARG_POINTER(aMessageListener);
+ nsresult rv;
nsCOMPtr<nsIObserverService> obsServ =
- mozilla::services::GetObserverService();
-
+ do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
// We have to abort all LDAP pending operation before shutdown.
obsServ->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
// Save various items that we'll use later
mBindName.Assign(aBindName);
mClosure = aClosure;
mInitListener = aMessageListener;
@@ -132,18 +133,16 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl,
// Check and save the version number
if (aVersion != nsILDAPConnection::VERSION2 &&
aVersion != nsILDAPConnection::VERSION3) {
NS_ERROR("nsLDAPConnection::Init(): illegal version");
return NS_ERROR_ILLEGAL_VALUE;
}
mVersion = aVersion;
- nsresult rv;
-
// Get the port number, SSL flag for use later, once the DNS server(s)
// has resolved the host part.
rv = aUrl->GetPort(&mPort);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 options;
rv = aUrl->GetOptions(&options);
NS_ENSURE_SUCCESS(rv, rv);
@@ -180,22 +179,22 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl,
rv = aUrl->GetAsciiHost(mDNSHost);
NS_ENSURE_SUCCESS(rv, rv);
// if the caller has passed in a space-delimited set of hosts, as the
// ldap c-sdk allows, strip off the trailing hosts for now.
// Soon, we'd like to make multiple hosts work, but now make
// at least the first one work.
- mDNSHost.CompressWhitespace(PR_TRUE, PR_TRUE);
+ LdapCompressWhitespace(mDNSHost);
PRInt32 spacePos = mDNSHost.FindChar(' ');
// trim off trailing host(s)
if (spacePos != kNotFound)
- mDNSHost.Truncate(spacePos);
+ mDNSHost.SetLength(spacePos);
rv = pDNSService->AsyncResolve(mDNSHost, 0, this, curThread,
getter_AddRefs(mDNSRequest));
if (NS_FAILED(rv)) {
switch (rv) {
case NS_ERROR_OUT_OF_MEMORY:
case NS_ERROR_UNKNOWN_HOST:
@@ -346,17 +345,17 @@ nsLDAPConnection::GetErrorString(PRUnich
//
char *rv = ldap_err2string(ldap_get_lderrno(mConnectionHandle, 0, 0));
if (!rv) {
return NS_ERROR_OUT_OF_MEMORY;
}
// make a copy using the XPCOM shared allocator
//
- *_retval = UTF8ToNewUnicode(nsDependentCString(rv));
+ *_retval = ToNewUnicode(NS_ConvertUTF8toUTF16(rv));
if (!*_retval) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
/**
* Add an nsILDAPOperation to the list of operations pending on
--- a/ldap/xpcom/src/nsLDAPConnection.h
+++ b/ldap/xpcom/src/nsLDAPConnection.h
@@ -38,17 +38,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsLDAPConnection_h_
#define _nsLDAPConnection_h_
#include "nsILDAPConnection.h"
#include "ldap.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIThread.h"
#include "nsIRunnable.h"
#include "nsCOMPtr.h"
#include "nsILDAPMessageListener.h"
#include "nsInterfaceHashtable.h"
#include "nspr.h"
#include "nsWeakReference.h"
#include "nsWeakPtr.h"
--- a/ldap/xpcom/src/nsLDAPControl.h
+++ b/ldap/xpcom/src/nsLDAPControl.h
@@ -35,17 +35,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsILDAPControl.h"
#include "nsCOMPtr.h"
#include "nsILDAPBERValue.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "ldap.h"
// {5B608BBE-C0EA-4f74-B209-9CDCD79EC401}
#define NS_LDAPCONTROL_CID \
{ 0x5b608bbe, 0xc0ea, 0x4f74, \
{ 0xb2, 0x9, 0x9c, 0xdc, 0xd7, 0x9e, 0xc4, 0x1 } }
class nsLDAPControl : public nsILDAPControl
--- a/ldap/xpcom/src/nsLDAPMessage.cpp
+++ b/ldap/xpcom/src/nsLDAPMessage.cpp
@@ -38,21 +38,21 @@
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPInternal.h"
#include "nsLDAPMessage.h"
#include "nspr.h"
#include "nsDebug.h"
#include "nsCRT.h"
#include "nsLDAPConnection.h"
-#include "nsReadableUtils.h"
#include "nsISupportsUtils.h"
#include "nsLDAPBERValue.h"
#include "nsILDAPErrors.h"
#include "nsIClassInfoImpl.h"
+#include "nsLDAPUtils.h"
NS_IMPL_CLASSINFO(nsLDAPMessage, NULL, nsIClassInfo::THREADSAFE,
NS_LDAPMESSAGE_CID)
NS_IMPL_THREADSAFE_ADDREF(nsLDAPMessage)
NS_IMPL_THREADSAFE_RELEASE(nsLDAPMessage)
NS_INTERFACE_MAP_BEGIN(nsLDAPMessage)
NS_INTERFACE_MAP_ENTRY(nsILDAPMessage)
@@ -532,19 +532,19 @@ nsLDAPMessage::GetValues(const char *aAt
// clone the array (except for the trailing NULL entry) using the
// shared allocator for XPCOM correctness
//
PRUint32 i;
for ( i = 0 ; i < numVals ; i++ ) {
nsDependentCString sValue(values[i]);
if (IsUTF8(sValue))
- (*aValues)[i] = UTF8ToNewUnicode(sValue);
+ (*aValues)[i] = ToNewUnicode(NS_ConvertUTF8toUTF16(sValue));
else
- (*aValues)[i] = ToNewUnicode(sValue);
+ (*aValues)[i] = ToNewUnicode(NS_ConvertASCIItoUTF16(sValue));
if ( ! (*aValues)[i] ) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, aValues);
ldap_value_free(values);
return NS_ERROR_OUT_OF_MEMORY;
}
}
// now free our value array since we already cloned the values array
--- a/ldap/xpcom/src/nsLDAPMessage.h
+++ b/ldap/xpcom/src/nsLDAPMessage.h
@@ -39,17 +39,16 @@
#ifndef _nsLDAPMessage_h_
#define _nsLDAPMessage_h_
#include "ldap.h"
#include "nsILDAPMessage.h"
#include "nsILDAPOperation.h"
#include "nsCOMPtr.h"
-#include "nsHashtable.h"
// 76e061ad-a59f-43b6-b812-ee6e8e69423f
//
#define NS_LDAPMESSAGE_CID \
{ 0x76e061ad, 0xa59f, 0x43b6, \
{ 0xb8, 0x12, 0xee, 0x6e, 0x8e, 0x69, 0x42, 0x3f }}
class nsLDAPMessage : public nsILDAPMessage
--- a/ldap/xpcom/src/nsLDAPModification.cpp
+++ b/ldap/xpcom/src/nsLDAPModification.cpp
@@ -36,16 +36,17 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPModification.h"
#include "nsILDAPBERValue.h"
#include "nsISimpleEnumerator.h"
#include "nsServiceManagerUtils.h"
+#include "nsComponentManagerUtils.h"
using namespace mozilla;
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPModification, nsILDAPModification)
// constructor
//
nsLDAPModification::nsLDAPModification()
--- a/ldap/xpcom/src/nsLDAPModification.h
+++ b/ldap/xpcom/src/nsLDAPModification.h
@@ -36,17 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsLDAPModification_h_
#define _nsLDAPModification_h_
#include "nsILDAPModification.h"
#include "nsIMutableArray.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsCOMPtr.h"
#include "mozilla/Mutex.h"
// 5b0f4d00-062e-11d6-a7f2-fc943c3c039c
//
#define NS_LDAPMODIFICATION_CID \
{ 0x5b0f4d00, 0x062e, 0x11d6, \
{ 0xa7, 0xf2, 0xfc, 0x94, 0x3c, 0x3c, 0x03, 0x9c }}
--- a/ldap/xpcom/src/nsLDAPOperation.cpp
+++ b/ldap/xpcom/src/nsLDAPOperation.cpp
@@ -39,24 +39,24 @@
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPInternal.h"
#include "nsLDAPOperation.h"
#include "nsLDAPBERValue.h"
#include "nsILDAPMessage.h"
#include "nsILDAPModification.h"
#include "nsIComponentManager.h"
-#include "nsReadableUtils.h"
#include "nspr.h"
#include "nsISimpleEnumerator.h"
#include "nsLDAPControl.h"
#include "nsILDAPErrors.h"
#include "nsIClassInfoImpl.h"
#include "nsIAuthModule.h"
#include "nsArrayUtils.h"
+#include "nsMemory.h"
// Helper function
static nsresult TranslateLDAPErrorToNSError(const int ldapError)
{
switch (ldapError) {
case LDAP_SUCCESS:
return NS_OK;
--- a/ldap/xpcom/src/nsLDAPOperation.h
+++ b/ldap/xpcom/src/nsLDAPOperation.h
@@ -41,17 +41,17 @@
#ifndef _nsLDAPOperation_h_
#define _nsLDAPOperation_h_
#include "ldap.h"
#include "nsCOMPtr.h"
#include "nsILDAPConnection.h"
#include "nsILDAPOperation.h"
#include "nsILDAPMessageListener.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsIMutableArray.h"
#include "nsLDAPConnection.h"
// 97a479d0-9a44-47c6-a17a-87f9b00294bb
#define NS_LDAPOPERATION_CID \
{ 0x97a479d0, 0x9a44, 0x47c6, \
{ 0xa1, 0x7a, 0x87, 0xf9, 0xb0, 0x02, 0x94, 0xbb}}
--- a/ldap/xpcom/src/nsLDAPSecurityGlue.cpp
+++ b/ldap/xpcom/src/nsLDAPSecurityGlue.cpp
@@ -49,16 +49,18 @@
#include "nsIInterfaceRequestor.h"
#include "nsNetCID.h"
#include "nsISocketProvider.h"
#include "nsISSLSocketControl.h"
#include "nsMemory.h"
#include "plstr.h"
#include "ldap.h"
#include "ldappr.h"
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
// LDAP per-session data structure.
//
typedef struct {
char *hostname;
LDAP_X_EXTIOF_CLOSE_CALLBACK *realClose;
LDAP_X_EXTIOF_CONNECT_CALLBACK *realConnect;
LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *realDisposeHandle;
--- a/ldap/xpcom/src/nsLDAPServer.cpp
+++ b/ldap/xpcom/src/nsLDAPServer.cpp
@@ -34,17 +34,16 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPServer.h"
-#include "nsReadableUtils.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPServer, nsILDAPServer)
nsLDAPServer::nsLDAPServer()
: mSizeLimit(0),
mProtocolVersion(nsILDAPConnection::VERSION3)
{
}
--- a/ldap/xpcom/src/nsLDAPServer.h
+++ b/ldap/xpcom/src/nsLDAPServer.h
@@ -33,17 +33,17 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsILDAPServer.h"
#include "nsILDAPURL.h"
// 8bbbaa54-f316-4271-87c3-d52b5b1c1f5b
#define NS_LDAPSERVER_CID \
{ 0x8bbbaa54, 0xf316, 0x4271, \
{ 0x87, 0xc3, 0xd5, 0x2b, 0x5b, 0x1c, 0x1f, 0x5b}}
--- a/ldap/xpcom/src/nsLDAPService.cpp
+++ b/ldap/xpcom/src/nsLDAPService.cpp
@@ -37,23 +37,23 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPInternal.h"
#include "nsLDAPService.h"
#include "nsLDAPConnection.h"
#include "nsLDAPOperation.h"
-#include "nsXPIDLString.h"
-#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsIConsoleService.h"
#include "nsILDAPURL.h"
#include "nsCRT.h"
#include "nsILDAPErrors.h"
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
using namespace mozilla;
// Constants for CIDs used here.
//
static NS_DEFINE_CID(kLDAPConnectionCID, NS_LDAPCONNECTION_CID);
static NS_DEFINE_CID(kLDAPOperationCID, NS_LDAPOPERATION_CID);
@@ -67,22 +67,16 @@ nsLDAPServiceEntry::nsLDAPServiceEntry()
: mLeases(0),
mDelete(PR_FALSE),
mRebinding(PR_FALSE)
{
mTimestamp = LL_Zero();
}
-// destructor
-//
-nsLDAPServiceEntry::~nsLDAPServiceEntry()
-{
-}
-
// Init function
//
bool nsLDAPServiceEntry::Init()
{
return PR_TRUE;
}
// Set/Get the timestamp when this server was last used. We might have
@@ -223,65 +217,48 @@ bool nsLDAPServiceEntry::DeleteEntry()
NS_IMPL_THREADSAFE_ISUPPORTS2(nsLDAPService,
nsILDAPService,
nsILDAPMessageListener)
// constructor
//
nsLDAPService::nsLDAPService()
- : mLock("nsLDAPService.mLock"),
- mServers(0),
- mConnections(0)
+ : mLock("nsLDAPService.mLock")
{
}
// destructor
//
nsLDAPService::~nsLDAPService()
{
- // Delete the hash table holding the entries
- if (mServers) {
- delete mServers;
- }
-
- // Delete the hash holding the "reverse" lookups from conn to server
- if (mConnections) {
- delete mConnections;
- }
}
// Initializer, create some internal hash tables etc.
//
nsresult nsLDAPService::Init()
{
- if (!mServers) {
- mServers = new nsHashtable(16, PR_FALSE);
- if (!mServers) {
- NS_ERROR("nsLDAPService::Init: out of memory ");
- return NS_ERROR_OUT_OF_MEMORY;
- }
+ if (!mServers.Init()) {
+ NS_ERROR("nsLDAPService::Init: out of memory ");
+ return NS_ERROR_OUT_OF_MEMORY;
}
- if (!mConnections) {
- mConnections = new nsHashtable(16, PR_FALSE);
- if (!mConnections) {
- NS_ERROR("nsLDAPService::Init: out of memory ");
- return NS_ERROR_OUT_OF_MEMORY;
- }
+ if (!mConnections.Init()) {
+ NS_ERROR("nsLDAPService::Init: out of memory ");
+ return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
// void addServer (in nsILDAPServer aServer);
NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
{
nsLDAPServiceEntry *entry;
- nsXPIDLString key;
+ nsString key;
nsresult rv;
if (!aServer) {
NS_ERROR("nsLDAPService::AddServer: null pointer ");
return NS_ERROR_NULL_POINTER;
}
// Set up the hash key for the server entry
@@ -318,45 +295,43 @@ NS_IMETHODIMP nsLDAPService::AddServer(n
return NS_ERROR_FAILURE;
}
// We increment the refcount here for the server entry, when
// we purge a server completely from the service (TBD), we
// need to decrement the counter as well.
//
{
- nsStringKey hashKey(key);
MutexAutoLock lock(mLock);
- if (mServers->Exists(&hashKey)) {
+ if (mServers.Get(key)) {
// Collision detected, lets just throw away this service entry
// and keep the old one.
//
delete entry;
return NS_ERROR_FAILURE;
}
- mServers->Put(&hashKey, entry);
+ mServers.Put(key, entry);
}
NS_ADDREF(aServer);
return NS_OK;
}
// void deleteServer (in wstring aKey);
NS_IMETHODIMP nsLDAPService::DeleteServer(const PRUnichar *aKey)
{
nsLDAPServiceEntry *entry;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
// We should probably rename the key for this entry now that it's
// "deleted", so that we can add in a new one with the same ID.
// This is bug #77669.
//
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
+ mServers.Get(nsDependentString(aKey), &entry);
if (entry) {
if (entry->GetLeases() > 0) {
return NS_ERROR_FAILURE;
}
entry->DeleteEntry();
} else {
// There is no Server entry for this key
//
@@ -366,26 +341,24 @@ NS_IMETHODIMP nsLDAPService::DeleteServe
return NS_OK;
}
// nsILDAPServer getServer (in wstring aKey);
NS_IMETHODIMP nsLDAPService::GetServer(const PRUnichar *aKey,
nsILDAPServer **_retval)
{
nsLDAPServiceEntry *entry;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
if (!_retval) {
NS_ERROR("nsLDAPService::GetServer: null pointer ");
return NS_ERROR_NULL_POINTER;
}
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry) {
+ if (!mServers.Get(nsDependentString(aKey), &entry)) {
*_retval = 0;
return NS_ERROR_FAILURE;
}
if (!(*_retval = entry->GetServer().get())) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@@ -395,30 +368,28 @@ NS_IMETHODIMP nsLDAPService::GetServer(c
// in nsILDAPMessageListener aMessageListener);
NS_IMETHODIMP nsLDAPService::RequestConnection(const PRUnichar *aKey,
nsILDAPMessageListener *aListener)
{
nsLDAPServiceEntry *entry;
nsCOMPtr<nsILDAPConnection> conn;
nsCOMPtr<nsILDAPMessage> message;
nsresult rv;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
if (!aListener) {
NS_ERROR("nsLDAPService::RequestConection: null pointer ");
return NS_ERROR_NULL_POINTER;
}
// Try to find a possibly cached connection and LDAP message.
//
{
MutexAutoLock lock(mLock);
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry) {
+ if (!mServers.Get(nsDependentString(aKey), &entry)) {
return NS_ERROR_FAILURE;
}
entry->SetTimestamp();
conn = entry->GetConnection();
message = entry->GetMessage();
}
@@ -440,63 +411,58 @@ NS_IMETHODIMP nsLDAPService::RequestConn
}
// We got a new connection, now push the listeners on our stack,
// until we get the LDAP message back.
//
{
MutexAutoLock lock(mLock);
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry ||
+ if (!mServers.Get(nsDependentString(aKey), &entry) ||
!entry->PushListener(static_cast<nsILDAPMessageListener *>
(aListener))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
// nsILDAPConnection getConnection (in wstring aKey);
NS_IMETHODIMP nsLDAPService::GetConnection(const PRUnichar *aKey,
nsILDAPConnection **_retval)
{
nsLDAPServiceEntry *entry;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
if (!_retval) {
NS_ERROR("nsLDAPService::GetConnection: null pointer ");
return NS_ERROR_NULL_POINTER;
}
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry) {
+ if (!mServers.Get(nsDependentString(aKey), &entry)) {
*_retval = 0;
return NS_ERROR_FAILURE;
}
entry->SetTimestamp();
entry->IncrementLeases();
if (!(*_retval = entry->GetConnection().get())){
return NS_ERROR_FAILURE;
}
return NS_OK;
}
// void releaseConnection (in wstring aKey);
NS_IMETHODIMP nsLDAPService::ReleaseConnection(const PRUnichar *aKey)
{
nsLDAPServiceEntry *entry;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry) {
+ if (!mServers.Get(nsDependentString(aKey), &entry)) {
return NS_ERROR_FAILURE;
}
if (entry->GetLeases() > 0) {
entry->SetTimestamp();
entry->DecrementLeases();
} else {
// Releasing a non-leased connection is currently a No-Op.
@@ -508,28 +474,26 @@ NS_IMETHODIMP nsLDAPService::ReleaseConn
// void reconnectConnection (in wstring aKey,
// in nsILDAPMessageListener aMessageListener);
NS_IMETHODIMP nsLDAPService::ReconnectConnection(const PRUnichar *aKey,
nsILDAPMessageListener *aListener)
{
nsLDAPServiceEntry *entry;
nsresult rv;
- nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
if (!aListener) {
NS_ERROR("nsLDAPService::ReconnectConnection: null pointer ");
return NS_ERROR_NULL_POINTER;
}
{
MutexAutoLock lock(mLock);
- entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
- if (!entry) {
+ if (!mServers.Get(nsDependentString(aKey), &entry)) {
return NS_ERROR_FAILURE;
}
entry->SetTimestamp();
if (entry->IsRebinding()) {
if (!entry->PushListener(aListener)) {
return NS_ERROR_FAILURE;
}
@@ -616,23 +580,19 @@ nsLDAPService::OnLDAPMessage(nsILDAPMess
// Now we have the connection, lets find the corresponding
// server entry in the Service.
//
{
nsCOMPtr<nsILDAPMessageListener> listener;
nsCOMPtr<nsILDAPMessage> message;
nsLDAPServiceEntry *entry;
- nsVoidKey connKey(static_cast<nsILDAPConnection *>
- (connection));
MutexAutoLock lock(mLock);
- entry = static_cast<nsLDAPServiceEntry *>
- (mConnections->Get(&connKey));
- if (!entry) {
+ if (!mConnections.Get(connection, &entry)) {
return NS_ERROR_FAILURE;
}
message = entry->GetMessage();
if (message) {
// We already have a message, lets keep that one.
//
return NS_ERROR_FAILURE;
@@ -787,21 +747,20 @@ nsLDAPService::EstablishConnection(nsLDA
return NS_OK;
}
// We made the connection, lets store it to the server entry,
// and also update the reverse lookup tables (for finding the
// server entry related to a particular connection).
//
{
- nsVoidKey connKey(static_cast<nsILDAPConnection *>(conn));
MutexAutoLock lock(mLock);
aEntry->SetConnection(conn);
- mConnections->Put(&connKey, aEntry);
+ mConnections.Put(conn, aEntry);
}
// Setup the bind() operation.
//
operation = do_CreateInstance(kLDAPOperationCID, &rv);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
@@ -841,38 +800,34 @@ NS_IMETHODIMP nsLDAPService::CreateFilte
const nsACString & aAttr,
const nsACString & aValue,
nsACString & _retval)
{
if (!aMaxSize) {
return NS_ERROR_INVALID_ARG;
}
- // prepare to tokenize |value| for %vM ... %vN
- //
- nsReadingIterator<char> iter, iterEnd; // setup the iterators
- aValue.BeginReading(iter);
- aValue.EndReading(iterEnd);
-
// figure out how big of an array we're going to need for the tokens,
// including a trailing NULL, and allocate space for it.
//
+ const char *iter = aValue.BeginReading();
+ const char *iterEnd = aValue.EndReading();
PRUint32 numTokens = CountTokens(iter, iterEnd);
char **valueWords;
valueWords = static_cast<char **>(nsMemory::Alloc((numTokens + 1) *
sizeof(char *)));
if (!valueWords) {
return NS_ERROR_OUT_OF_MEMORY;
}
// build the array of values
//
PRUint32 curToken = 0;
while (iter != iterEnd && curToken < numTokens ) {
- valueWords[curToken] = NextToken(iter, iterEnd);
+ valueWords[curToken] = NextToken(&iter, &iterEnd);
if ( !valueWords[curToken] ) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(curToken, valueWords);
return NS_ERROR_OUT_OF_MEMORY;
}
curToken++;
}
valueWords[numTokens] = 0; // end of array signal to LDAP C SDK
@@ -1020,37 +975,37 @@ NS_IMETHODIMP nsLDAPService::ParseDn(con
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
return NS_OK;
}
// Count the number of space-separated tokens between aIter and aIterEnd
//
PRUint32
-nsLDAPService::CountTokens(nsReadingIterator<char> aIter,
- nsReadingIterator<char> aIterEnd)
+nsLDAPService::CountTokens(const char *aIter,
+ const char *aIterEnd)
{
PRUint32 count(0);
// keep iterating through the string until we hit the end
//
while (aIter != aIterEnd) {
// move past any leading spaces
//
while (aIter != aIterEnd &&
- ldap_utf8isspace(const_cast<char *>(aIter.get()))){
+ ldap_utf8isspace(const_cast<char *>(aIter))){
++aIter;
}
// move past all chars in this token
//
while (aIter != aIterEnd) {
- if (ldap_utf8isspace(const_cast<char *>(aIter.get()))) {
+ if (ldap_utf8isspace(const_cast<char *>(aIter))) {
++count; // token finished; increment the count
++aIter; // move past the space
break;
}
++aIter; // move to next char
// if we've hit the end of this token and the end of this
@@ -1065,29 +1020,29 @@ nsLDAPService::CountTokens(nsReadingIter
}
return count;
}
// return the next token in this iterator
//
char*
-nsLDAPService::NextToken(nsReadingIterator<char> & aIter,
- nsReadingIterator<char> & aIterEnd)
+nsLDAPService::NextToken(const char **aIter,
+ const char **aIterEnd)
{
// move past any leading whitespace
//
- while (aIter != aIterEnd &&
- ldap_utf8isspace(const_cast<char *>(aIter.get()))) {
- ++aIter;
+ while (*aIter != *aIterEnd &&
+ ldap_utf8isspace(const_cast<char *>(*aIter))) {
+ ++(*aIter);
}
- nsACString::const_iterator start(aIter);
+ const char *start = *aIter;
// copy the token into our local variable
//
- while (aIter != aIterEnd &&
- !ldap_utf8isspace(const_cast<char *>(aIter.get()))) {
- ++aIter;
+ while (*aIter != *aIterEnd &&
+ !ldap_utf8isspace(const_cast<char *>(*aIter))) {
+ ++(*aIter);
}
- return ToNewCString(Substring(start, aIter));
+ return ToNewCString(Substring(start, *aIter));
}
--- a/ldap/xpcom/src/nsLDAPService.h
+++ b/ldap/xpcom/src/nsLDAPService.h
@@ -33,19 +33,19 @@
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "ldap.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsCOMArray.h"
-#include "nsHashtable.h"
+#include "nsDataHashtable.h"
#include "nsILDAPService.h"
#include "nsILDAPMessage.h"
#include "nsILDAPMessageListener.h"
#include "nsCOMPtr.h"
#include "nsILDAPServer.h"
#include "nsILDAPConnection.h"
#include "nsILDAPMessage.h"
#include "mozilla/Mutex.h"
@@ -60,17 +60,17 @@
// This is a little "helper" class, we use to store information
// related to one Service entry (one LDAP server).
//
class nsLDAPServiceEntry
{
public:
nsLDAPServiceEntry();
- virtual ~nsLDAPServiceEntry();
+ virtual ~nsLDAPServiceEntry() {};
bool Init();
inline PRUint32 GetLeases();
inline void IncrementLeases();
inline bool DecrementLeases();
inline PRTime GetTimestamp();
inline void SetTimestamp();
@@ -126,24 +126,24 @@ class nsLDAPService : public nsILDAPServ
protected:
nsresult EstablishConnection(nsLDAPServiceEntry *,
nsILDAPMessageListener *);
// kinda like strtok_r, but with iterators. for use by
// createFilter
//
- char *NextToken(nsReadingIterator<char> & aIter,
- nsReadingIterator<char> & aIterEnd);
+ char *NextToken(const char **aIter, const char **aIterEnd);
// count how many tokens are in this string; for use by
// createFilter; note that unlike with NextToken, these params
// are copies, not references.
//
- PRUint32 CountTokens(nsReadingIterator<char> aIter,
- nsReadingIterator<char> aIterEnd);
+ PRUint32 CountTokens(const char * aIter, const char * aIterEnd);
mozilla::Mutex mLock; // Lock mechanism
- nsHashtable *mServers; // Hash table holding server entries
- nsHashtable *mConnections; // Hash table holding "reverse"
- // lookups from connection to server
+
+ // Hash table holding server entries
+ nsDataHashtable<nsStringHashKey, nsLDAPServiceEntry*> mServers;
+ // Hash table holding "reverse" lookups from connection to server
+ nsDataHashtable<nsVoidPtrHashKey, nsLDAPServiceEntry*> mConnections;
};
--- a/ldap/xpcom/src/nsLDAPSyncQuery.cpp
+++ b/ldap/xpcom/src/nsLDAPSyncQuery.cpp
@@ -34,21 +34,22 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPSyncQuery.h"
#include "nsIServiceManager.h"
-#include "nsXPIDLString.h"
#include "nsILDAPErrors.h"
#include "nsThreadUtils.h"
-#include "nsReadableUtils.h"
#include "nsILDAPMessage.h"
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
+#include "nsMemory.h"
// nsISupports Implementation
NS_IMPL_THREADSAFE_ISUPPORTS2(nsLDAPSyncQuery, nsILDAPSyncQuery, nsILDAPMessageListener)
// Constructor
//
nsLDAPSyncQuery::nsLDAPSyncQuery() :
--- a/ldap/xpcom/src/nsLDAPSyncQuery.h
+++ b/ldap/xpcom/src/nsLDAPSyncQuery.h
@@ -37,17 +37,17 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsILDAPConnection.h"
#include "nsILDAPOperation.h"
#include "nsILDAPMessageListener.h"
#include "nsILDAPURL.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
#include "nsILDAPSyncQuery.h"
// DDDEE14E-ED81-4182-9323-C2AB22FBA68E
#define NS_LDAPSYNCQUERY_CID \
{ 0xdddee14e, 0xed81, 0x4182, \
{ 0x93, 0x23, 0xc2, 0xab, 0x22, 0xfb, 0xa6, 0x8e }}
--- a/ldap/xpcom/src/nsLDAPURL.cpp
+++ b/ldap/xpcom/src/nsLDAPURL.cpp
@@ -192,17 +192,17 @@ nsLDAPURL::SetSpec(const nsACString &aSp
// need to reset ourselves.
nsCString originalSpec;
nsresult rv = mBaseURL->GetSpec(originalSpec);
NS_ENSURE_SUCCESS(rv, rv);
rv = mBaseURL->SetSpec(aSpec);
NS_ENSURE_SUCCESS(rv, rv);
- rv = SetPathInternal(nsPromiseFlatCString(aSpec));
+ rv = SetPathInternal(PromiseFlatCString(aSpec));
if (NS_FAILED(rv))
mBaseURL->SetSpec(originalSpec);
return rv;
}
NS_IMETHODIMP nsLDAPURL::GetPrePath(nsACString &_retval)
{
@@ -337,17 +337,17 @@ NS_IMETHODIMP nsLDAPURL::GetPath(nsACStr
return mBaseURL->GetPath(_retval);
}
NS_IMETHODIMP nsLDAPURL::SetPath(const nsACString &aPath)
{
if (!mBaseURL)
return NS_ERROR_NOT_INITIALIZED;
- nsresult rv = SetPathInternal(nsPromiseFlatCString(aPath));
+ nsresult rv = SetPathInternal(PromiseFlatCString(aPath));
NS_ENSURE_SUCCESS(rv, rv);
return mBaseURL->SetPath(aPath);
}
NS_IMETHODIMP nsLDAPURL::GetAsciiSpec(nsACString &_retval)
{
if (!mBaseURL)
@@ -543,17 +543,17 @@ NS_IMETHODIMP nsLDAPURL::AddAttribute(co
{
mAttributes = ',';
mAttributes.Append(aAttribute);
mAttributes.Append(',');
}
else
{
// Wrap the attribute in commas, so that we can do an exact match.
- nsCAutoString findAttribute(',');
+ nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');
// Check to see if the attribute is already stored. If it is, then also
// check to see if it is the last attribute in the string, or if the next
// character is a comma, this means we won't match substrings.
PRInt32 pos = mAttributes.Find(findAttribute, CaseInsensitiveCompare);
if (pos != -1)
@@ -573,17 +573,17 @@ NS_IMETHODIMP nsLDAPURL::AddAttribute(co
NS_IMETHODIMP nsLDAPURL::RemoveAttribute(const nsACString &aAttribute)
{
if (!mBaseURL)
return NS_ERROR_NOT_INITIALIZED;
if (mAttributes.IsEmpty())
return NS_OK;
- nsCAutoString findAttribute(',');
+ nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');
if (mAttributes.Equals(findAttribute, nsCaseInsensitiveCStringComparator()))
mAttributes.Truncate();
else
{
PRInt32 pos = mAttributes.Find(findAttribute, CaseInsensitiveCompare);
@@ -601,17 +601,17 @@ NS_IMETHODIMP nsLDAPURL::RemoveAttribute
return mBaseURL->SetPath(newPath);
}
NS_IMETHODIMP nsLDAPURL::HasAttribute(const nsACString &aAttribute,
bool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
- nsCAutoString findAttribute(',');
+ nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');
*_retval = mAttributes.Find(findAttribute, CaseInsensitiveCompare) != -1;
return NS_OK;
}
NS_IMETHODIMP nsLDAPURL::GetScope(PRInt32 *_retval)
new file mode 100644
--- /dev/null
+++ b/ldap/xpcom/src/nsLDAPUtils.h
@@ -0,0 +1,181 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jan Horak <jhorak@redhat.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* This module contains helper functions and macros for converting directory
+ module to frozen linkage.
+ */
+#include "nsIProxyObjectManager.h"
+#include "nsServiceManagerUtils.h"
+#include "nsStringGlue.h"
+#include <ctype.h>
+
+#ifdef MOZILLA_INTERNAL_API
+/* Internal API helper macros */
+
+#define LdapCompressWhitespace(str) \
+ (str).CompressWhitespace()
+
+#else // MOZILLA_INTERNAL_API
+/* Frozen linkage helper functions */
+
+/* This macro has been copied from msgcore.h */
+#define IS_SPACE(VAL) \
+ (((((intn)(VAL)) & 0x7f) == ((intn)(VAL))) && isspace((intn)(VAL)))
+
+/* This function has been copied from nsMsgUtils.cpp */
+inline void LdapCompressWhitespace(nsCString& aString)
+{
+ // This code is frozen linkage specific
+ aString.Trim(" \f\n\r\t\v");
+
+ char *start, *end;
+ aString.BeginWriting(&start, &end);
+
+ for (char *cur = start; cur < end; ++cur) {
+ if (!IS_SPACE(*cur))
+ continue;
+
+ *cur = ' ';
+
+ if (!IS_SPACE(*(cur + 1)))
+ continue;
+
+ // Loop through the white space
+ char *wend = cur + 2;
+ while (IS_SPACE(*wend))
+ ++wend;
+
+ PRUint32 wlen = wend - cur - 1;
+
+ // fix "end"
+ end -= wlen;
+
+ // move everything forwards a bit
+ for (char *m = cur + 1; m < end; ++m) {
+ *m = *(m + wlen);
+ }
+ }
+
+ // Set the new length.
+ aString.SetLength(end - start);
+}
+
+/*
+ * Function copied from nsReadableUtils.
+ * Migrating to frozen linkage is the only change done
+ */
+inline
+bool IsUTF8(const nsACString& aString)
+{
+ const char *done_reading = aString.EndReading();
+
+ PRInt32 state = 0;
+ bool overlong = false;
+ bool surrogate = false;
+ bool nonchar = false;
+ PRUint16 olupper = 0; // overlong byte upper bound.
+ PRUint16 slower = 0; // surrogate byte lower bound.
+
+ const char *ptr = aString.BeginReading();
+
+ while (ptr < done_reading) {
+ PRUint8 c;
+
+ if (0 == state) {
+
+ c = *ptr++;
+
+ if ((c & 0x80) == 0x00)
+ continue;
+
+ if ( c <= 0xC1 ) // [80-BF] where not expected, [C0-C1] for overlong.
+ return PR_FALSE;
+ else if ((c & 0xE0) == 0xC0)
+ state = 1;
+ else if ((c & 0xF0) == 0xE0) {
+ state = 2;
+ if ( c == 0xE0 ) { // to exclude E0[80-9F][80-BF]
+ overlong = PR_TRUE;
+ olupper = 0x9F;
+ } else if ( c == 0xED ) { // ED[A0-BF][80-BF] : surrogate codepoint
+ surrogate = PR_TRUE;
+ slower = 0xA0;
+ } else if ( c == 0xEF ) // EF BF [BE-BF] : non-character
+ nonchar = PR_TRUE;
+ } else if ( c <= 0xF4 ) { // XXX replace /w UTF8traits::is4byte when it's updated to exclude [F5-F7].(bug 199090)
+ state = 3;
+ nonchar = PR_TRUE;
+ if ( c == 0xF0 ) { // to exclude F0[80-8F][80-BF]{2}
+ overlong = PR_TRUE;
+ olupper = 0x8F;
+ }
+ else if ( c == 0xF4 ) { // to exclude F4[90-BF][80-BF]
+ // actually not surrogates but codepoints beyond 0x10FFFF
+ surrogate = PR_TRUE;
+ slower = 0x90;
+ }
+ } else
+ return PR_FALSE; // Not UTF-8 string
+ }
+
+ while (ptr < done_reading && state) {
+ c = *ptr++;
+ --state;
+
+ // non-character : EF BF [BE-BF] or F[0-7] [89AB]F BF [BE-BF]
+ if ( nonchar && ( !state && c < 0xBE ||
+ state == 1 && c != 0xBF ||
+ state == 2 && 0x0F != (0x0F & c) ))
+ nonchar = PR_FALSE;
+
+ if ((c & 0xC0) != 0x80 || overlong && c <= olupper ||
+ surrogate && slower <= c || nonchar && !state )
+ return PR_FALSE; // Not UTF-8 string
+ overlong = surrogate = PR_FALSE;
+ }
+ }
+ return !state; // state != 0 at the end indicates an invalid UTF-8 seq.
+}
+
+#define kNotFound -1
+
+#define nsCaseInsensitiveCStringComparator() \
+ CaseInsensitiveCompare
+#define nsCaseInsensitiveStringComparator() \
+ CaseInsensitiveCompare
+
+#endif // MOZILLA_INTERNAL_API