Bug 590494 Move ldap/xpcom/src to frozen linkage r=Neil

This commit is contained in:
Jan Horak 2011-11-25 14:03:49 +00:00
Родитель b11c6b5eec
Коммит ee5504f57e
21 изменённых файлов: 273 добавлений и 125 удалений

Просмотреть файл

@ -48,8 +48,14 @@ 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 \
@ -84,7 +90,13 @@ CPPSRCS += \
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)

Просмотреть файл

@ -38,7 +38,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPBERElement.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsCOMPtr.h"
#include "nsLDAPBERValue.h"

Просмотреть файл

@ -39,8 +39,7 @@
#include "nsLDAPBERValue.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsStringGlue.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPBERValue, nsILDAPBERValue)

Просмотреть файл

@ -45,8 +45,7 @@
#include "nsLDAPInternal.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsStringGlue.h"
#include "nsIComponentManager.h"
#include "nsLDAPConnection.h"
#include "nsLDAPMessage.h"
@ -63,6 +62,7 @@
#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";
@ -82,7 +82,7 @@ nsLDAPConnection::nsLDAPConnection()
nsLDAPConnection::~nsLDAPConnection()
{
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
if (obsServ)
obsServ->RemoveObserver(this, "profile-change-net-teardown");
Close();
@ -113,9 +113,10 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl, const nsACString &aBindName,
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);
@ -137,8 +138,6 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl, const nsACString &aBindName,
}
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);
@ -185,12 +184,12 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl, const nsACString &aBindName,
// 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));
@ -351,7 +350,7 @@ nsLDAPConnection::GetErrorString(PRUnichar **_retval)
// 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;
}

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsILDAPConnection.h"
#include "ldap.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsIThread.h"
#include "nsIRunnable.h"
#include "nsCOMPtr.h"

Просмотреть файл

@ -40,7 +40,7 @@
#include "nsILDAPControl.h"
#include "nsCOMPtr.h"
#include "nsILDAPBERValue.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "ldap.h"
// {5B608BBE-C0EA-4f74-B209-9CDCD79EC401}

Просмотреть файл

@ -43,11 +43,11 @@
#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)
@ -537,9 +537,9 @@ nsLDAPMessage::GetValues(const char *aAttr, PRUint32 *aCount,
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);

Просмотреть файл

@ -44,7 +44,6 @@
#include "nsILDAPMessage.h"
#include "nsILDAPOperation.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
// 76e061ad-a59f-43b6-b812-ee6e8e69423f
//

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsILDAPBERValue.h"
#include "nsISimpleEnumerator.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla;

Просмотреть файл

@ -41,7 +41,7 @@
#include "nsILDAPModification.h"
#include "nsIMutableArray.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsCOMPtr.h"
#include "mozilla/Mutex.h"

Просмотреть файл

@ -44,7 +44,6 @@
#include "nsILDAPMessage.h"
#include "nsILDAPModification.h"
#include "nsIComponentManager.h"
#include "nsReadableUtils.h"
#include "nspr.h"
#include "nsISimpleEnumerator.h"
#include "nsLDAPControl.h"
@ -52,6 +51,7 @@
#include "nsIClassInfoImpl.h"
#include "nsIAuthModule.h"
#include "nsArrayUtils.h"
#include "nsMemory.h"
// Helper function
static nsresult TranslateLDAPErrorToNSError(const int ldapError)

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsILDAPConnection.h"
#include "nsILDAPOperation.h"
#include "nsILDAPMessageListener.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsIMutableArray.h"
#include "nsLDAPConnection.h"

Просмотреть файл

@ -54,6 +54,8 @@
#include "plstr.h"
#include "ldap.h"
#include "ldappr.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
// LDAP per-session data structure.
//

Просмотреть файл

@ -39,7 +39,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsLDAPServer.h"
#include "nsReadableUtils.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPServer, nsILDAPServer)

Просмотреть файл

@ -38,7 +38,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsILDAPServer.h"
#include "nsILDAPURL.h"

Просмотреть файл

@ -42,13 +42,13 @@
#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;
@ -72,12 +72,6 @@ nsLDAPServiceEntry::nsLDAPServiceEntry()
mTimestamp = LL_Zero();
}
// destructor
//
nsLDAPServiceEntry::~nsLDAPServiceEntry()
{
}
// Init function
//
bool nsLDAPServiceEntry::Init()
@ -228,9 +222,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsLDAPService,
// constructor
//
nsLDAPService::nsLDAPService()
: mLock("nsLDAPService.mLock"),
mServers(0),
mConnections(0)
: mLock("nsLDAPService.mLock")
{
}
@ -238,35 +230,20 @@ nsLDAPService::nsLDAPService()
//
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;
@ -276,7 +253,7 @@ nsresult nsLDAPService::Init()
NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
{
nsLDAPServiceEntry *entry;
nsXPIDLString key;
nsString key;
nsresult rv;
if (!aServer) {
@ -323,17 +300,16 @@ NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
// 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);
@ -344,14 +320,13 @@ NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
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;
@ -371,7 +346,6 @@ NS_IMETHODIMP nsLDAPService::GetServer(const PRUnichar *aKey,
nsILDAPServer **_retval)
{
nsLDAPServiceEntry *entry;
nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
if (!_retval) {
@ -379,8 +353,7 @@ NS_IMETHODIMP nsLDAPService::GetServer(const PRUnichar *aKey,
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;
}
@ -400,7 +373,6 @@ NS_IMETHODIMP nsLDAPService::RequestConnection(const PRUnichar *aKey,
nsCOMPtr<nsILDAPConnection> conn;
nsCOMPtr<nsILDAPMessage> message;
nsresult rv;
nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
if (!aListener) {
NS_ERROR("nsLDAPService::RequestConection: null pointer ");
@ -412,8 +384,7 @@ NS_IMETHODIMP nsLDAPService::RequestConnection(const PRUnichar *aKey,
{
MutexAutoLock lock(mLock);
entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
if (!entry) {
if (!mServers.Get(nsDependentString(aKey), &entry)) {
return NS_ERROR_FAILURE;
}
entry->SetTimestamp();
@ -445,8 +416,7 @@ NS_IMETHODIMP nsLDAPService::RequestConnection(const PRUnichar *aKey,
{
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;
@ -461,7 +431,6 @@ NS_IMETHODIMP nsLDAPService::GetConnection(const PRUnichar *aKey,
nsILDAPConnection **_retval)
{
nsLDAPServiceEntry *entry;
nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
MutexAutoLock lock(mLock);
if (!_retval) {
@ -469,8 +438,7 @@ NS_IMETHODIMP nsLDAPService::GetConnection(const PRUnichar *aKey,
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;
}
@ -487,11 +455,9 @@ NS_IMETHODIMP nsLDAPService::GetConnection(const PRUnichar *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;
}
@ -513,7 +479,6 @@ NS_IMETHODIMP nsLDAPService::ReconnectConnection(const PRUnichar *aKey,
{
nsLDAPServiceEntry *entry;
nsresult rv;
nsStringKey hashKey(aKey, -1, nsStringKey::NEVER_OWN);
if (!aListener) {
NS_ERROR("nsLDAPService::ReconnectConnection: null pointer ");
@ -523,8 +488,7 @@ NS_IMETHODIMP nsLDAPService::ReconnectConnection(const PRUnichar *aKey,
{
MutexAutoLock lock(mLock);
entry = static_cast<nsLDAPServiceEntry *>(mServers->Get(&hashKey));
if (!entry) {
if (!mServers.Get(nsDependentString(aKey), &entry)) {
return NS_ERROR_FAILURE;
}
entry->SetTimestamp();
@ -621,13 +585,9 @@ nsLDAPService::OnLDAPMessage(nsILDAPMessage *aMessage)
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;
}
@ -792,11 +752,10 @@ nsLDAPService::EstablishConnection(nsLDAPServiceEntry *aEntry,
// 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.
@ -846,15 +805,11 @@ NS_IMETHODIMP nsLDAPService::CreateFilter(PRUint32 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) *
@ -867,7 +822,7 @@ NS_IMETHODIMP nsLDAPService::CreateFilter(PRUint32 aMaxSize,
//
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;
@ -1025,8 +980,8 @@ NS_IMETHODIMP nsLDAPService::ParseDn(const char *aDn,
// 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);
@ -1037,7 +992,7 @@ nsLDAPService::CountTokens(nsReadingIterator<char> aIter,
// move past any leading spaces
//
while (aIter != aIterEnd &&
ldap_utf8isspace(const_cast<char *>(aIter.get()))){
ldap_utf8isspace(const_cast<char *>(aIter))){
++aIter;
}
@ -1045,7 +1000,7 @@ nsLDAPService::CountTokens(nsReadingIterator<char> aIter,
//
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;
@ -1070,24 +1025,24 @@ nsLDAPService::CountTokens(nsReadingIterator<char> aIter,
// 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));
}

Просмотреть файл

@ -38,9 +38,9 @@
* ***** 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"
@ -65,7 +65,7 @@ class nsLDAPServiceEntry
{
public:
nsLDAPServiceEntry();
virtual ~nsLDAPServiceEntry();
virtual ~nsLDAPServiceEntry() {};
bool Init();
inline PRUint32 GetLeases();
@ -131,19 +131,19 @@ class nsLDAPService : public nsILDAPService, public 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;
};

Просмотреть файл

@ -39,11 +39,12 @@
#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

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsILDAPOperation.h"
#include "nsILDAPMessageListener.h"
#include "nsILDAPURL.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsILDAPSyncQuery.h"
// DDDEE14E-ED81-4182-9323-C2AB22FBA68E

Просмотреть файл

@ -197,7 +197,7 @@ nsLDAPURL::SetSpec(const nsACString &aSpec)
rv = mBaseURL->SetSpec(aSpec);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPathInternal(nsPromiseFlatCString(aSpec));
rv = SetPathInternal(PromiseFlatCString(aSpec));
if (NS_FAILED(rv))
mBaseURL->SetSpec(originalSpec);
@ -342,7 +342,7 @@ 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);
@ -548,7 +548,7 @@ NS_IMETHODIMP nsLDAPURL::AddAttribute(const nsACString &aAttribute)
else
{
// Wrap the attribute in commas, so that we can do an exact match.
nsCAutoString findAttribute(',');
nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');
@ -578,7 +578,7 @@ NS_IMETHODIMP nsLDAPURL::RemoveAttribute(const nsACString &aAttribute)
if (mAttributes.IsEmpty())
return NS_OK;
nsCAutoString findAttribute(',');
nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');
@ -606,7 +606,7 @@ NS_IMETHODIMP nsLDAPURL::HasAttribute(const nsACString &aAttribute,
{
NS_ENSURE_ARG_POINTER(_retval);
nsCAutoString findAttribute(',');
nsCAutoString findAttribute(",");
findAttribute.Append(aAttribute);
findAttribute.Append(',');

Просмотреть файл

@ -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