Libksieve

sasl-common.h
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2008 Jarosław Staniek <staniek@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7// krazy:excludeall=null since used by SASL (C library)
8
9#pragma once
10
11#include <QDir>
12#include <QFile>
13#include <cstdio>
14
15#ifdef Q_OS_WIN
16#include <QCoreApplication>
17#endif
18
19extern "C" {
20#include <sasl/sasl.h>
21}
22
23inline bool initSASL()
24{
25#ifdef Q_OS_WIN // krazy:exclude=cpp
26 for (const auto &path : QCoreApplication::libraryPaths()) {
27 QDir dir(path);
28 if (dir.exists(QStringLiteral("sasl2"))) {
29 auto libInstallPath = QFile::encodeName(dir.absoluteFilePath(QStringLiteral("sasl2")));
30 if (sasl_set_path(SASL_PATH_TYPE_PLUGIN, libInstallPath.data()) != SASL_OK) {
31 fprintf(stderr, "SASL path initialization failed!\n");
32 return false;
33 }
34 break;
35 }
36 }
37#endif
38
39 if (sasl_client_init(nullptr) != SASL_OK) {
40 fprintf(stderr, "SASL library initialization failed!\n");
41 return false;
42 }
43 return true;
44}
KIOCORE_EXPORT QString dir(const QString &fileClass)
QStringList libraryPaths()
QByteArray encodeName(const QString &fileName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.