File indexing completed on 2024-05-12 05:17:12
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2008 Jarosław Staniek <staniek@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QCoreApplication> 0010 #include <QDir> 0011 #include <QFile> 0012 #include <stdio.h> 0013 0014 extern "C" { 0015 #include <sasl/sasl.h> 0016 } 0017 0018 inline bool initSASL() 0019 { 0020 #ifdef Q_OS_WIN // krazy:exclude=cpp 0021 for (const auto &path : QCoreApplication::libraryPaths()) { 0022 QDir dir(path); 0023 if (dir.exists(QStringLiteral("sasl2"))) { 0024 auto libInstallPath = QFile::encodeName(dir.absoluteFilePath(QStringLiteral("sasl2"))); 0025 if (sasl_set_path(SASL_PATH_TYPE_PLUGIN, libInstallPath.data()) != SASL_OK) { 0026 fprintf(stderr, "SASL path initialization failed!\n"); 0027 return false; 0028 } 0029 break; 0030 } 0031 } 0032 #endif 0033 0034 if (sasl_client_init(nullptr) != SASL_OK) { 0035 fprintf(stderr, "SASL library initialization failed!\n"); 0036 return false; 0037 } 0038 return true; 0039 }