Libksieve

sasl-common.h
1 /* This file is part of the KDE project
2  SPDX-FileCopyrightText: 2008 JarosÅ‚aw Staniek <[email protected]>
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 <stdio.h>
14 
15 #ifdef Q_OS_WIN
16 #include <QCoreApplication>
17 #endif
18 
19 extern "C" {
20 #include <sasl/sasl.h>
21 }
22 
23 inline 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 }
45 
QStringList libraryPaths()
KIOFILEWIDGETS_EXPORT QString dir(const QString &fileClass)
QByteArray encodeName(const QString &fileName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.