Commit 2f084272 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Use cmakedefine01

This way we get a build time warning if the var isn't defined at all, e.g.
a missing check_include_files() CMake call.

Remove unused var, HAVE_LDAP_H.
parent 58c9601e
......@@ -13,7 +13,6 @@ if(Ldap_FOUND)
if(WIN32)
set(kldap_EXTRA_LIBS ${kldap_EXTRA_LIBS} ws2_32)
endif()
set(HAVE_LDAP_H)
set(CMAKE_REQUIRED_INCLUDES lber.h ldap.h)
set(CMAKE_REQUIRED_LIBRARIES Ldap::Ldap)
check_function_exists(ldap_start_tls_s HAVE_LDAP_START_TLS_S)
......
......@@ -15,13 +15,13 @@
#include <cstdarg>
#ifdef LDAP_FOUND
#if LDAP_FOUND
#ifdef Q_OS_SOLARIS // krazy:exclude=cpp
#define BC31 1
#endif
#ifndef HAVE_WINLDAP_H
#if !HAVE_WINLDAP_H
#include <lber.h>
#include <ldap.h>
#else
......@@ -32,8 +32,8 @@
#define LBER_USE_DER 1
#endif
#ifndef HAVE_BER_MEMFREE
#ifndef HAVE_WINLDAP_H
#if !HAVE_BER_MEMFREE
#if !HAVE_WINLDAP_H
#define ber_memfree(x) ldap_memfree(x)
#else
#define ber_memfree(x) win_ldap_memfree(x)
......@@ -47,12 +47,12 @@ using namespace KLDAP;
class Q_DECL_HIDDEN Ber::BerPrivate
{
public:
#ifdef LDAP_FOUND
#if LDAP_FOUND
BerElement *mBer = nullptr;
#endif
};
#ifdef LDAP_FOUND
#if LDAP_FOUND
Ber::Ber()
: d(new BerPrivate)
{
......
......@@ -25,8 +25,8 @@ static const sasl_callback_t callbacks[] = {{SASL_CB_ECHOPROMPT, nullptr, nullpt
static bool ldapoperation_sasl_initialized = false;
#ifdef LDAP_FOUND
#ifndef HAVE_WINLDAP_H
#if LDAP_FOUND
#if !HAVE_WINLDAP_H
#include <lber.h>
#include <ldap.h>
#else
......@@ -48,7 +48,7 @@ public:
LdapServer mServer;
QString mConnectionError;
#ifdef LDAP_FOUND
#if LDAP_FOUND
LDAP *mLDAP;
#else
void *mLDAP;
......@@ -118,7 +118,7 @@ void *LdapConnection::saslHandle() const
QString LdapConnection::errorString(int code)
{
// No translated error messages yet
#ifdef LDAP_FOUND
#if LDAP_FOUND
return QString::fromUtf8(ldap_err2string(code));
#else
return i18n("No LDAP Support...");
......@@ -137,7 +137,7 @@ QString LdapConnection::connectionError() const
return d->mConnectionError;
}
#ifdef LDAP_FOUND
#if LDAP_FOUND
int LdapConnection::getOption(int option, void *value) const
{
Q_ASSERT(d->mLDAP);
......@@ -225,7 +225,7 @@ int LdapConnection::connect()
url += QLatin1Char(':');
url += QString::number(d->mServer.port());
qCDebug(LDAP_LOG) << "ldap url:" << url;
#ifdef HAVE_LDAP_INITIALIZE
#if HAVE_LDAP_INITIALIZE
ret = ldap_initialize(&d->mLDAP, url.toLatin1().constData());
#else
d->mLDAP = ldap_init(d->mServer.host().toLatin1().data(), d->mServer.port());
......@@ -314,7 +314,7 @@ int LdapConnection::connect()
if (d->mServer.security() == LdapServer::TLS) {
qCDebug(LDAP_LOG) << "start TLS";
#ifdef HAVE_LDAP_START_TLS_S
#if HAVE_LDAP_START_TLS_S
if ((ret = ldap_start_tls_s(d->mLDAP, nullptr, nullptr)) != LDAP_SUCCESS) {
d->mConnectionError = ldapErrorString();
close();
......@@ -360,7 +360,7 @@ int LdapConnection::connect()
void LdapConnection::close()
{
if (d->mLDAP) {
#ifdef HAVE_LDAP_UNBIND_EXT
#if HAVE_LDAP_UNBIND_EXT
ldap_unbind_ext(d->mLDAP, nullptr, nullptr);
#else
ldap_unbind(d->mLDAP);
......
......@@ -15,7 +15,7 @@
#include <cstdlib>
// for struct timeval
#if defined(HAVE_SYS_TIME_H)
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#elif defined(_WIN32)
#include <winsock2.h>
......@@ -23,8 +23,8 @@
#include <sasl/sasl.h>
#ifdef LDAP_FOUND
#ifndef HAVE_WINLDAP_H
#if LDAP_FOUND
#if !HAVE_WINLDAP_H
#include <lber.h>
#include <ldap.h>
#else
......@@ -36,7 +36,7 @@
using namespace KLDAP;
#ifdef LDAP_FOUND
#if LDAP_FOUND
static void extractControls(LdapControls &ctrls, LDAPControl **pctrls);
#endif // LDAP_FOUND
......@@ -59,7 +59,7 @@ class Q_DECL_HIDDEN LdapOperation::LdapOperationPrivate
public:
LdapOperationPrivate();
~LdapOperationPrivate();
#ifdef LDAP_FOUND
#if LDAP_FOUND
int processResult(int rescode, LDAPMessage *msg);
int bind(const QByteArray &creds, SASL_Callback_Proc *saslproc, void *data, bool async);
#endif
......@@ -156,7 +156,7 @@ LdapOperation::LdapOperationPrivate::LdapOperationPrivate() = default;
LdapOperation::LdapOperationPrivate::~LdapOperationPrivate() = default;
#ifdef LDAP_FOUND
#if LDAP_FOUND
static int kldap_sasl_interact(sasl_interact_t *interact, LdapOperation::SASL_Data *data)
{
......@@ -324,7 +324,7 @@ int LdapOperation::LdapOperationPrivate::bind(const QByteArray &creds, SASL_Call
if (async) {
qCDebug(LDAP_LOG) << "ldap_sasl_bind (simple)";
#ifndef HAVE_WINLDAP_H
#if !HAVE_WINLDAP_H
int msgid = 0;
ret = ldap_sasl_bind(ld, bindname.data(), nullptr, &ccred, nullptr, nullptr, &msgid);
if (ret == 0) {
......@@ -335,7 +335,7 @@ int LdapOperation::LdapOperationPrivate::bind(const QByteArray &creds, SASL_Call
#endif
} else {
qCDebug(LDAP_LOG) << "ldap_sasl_bind_s (simple)";
#ifndef HAVE_WINLDAP_H
#if !HAVE_WINLDAP_H
ret = ldap_sasl_bind_s(ld, bindname.data(), nullptr, &ccred, nullptr, nullptr, nullptr);
#else
ret = ldap_simple_bind_s(ld, bindname.data(), pass.data());
......@@ -410,7 +410,7 @@ int LdapOperation::LdapOperationPrivate::processResult(int rescode, LDAPMessage
}
case RES_BIND: {
struct berval *servercred = nullptr;
#ifndef HAVE_WINLDAP_H
#if !HAVE_WINLDAP_H
// FIXME: Error handling Winldap does not have ldap_parse_sasl_bind_result
retval = ldap_parse_sasl_bind_result(ld, msg, &servercred, 0);
#else
......
#cmakedefine LDAP_FOUND
#cmakedefine HAVE_WINLDAP_H
#cmakedefine HAVE_LDAP_H
#cmakedefine HAVE_SYS_TIME_H
#cmakedefine HAVE_LDAP_START_TLS_S
#cmakedefine HAVE_LDAP_INITIALIZE
#cmakedefine HAVE_BER_MEMFREE
#cmakedefine HAVE_LDAP_UNBIND_EXT
#cmakedefine HAVE_LDAP_EXTENDED_OPERATION
#cmakedefine HAVE_LDAP_EXTENDED_OPERATION_S
#cmakedefine HAVE_LDAP_EXTENDED_OPERATION_PROTOTYPE
#cmakedefine HAVE_LDAP_EXTENDED_OPERATION_S_PROTOTYPE
#cmakedefine01 LDAP_FOUND
#cmakedefine01 HAVE_WINLDAP_H
#cmakedefine01 HAVE_SYS_TIME_H
#cmakedefine01 HAVE_LDAP_START_TLS_S
#cmakedefine01 HAVE_LDAP_INITIALIZE
#cmakedefine01 HAVE_BER_MEMFREE
#cmakedefine01 HAVE_LDAP_UNBIND_EXT
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment