aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-05-13 19:11:40 +0000
committerSaturneric <[email protected]>2021-05-13 19:11:40 +0000
commit738d1fefa058081cfc849b4900f837790adcba44 (patch)
treeeba5b6840cc7439d69ea3526f2a1e5e5b6e810f1
parentFile Structure Modified. (diff)
downloadGpgFrontend-738d1fefa058081cfc849b4900f837790adcba44.tar.gz
GpgFrontend-738d1fefa058081cfc849b4900f837790adcba44.zip
Support more Key Generating Algo.
Support GPG2 now. Change GPGME Key Generation API to newer one. Statically link GPGME into the program.
-rw-r--r--CMakeLists.txt24
-rw-r--r--include/gpg/GpgContext.h3
-rw-r--r--include/gpg/GpgGenKeyInfo.h23
-rw-r--r--include/ui/KeygenThread.h4
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/gpg/CMakeLists.txt8
-rw-r--r--src/gpg/GpgContext.cpp36
-rw-r--r--src/main.cpp2
-rw-r--r--src/ui/CMakeLists.txt3
-rw-r--r--src/ui/KeygenDialog.cpp59
-rw-r--r--src/ui/KeygenThread.cpp2
-rw-r--r--utils/gpgme/include/assuan.h709
-rw-r--r--utils/gpgme/include/gpg-error.h2005
-rw-r--r--utils/gpgme/include/gpgme.h2841
14 files changed, 5662 insertions, 63 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6df464f1..2fc0a975 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,22 +4,24 @@ project(gpg4usb VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-# set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC OM)
+set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Test REQUIRED)
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5PrintSupport REQUIRED)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5Test REQUIRED)
+find_package(Qt5 COMPONENTS Core Test Widgets PrintSupport Network REQUIRED)
-include_directories(include)
-include_directories(/usr/local/include)
-link_directories(/usr/local/lib)
+message("${Qt5Widgets_INCLUDE_DIRS}")
+
+include_directories(
+ include
+ ${CMAKE_SOURCE_DIR}/utils/gpgme/include
+)
+link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/)
+link_directories(/usr/local/lib/)
+link_directories(/lib/)
add_subdirectory(src)
diff --git a/include/gpg/GpgContext.h b/include/gpg/GpgContext.h
index d361c412..71c857ad 100644
--- a/include/gpg/GpgContext.h
+++ b/include/gpg/GpgContext.h
@@ -25,6 +25,7 @@
#include <GPG4USB.h>
#include "GpgConstants.h"
+#include "GpgGenKeyInfo.h"
class GpgKey {
@@ -98,7 +99,7 @@ namespace GpgME {
bool exportKeys(QStringList *uidList, QByteArray *outBuffer);
- void generateKey(QString *params);
+ void generateKey(GenKeyInfo *params);
GpgKeyList listKeys();
diff --git a/include/gpg/GpgGenKeyInfo.h b/include/gpg/GpgGenKeyInfo.h
new file mode 100644
index 00000000..397123d9
--- /dev/null
+++ b/include/gpg/GpgGenKeyInfo.h
@@ -0,0 +1,23 @@
+//
+// Created by eric on 2021/5/13.
+//
+
+#ifndef GPG4USB_GPGGENKEYINFO_H
+#define GPG4USB_GPGGENKEYINFO_H
+
+#include <QString>
+#include <QTime>
+
+struct GenKeyInfo {
+ bool isSubKey = false;
+ QString userid;
+ QString algo;
+ int keySize;
+ QDateTime expired;
+ bool nonExpired = false;
+ bool allowSigning = true;
+ bool allowEncryption = true;
+ QString passPhrase;
+};
+
+#endif //GPG4USB_GPGGENKEYINFO_H
diff --git a/include/ui/KeygenThread.h b/include/ui/KeygenThread.h
index c7406881..467d8338 100644
--- a/include/ui/KeygenThread.h
+++ b/include/ui/KeygenThread.h
@@ -34,14 +34,14 @@ class KeyGenThread : public QThread {
Q_OBJECT
public:
- KeyGenThread(QString keyGenParams, GpgME::GpgContext *ctx);
+ KeyGenThread(GenKeyInfo keyGenParams, GpgME::GpgContext *ctx);
signals:
void signalKeyGenerated();
private:
- QString keyGenParams;
+ GenKeyInfo keyGenParams;
GpgME::GpgContext *mCtx;
[[maybe_unused]] bool abort;
QMutex mutex;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d65c791a..ada40b82 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,8 @@ aux_source_directory(. BASE_SOURCE)
file(GLOB_RECURSE GPG4USB_HEADER_FILES RELACTIVE ../include/* *.h)
qt5_wrap_cpp(QT5_MOCS ${GPG4USB_HEADER_FILES} TARGET gpg4usb)
-add_executable(gpg4usb ${BASE_SOURCE} ../gpg4usb.qrc ${QT5_MOCS})
+add_executable(gpg4usb ${BASE_SOURCE} ../gpg4usb.qrc ${QT5_MOCS} ../include/gpg/GpgGenKeyInfo.h)
-target_link_libraries(gpg4usb qtui gpg Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) \ No newline at end of file
+target_link_libraries(gpg4usb
+ qtui gpg
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) \ No newline at end of file
diff --git a/src/gpg/CMakeLists.txt b/src/gpg/CMakeLists.txt
index 881cd7d4..7e3df7de 100644
--- a/src/gpg/CMakeLists.txt
+++ b/src/gpg/CMakeLists.txt
@@ -2,6 +2,10 @@ aux_source_directory(. GPG_SOURCE)
add_library(gpg STATIC ${GPG_SOURCE})
-target_link_libraries(gpg gpg-error gpgme)
+set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
-qt5_use_modules(gpg Network PrintSupport Widgets Test Core) \ No newline at end of file
+set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
+
+target_link_libraries(gpg
+ ${GPGME_LIB_DIR}/libgpgme.a ${GPGME_LIB_DIR}/libgpg-error.a ${GPGME_LIB_DIR}/libassuan.a
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) \ No newline at end of file
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index d0694638..a42861a6 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -56,8 +56,8 @@ namespace GpgME {
#endif
err = gpgme_new(&mCtx);
-
checkErr(err);
+
/** here come the qSettings, instead of /usr/bin/gpg
* a executable in the same path as app is used.
* also lin/win must be checked, for calling gpg.exe if needed
@@ -65,7 +65,7 @@ namespace GpgME {
#ifdef _WIN32
gpgBin = appPath + "/bin/gpg.exe";
#else
- gpgBin = appPath + "/bin/gpg";
+ gpgBin = "/usr/bin/gpg";
#endif
QSettings qSettings;
@@ -195,8 +195,33 @@ namespace GpgME {
/** Generate New Key with values params
*
*/
- void GpgContext::generateKey(QString *params) {
- err = gpgme_op_genkey(mCtx, params->toUtf8().data(), nullptr, nullptr);
+ void GpgContext::generateKey(GenKeyInfo *params) {
+ auto userid_utf8 = params->userid.toUtf8();
+ const char *userid = userid_utf8.constData();
+ auto algo_utf8 = (params->algo + QString::number(params->keySize)).toUtf8();
+ const char *algo = algo_utf8.constData();
+ unsigned long expires = params->expired.toTime_t();
+ unsigned int flags = 0;
+
+ if(!params->isSubKey) {
+ flags |= GPGME_CREATE_CERT;
+ flags |= GPGME_CREATE_ENCR;
+ } else {
+ if(params->allowEncryption) {
+ flags |= GPGME_CREATE_ENCR;
+ }
+ }
+
+ if(params->allowSigning) {
+ flags |= GPGME_CREATE_SIGN;
+ }
+
+ if(params->nonExpired) {
+ flags |= GPGME_CREATE_NOEXPIRE;
+ }
+
+ err = gpgme_op_createkey(mCtx, userid, algo, 0, expires, nullptr, flags);
+
checkErr(err);
emit signalKeyDBChanged();
}
@@ -547,7 +572,8 @@ namespace GpgME {
void GpgContext::checkErr(gpgme_error_t gpgmeError) {
//if (gpgmeError != GPG_ERR_NO_ERROR && gpgmeError != GPG_ERR_CANCELED) {
if (gpgmeError != GPG_ERR_NO_ERROR) {
- qDebug() << "[Error] Source: " << gpgme_strsource(gpgmeError) << " String: " << gpgErrString(gpgmeError);
+ qDebug() << "[Error "<< gpg_err_code(gpgmeError)
+ <<"] Source: " << gpgme_strsource(gpgmeError) << " Description: " << gpgErrString(gpgmeError);
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 6ee3ccf5..c1826380 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
// get application path
QString appPath = qApp->applicationDirPath();
- QApplication::setApplicationVersion("0.3.3");
+ QApplication::setApplicationVersion("1.0.0");
QApplication::setApplicationName("gpg4usb");
// dont show icons in menus
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index a9782fcc..8398740b 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -2,4 +2,5 @@ aux_source_directory(. QTUI_SOURCE)
add_library(qtui STATIC ${QTUI_SOURCE})
-qt5_use_modules(qtui Network PrintSupport Widgets Test Core) \ No newline at end of file
+target_link_libraries(qtui
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) \ No newline at end of file
diff --git a/src/ui/KeygenDialog.cpp b/src/ui/KeygenDialog.cpp
index 762acd52..5f29836f 100644
--- a/src/ui/KeygenDialog.cpp
+++ b/src/ui/KeygenDialog.cpp
@@ -40,13 +40,16 @@ void KeyGenDialog::generateKeyDialog() {
keySizeSpinBox = new QSpinBox(this);
keySizeSpinBox->setRange(1024, 4096);
- keySizeSpinBox->setValue(2048);
+ keySizeSpinBox->setValue(3072);
keySizeSpinBox->setSingleStep(1024);
keyTypeComboBox = new QComboBox(this);
keyTypeComboBox->addItem("RSA");
- keyTypeComboBox->addItem("DSA/Elgamal");
+ keyTypeComboBox->addItem("DSA");
+ keyTypeComboBox->addItem("ELG");
+ keyTypeComboBox->addItem("ED25519");
+ keyTypeComboBox->addItem("CV25519");
keyTypeComboBox->setCurrentIndex(0);
dateEdit = new QDateEdit(QDate::currentDate().addYears(5), this);
dateEdit->setMinimumDate(QDate::currentDate());
@@ -73,7 +76,7 @@ void KeyGenDialog::generateKeyDialog() {
auto *vbox1 = new QGridLayout;
vbox1->addWidget(new QLabel(tr("Name:")), 0, 0);
- vbox1->addWidget(new QLabel(tr("E-Mailaddress:")), 1, 0);
+ vbox1->addWidget(new QLabel(tr("E-Mail:")), 1, 0);
vbox1->addWidget(new QLabel(tr("Comment:")), 2, 0);
vbox1->addWidget(new QLabel(tr("Expiration Date:")), 3, 0);
vbox1->addWidget(new QLabel(tr("Never Expire")), 3, 3);
@@ -114,12 +117,16 @@ void KeyGenDialog::generateKeyDialog() {
void KeyGenDialog::slotKeyGenAccept() {
QString errorString = "";
- QString keyGenParams;
+
+ GenKeyInfo genKeyInfo;
+
/**
* check for errors in keygen dialog input
*/
if ((nameEdit->text()).size() < 5) {
errorString.append(tr(" Name must contain at least five characters. \n"));
+ } if(emailEdit->text().isEmpty()) {
+ errorString.append(tr(" Please give a email address. \n"));
}
if (passwordEdit->text() != repeatpwEdit->text()) {
errorString.append(tr(" Password and Repeat don't match. "));
@@ -130,44 +137,22 @@ void KeyGenDialog::slotKeyGenAccept() {
* create the string for key generation
*/
- if (keyTypeComboBox->currentText() == "RSA") {
- keyGenParams = "<GnupgKeyParms format=\"internal\">\n"
- "Key-Type: RSA\n"
- "Key-Usage: sign\n"
- "Key-Length: " + keySizeSpinBox->cleanText() + "\n"
- "Subkey-Type: RSA\n"
- "Subkey-Length: " +
- keySizeSpinBox->cleanText() + "\n"
- "Subkey-Usage: encrypt\n";
- } else {
- keyGenParams = "<GnupgKeyParms format=\"internal\">\n"
- "Key-Type: DSA\n"
- "Key-Length: " + keySizeSpinBox->cleanText() + "\n"
- "Subkey-Type: ELG-E\n"
- "Subkey-Length: " +
- keySizeSpinBox->cleanText() + "\n";
- }
+ genKeyInfo.userid = QString("%1 <%2>").arg(nameEdit->text(), emailEdit->text());
+
+ genKeyInfo.algo = keyTypeComboBox->currentText().toLower();
+
+ genKeyInfo.keySize = keySizeSpinBox->value();
+
+ genKeyInfo.passPhrase = passwordEdit->text();
- keyGenParams += "Name-Real: " + nameEdit->text().toUtf8() + "\n";
- if (!(commentEdit->text().isEmpty())) {
- keyGenParams += "Name-Comment: " + commentEdit->text().toUtf8() + "\n";
- }
- if (!(emailEdit->text().isEmpty())) {
- keyGenParams += "Name-Email: " + emailEdit->text().toUtf8() + "\n";
- }
if (expireCheckBox->checkState()) {
- keyGenParams += "Expire-Date: 0\n";
+ genKeyInfo.nonExpired = true;
+ genKeyInfo.expired = QDateTime(QDateTime::fromTime_t(0));
} else {
- keyGenParams += "Expire-Date: " + dateEdit->sectionText(QDateTimeEdit::YearSection) + "-" +
- dateEdit->sectionText(QDateTimeEdit::MonthSection) + "-" +
- dateEdit->sectionText(QDateTimeEdit::DaySection) + "\n";
- }
- if (!(passwordEdit->text().isEmpty())) {
- keyGenParams += "Passphrase: " + passwordEdit->text() + "\n";
+ genKeyInfo.expired = dateEdit->dateTime();
}
- keyGenParams += "</GnupgKeyParms>";
- auto *kg = new KeyGenThread(keyGenParams, mCtx);
+ auto *kg = new KeyGenThread(genKeyInfo, mCtx);
kg->start();
this->accept();
diff --git a/src/ui/KeygenThread.cpp b/src/ui/KeygenThread.cpp
index 2bb21eca..cd564c42 100644
--- a/src/ui/KeygenThread.cpp
+++ b/src/ui/KeygenThread.cpp
@@ -23,7 +23,7 @@
#include <utility>
-KeyGenThread::KeyGenThread(QString keyGenParams, GpgME::GpgContext *ctx) {
+KeyGenThread::KeyGenThread(GenKeyInfo keyGenParams, GpgME::GpgContext *ctx) {
this->keyGenParams = std::move(keyGenParams);
this->mCtx = ctx;
abort = false;
diff --git a/utils/gpgme/include/assuan.h b/utils/gpgme/include/assuan.h
new file mode 100644
index 00000000..6a072aa8
--- /dev/null
+++ b/utils/gpgme/include/assuan.h
@@ -0,0 +1,709 @@
+/* assuan.h - Definitions for the Assuan IPC library -*- c -*-
+ * Copyright (C) 2001-2013 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2021 g10 Code GmbH
+ *
+ * This file is part of Assuan.
+ *
+ * Assuan is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Assuan is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Do not edit. Generated from assuan.h.in by mkheader for linux-gnu.
+ */
+
+/* Compile time configuration:
+ *
+ * #define _ASSUAN_NO_SOCKET_WRAPPER
+ *
+ * Do not include the definitions for the socket wrapper feature.
+ */
+
+#ifndef ASSUAN_H
+#define ASSUAN_H
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#ifndef _ASSUAN_NO_SOCKET_WRAPPER
+#include <sys/socket.h>
+#endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/
+
+typedef struct msghdr *assuan_msghdr_t;
+
+#include <gpg-error.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0
+}
+#endif
+#endif
+
+/* The version of this header should match the one of the library. Do
+ * not use this symbol in your application; use assuan_check_version
+ * instead. */
+#define ASSUAN_VERSION "2.5.5"
+
+/* The version number of this header. It may be used to handle minor
+ * API incompatibilities. */
+#define ASSUAN_VERSION_NUMBER 0x020505
+
+
+/* Check for compiler features. */
+#if __GNUC__
+#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+
+#if _ASSUAN_GCC_VERSION > 30100
+#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+#endif
+#ifndef _ASSUAN_DEPRECATED
+#define _ASSUAN_DEPRECATED
+#endif
+
+
+#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
+
+struct assuan_context_s;
+typedef struct assuan_context_s *assuan_context_t;
+
+typedef int assuan_fd_t;
+#define ASSUAN_INVALID_FD (-1)
+#define ASSUAN_INVALID_PID ((pid_t) -1)
+static GPG_ERR_INLINE assuan_fd_t
+assuan_fd_from_posix_fd (int fd)
+{
+ return fd;
+}
+
+
+assuan_fd_t assuan_fdopen (int fd);
+
+/* Under Windows Assuan features an emulation of Unix domain sockets
+ based on a local TCP connections. To implement access permissions
+ based on file permissions a nonce is used which is expected by the
+ server as the first bytes received. On POSIX systems this is a
+ dummy structure. */
+struct assuan_sock_nonce_s
+{
+ size_t length;
+};
+typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
+
+
+/*
+ * Global interface.
+ */
+
+struct assuan_malloc_hooks
+{
+ void *(*malloc) (size_t cnt);
+ void *(*realloc) (void *ptr, size_t cnt);
+ void (*free) (void *ptr);
+};
+typedef struct assuan_malloc_hooks *assuan_malloc_hooks_t;
+
+/* Categories for log messages. */
+#define ASSUAN_LOG_INIT 1
+#define ASSUAN_LOG_CTX 2
+#define ASSUAN_LOG_ENGINE 3
+#define ASSUAN_LOG_DATA 4
+#define ASSUAN_LOG_SYSIO 5
+#define ASSUAN_LOG_CONTROL 8
+
+/* If MSG is NULL, return true/false depending on if this category is
+ * logged. This is used to probe before expensive log message
+ * generation (buffer dumps). */
+typedef int (*assuan_log_cb_t) (assuan_context_t ctx, void *hook,
+ unsigned int cat, const char *msg);
+
+/* Return or check the version number. */
+const char *assuan_check_version (const char *req_version);
+
+/* Set the default gpg error source. */
+void assuan_set_gpg_err_source (gpg_err_source_t errsource);
+
+/* Get the default gpg error source. */
+gpg_err_source_t assuan_get_gpg_err_source (void);
+
+
+/* Set the default malloc hooks. */
+void assuan_set_malloc_hooks (assuan_malloc_hooks_t malloc_hooks);
+
+/* Get the default malloc hooks. */
+assuan_malloc_hooks_t assuan_get_malloc_hooks (void);
+
+
+/* Set the default log callback handler. */
+void assuan_set_log_cb (assuan_log_cb_t log_cb, void *log_cb_data);
+
+/* Get the default log callback handler. */
+void assuan_get_log_cb (assuan_log_cb_t *log_cb, void **log_cb_data);
+
+
+/* Create a new Assuan context. The initial parameters are all needed
+ * in the creation of the context. */
+gpg_error_t assuan_new_ext (assuan_context_t *ctx, gpg_err_source_t errsource,
+ assuan_malloc_hooks_t malloc_hooks,
+ assuan_log_cb_t log_cb, void *log_cb_data);
+
+/* Create a new context with default arguments. */
+gpg_error_t assuan_new (assuan_context_t *ctx);
+
+/* Release all resources associated with the given context. */
+void assuan_release (assuan_context_t ctx);
+
+/* Release the memory at PTR using the allocation handler of the
+ * context CTX. This is a convenience function. */
+void assuan_free (assuan_context_t ctx, void *ptr);
+
+
+/* Set user-data in a context. */
+void assuan_set_pointer (assuan_context_t ctx, void *pointer);
+
+/* Get user-data in a context. */
+void *assuan_get_pointer (assuan_context_t ctx);
+
+
+/* Definitions of flags for assuan_set_flag(). */
+typedef unsigned int assuan_flag_t;
+
+/* When using a pipe server, by default Assuan will wait for the
+ * forked process to die in assuan_release. In certain cases this
+ * is not desirable. By setting this flag, the waitpid will be
+ * skipped and the caller is responsible to cleanup a forked
+ * process. */
+#define ASSUAN_NO_WAITPID 1
+
+/* This flag indicates whether Assuan logging is in confidential mode.
+ You can use assuan_{begin,end}_condidential to change the mode. */
+#define ASSUAN_CONFIDENTIAL 2
+
+/* This flag suppresses fix up of signal handlers for pipes. */
+#define ASSUAN_NO_FIXSIGNALS 3
+
+/* This flag changes assuan_transact to return comment lines via the
+ * status callback. The default is to skip comment lines. */
+#define ASSUAN_CONVEY_COMMENTS 4
+
+/* This flag disables logging for one context. */
+#define ASSUAN_NO_LOGGING 5
+
+/* This flag forces a connection close. */
+#define ASSUAN_FORCE_CLOSE 6
+
+
+/* For context CTX, set the flag FLAG to VALUE. Values for flags
+ * are usually 1 or 0 but certain flags might allow for other values;
+ * see the description of the type assuan_flag_t for details. */
+void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
+
+/* Return the VALUE of FLAG in context CTX. */
+int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
+
+/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1). */
+void assuan_begin_confidential (assuan_context_t ctx);
+
+/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0). */
+void assuan_end_confidential (assuan_context_t ctx);
+
+
+/* Direction values for assuan_set_io_monitor. */
+#define ASSUAN_IO_FROM_PEER 0
+#define ASSUAN_IO_TO_PEER 1
+
+/* Return flags of I/O monitor. */
+#define ASSUAN_IO_MONITOR_NOLOG 1
+#define ASSUAN_IO_MONITOR_IGNORE 2
+
+/* The IO monitor gets to see all I/O on the context, and can return
+ * ASSUAN_IO_MONITOR_* bits to control actions on it. */
+typedef unsigned int (*assuan_io_monitor_t) (assuan_context_t ctx, void *hook,
+ int inout, const char *line,
+ size_t linelen);
+
+/* Set the IO monitor function. */
+void assuan_set_io_monitor (assuan_context_t ctx,
+ assuan_io_monitor_t io_monitor, void *hook_data);
+
+/* The system hooks. See assuan_set_system_hooks et al. */
+#define ASSUAN_SYSTEM_HOOKS_VERSION 2
+#define ASSUAN_SPAWN_DETACHED 128
+struct assuan_system_hooks
+{
+ /* Always set to ASSUAN_SYTEM_HOOKS_VERSION. */
+ int version;
+
+ /* Sleep for the given number of microseconds. */
+ void (*usleep) (assuan_context_t ctx, unsigned int usec);
+
+ /* Create a pipe with an inheritable end. */
+ int (*pipe) (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx);
+
+ /* Close the given file descriptor, created with _assuan_pipe or one
+ of the socket functions. */
+ int (*close) (assuan_context_t ctx, assuan_fd_t fd);
+
+
+ ssize_t (*read) (assuan_context_t ctx, assuan_fd_t fd, void *buffer,
+ size_t size);
+ ssize_t (*write) (assuan_context_t ctx, assuan_fd_t fd,
+ const void *buffer, size_t size);
+
+ int (*recvmsg) (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
+ int flags);
+ int (*sendmsg) (assuan_context_t ctx, assuan_fd_t fd,
+ const assuan_msghdr_t msg, int flags);
+
+ /* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is
+ modified to reflect the value of the FD in the peer process (on
+ Windows). */
+ int (*spawn) (assuan_context_t ctx, pid_t *r_pid, const char *name,
+ const char **argv,
+ assuan_fd_t fd_in, assuan_fd_t fd_out,
+ assuan_fd_t *fd_child_list,
+ void (*atfork) (void *opaque, int reserved),
+ void *atforkvalue, unsigned int flags);
+
+ /* If action is 0, like waitpid. If action is 1, just release the PID? */
+ pid_t (*waitpid) (assuan_context_t ctx, pid_t pid,
+ int action, int *status, int options);
+ int (*socketpair) (assuan_context_t ctx, int _namespace, int style,
+ int protocol, assuan_fd_t filedes[2]);
+ int (*socket) (assuan_context_t ctx, int _namespace, int style, int protocol);
+ int (*connect) (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length);
+};
+typedef struct assuan_system_hooks *assuan_system_hooks_t;
+
+
+
+/*
+ * Configuration of the default log handler.
+ */
+
+/* Set the prefix to be used at the start of a line emitted by assuan
+ * on the log stream. The default is the empty string. Note, that
+ * this function is not thread-safe and should in general be used
+ * right at startup. */
+void assuan_set_assuan_log_prefix (const char *text);
+
+/* Return a prefix to be used at the start of a line emitted by assuan
+ * on the log stream. The default implementation returns the empty
+ * string, i.e. "". */
+const char *assuan_get_assuan_log_prefix (void);
+
+/* Global default log stream. */
+void assuan_set_assuan_log_stream (FILE *fp);
+
+/* Set the per context log stream for the default log handler. */
+void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
+
+
+/* The type for assuan command handlers. */
+typedef gpg_error_t (*assuan_handler_t) (assuan_context_t, char *);
+
+/*-- assuan-handler.c --*/
+gpg_error_t assuan_register_command (assuan_context_t ctx,
+ const char *cmd_string,
+ assuan_handler_t handler,
+ const char *help_string);
+gpg_error_t assuan_register_pre_cmd_notify (assuan_context_t ctx,
+ gpg_error_t (*fnc)(assuan_context_t,
+ const char *cmd));
+
+gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx,
+ void (*fnc)(assuan_context_t,
+ gpg_error_t));
+gpg_error_t assuan_register_bye_notify (assuan_context_t ctx,
+ assuan_handler_t handler);
+gpg_error_t assuan_register_reset_notify (assuan_context_t ctx,
+ assuan_handler_t handler);
+gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx,
+ assuan_handler_t handler);
+gpg_error_t assuan_register_input_notify (assuan_context_t ctx,
+ assuan_handler_t handler);
+gpg_error_t assuan_register_output_notify (assuan_context_t ctx,
+ assuan_handler_t handler);
+
+gpg_error_t assuan_register_option_handler (assuan_context_t ctx,
+ gpg_error_t (*fnc)(assuan_context_t,
+ const char*,
+ const char*));
+
+gpg_error_t assuan_process (assuan_context_t ctx);
+gpg_error_t assuan_process_next (assuan_context_t ctx, int *done);
+gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc);
+int assuan_get_active_fds (assuan_context_t ctx, int what,
+ assuan_fd_t *fdarray, int fdarraysize);
+
+const char *assuan_get_command_name (assuan_context_t ctx);
+
+FILE *assuan_get_data_fp (assuan_context_t ctx);
+gpg_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
+gpg_error_t assuan_write_status (assuan_context_t ctx,
+ const char *keyword, const char *text);
+
+/* Negotiate a file descriptor. If LINE contains "FD=N", returns N
+ * assuming a local file descriptor. If LINE contains "FD" reads a
+ * file descriptor via CTX and stores it in *RDF (the CTX must be
+ * capable of passing file descriptors). Under Windows the returned
+ * FD is a libc-type one. */
+gpg_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
+ assuan_fd_t *rfd);
+
+
+/*-- assuan-listen.c --*/
+gpg_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
+gpg_error_t assuan_accept (assuan_context_t ctx);
+assuan_fd_t assuan_get_input_fd (assuan_context_t ctx);
+assuan_fd_t assuan_get_output_fd (assuan_context_t ctx);
+gpg_error_t assuan_close_input_fd (assuan_context_t ctx);
+gpg_error_t assuan_close_output_fd (assuan_context_t ctx);
+
+
+/*-- assuan-pipe-server.c --*/
+gpg_error_t assuan_init_pipe_server (assuan_context_t ctx,
+ assuan_fd_t filedes[2]);
+
+/*-- assuan-socket-server.c --*/
+#define ASSUAN_SOCKET_SERVER_FDPASSING 1
+#define ASSUAN_SOCKET_SERVER_ACCEPTED 2
+gpg_error_t assuan_init_socket_server (assuan_context_t ctx,
+ assuan_fd_t listen_fd,
+ unsigned int flags);
+void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
+
+/*-- assuan-pipe-connect.c --*/
+#define ASSUAN_PIPE_CONNECT_FDPASSING 1
+#define ASSUAN_PIPE_CONNECT_DETACHED 128
+gpg_error_t assuan_pipe_connect (assuan_context_t ctx,
+ const char *name,
+ const char *argv[],
+ assuan_fd_t *fd_child_list,
+ void (*atfork) (void *, int),
+ void *atforkvalue,
+ unsigned int flags);
+
+/*-- assuan-socket-connect.c --*/
+#define ASSUAN_SOCKET_CONNECT_FDPASSING 1
+gpg_error_t assuan_socket_connect (assuan_context_t ctx, const char *name,
+ pid_t server_pid, unsigned int flags);
+
+/*-- assuan-socket-connect.c --*/
+gpg_error_t assuan_socket_connect_fd (assuan_context_t ctx, int fd,
+ unsigned int flags);
+
+/*-- context.c --*/
+pid_t assuan_get_pid (assuan_context_t ctx);
+struct _assuan_peercred
+{
+#ifdef _WIN32
+ /* Empty struct not allowed on some compilers, so, put this (not valid). */
+ pid_t pid;
+#else
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+#endif
+};
+typedef struct _assuan_peercred *assuan_peercred_t;
+
+gpg_error_t assuan_get_peercred (assuan_context_t ctx,
+ assuan_peercred_t *peercred);
+
+
+
+/*
+ * Client interface.
+ */
+
+/* Client response codes. */
+#define ASSUAN_RESPONSE_ERROR 0
+#define ASSUAN_RESPONSE_OK 1
+#define ASSUAN_RESPONSE_DATA 2
+#define ASSUAN_RESPONSE_INQUIRE 3
+#define ASSUAN_RESPONSE_STATUS 4
+#define ASSUAN_RESPONSE_END 5
+#define ASSUAN_RESPONSE_COMMENT 6
+typedef int assuan_response_t;
+
+/* This already de-escapes data lines. */
+gpg_error_t assuan_client_read_response (assuan_context_t ctx,
+ char **line, int *linelen);
+
+gpg_error_t assuan_client_parse_response (assuan_context_t ctx,
+ char *line, int linelen,
+ assuan_response_t *response,
+ int *off);
+
+/*-- assuan-client.c --*/
+gpg_error_t
+assuan_transact (assuan_context_t ctx,
+ const char *command,
+ gpg_error_t (*data_cb)(void *, const void *, size_t),
+ void *data_cb_arg,
+ gpg_error_t (*inquire_cb)(void*, const char *),
+ void *inquire_cb_arg,
+ gpg_error_t (*status_cb)(void*, const char *),
+ void *status_cb_arg);
+
+
+/*-- assuan-inquire.c --*/
+gpg_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
+ unsigned char **r_buffer, size_t *r_length,
+ size_t maxlen);
+gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
+ size_t maxlen,
+ gpg_error_t (*cb) (void *cb_data,
+ gpg_error_t rc,
+ unsigned char *buf,
+ size_t buf_len),
+ void *cb_data);
+/*-- assuan-buffer.c --*/
+gpg_error_t assuan_read_line (assuan_context_t ctx,
+ char **line, size_t *linelen);
+int assuan_pending_line (assuan_context_t ctx);
+gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line);
+gpg_error_t assuan_send_data (assuan_context_t ctx,
+ const void *buffer, size_t length);
+
+/* The file descriptor must be pending before assuan_receivefd is
+ * called. This means that assuan_sendfd should be called *before* the
+ * trigger is sent (normally via assuan_write_line ("INPUT FD")). */
+gpg_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
+gpg_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
+
+
+/*-- assuan-util.c --*/
+gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err,
+ const char *text);
+
+
+
+/*-- assuan-socket.c --*/
+
+/* This flag is used with assuan_sock_connect_byname to
+ * connect via SOCKS. */
+#define ASSUAN_SOCK_SOCKS 1
+
+/* This flag is used with assuan_sock_connect_byname to force a
+ connection via Tor even if the socket subsystem has not been
+ swicthed into Tor mode. This flags overrides ASSUAN_SOCK_SOCKS. */
+#define ASSUAN_SOCK_TOR 2
+
+/* These are socket wrapper functions to support an emulation of Unix
+ * domain sockets on Windows. */
+gpg_error_t assuan_sock_init (void);
+void assuan_sock_deinit (void);
+int assuan_sock_close (assuan_fd_t fd);
+assuan_fd_t assuan_sock_new (int domain, int type, int proto);
+int assuan_sock_set_flag (assuan_fd_t sockfd, const char *name, int value);
+int assuan_sock_get_flag (assuan_fd_t sockfd, const char *name, int *r_value);
+int assuan_sock_connect (assuan_fd_t sockfd,
+ struct sockaddr *addr, int addrlen);
+assuan_fd_t assuan_sock_connect_byname (const char *host, unsigned short port,
+ int reserved,
+ const char *credentials,
+ unsigned int flags);
+int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
+int assuan_sock_set_sockaddr_un (const char *fname, struct sockaddr *addr,
+ int *r_redirected);
+int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
+ assuan_sock_nonce_t *nonce);
+int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
+void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks);
+
+
+/* Set the default system callbacks. This is irreversible. */
+void assuan_set_system_hooks (assuan_system_hooks_t system_hooks);
+
+/* Set the per context system callbacks. This is irreversible. */
+void assuan_ctx_set_system_hooks (assuan_context_t ctx,
+ assuan_system_hooks_t system_hooks);
+
+/* Change the system hooks for the socket interface.
+ * This is not thread-safe. */
+void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks);
+
+void __assuan_usleep (assuan_context_t ctx, unsigned int usec);
+int __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx);
+int __assuan_close (assuan_context_t ctx, assuan_fd_t fd);
+int __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name,
+ const char **argv, assuan_fd_t fd_in, assuan_fd_t fd_out,
+ assuan_fd_t *fd_child_list,
+ void (*atfork) (void *opaque, int reserved),
+ void *atforkvalue, unsigned int flags);
+int __assuan_socketpair (assuan_context_t ctx, int _namespace, int style,
+ int protocol, assuan_fd_t filedes[2]);
+int __assuan_socket (assuan_context_t ctx, int _namespace, int style, int protocol);
+int __assuan_connect (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length);
+ssize_t __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size);
+ssize_t __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size);
+int __assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags);
+int __assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, int flags);
+pid_t __assuan_waitpid (assuan_context_t ctx, pid_t pid, int nowait, int *status, int options);
+
+/* Standard system hooks for the legacy GNU Pth. */
+#define ASSUAN_SYSTEM_PTH_IMPL \
+ static void _assuan_pth_usleep (assuan_context_t ctx, unsigned int usec) \
+ { (void) ctx; pth_usleep (usec); } \
+ static ssize_t _assuan_pth_read (assuan_context_t ctx, assuan_fd_t fd, \
+ void *buffer, size_t size) \
+ { (void) ctx; return pth_read (fd, buffer, size); } \
+ static ssize_t _assuan_pth_write (assuan_context_t ctx, assuan_fd_t fd, \
+ const void *buffer, size_t size) \
+ { (void) ctx; return pth_write (fd, buffer, size); } \
+ static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \
+ assuan_msghdr_t msg, int flags) \
+ { \
+ /* Pth does not provide a recvmsg function. We implement it. */ \
+ int ret; \
+ int fdmode; \
+ \
+ (void) ctx; \
+ fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \
+ if (fdmode == PTH_FDMODE_ERROR) \
+ { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ if (fdmode == PTH_FDMODE_BLOCK) \
+ { \
+ fd_set fds; \
+ \
+ FD_ZERO (&fds); \
+ FD_SET (fd, &fds); \
+ while ((ret = pth_select (fd + 1, &fds, NULL, NULL, NULL)) < 0 \
+ && errno == EINTR) \
+ ; \
+ if (ret < 0) \
+ return -1; \
+ } \
+ \
+ while ((ret = recvmsg (fd, msg, flags)) == -1 && errno == EINTR) \
+ ; \
+ return ret; \
+ } \
+ static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \
+ const assuan_msghdr_t msg, int flags) \
+ { \
+ /* Pth does not provide a sendmsg function. We implement it. */ \
+ int ret; \
+ int fdmode; \
+ \
+ (void) ctx; \
+ fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \
+ if (fdmode == PTH_FDMODE_ERROR) \
+ { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ if (fdmode == PTH_FDMODE_BLOCK) \
+ { \
+ fd_set fds; \
+ \
+ FD_ZERO (&fds); \
+ FD_SET (fd, &fds); \
+ while ((ret = pth_select (fd + 1, NULL, &fds, NULL, NULL)) < 0 \
+ && errno == EINTR) \
+ ; \
+ if (ret < 0) \
+ return -1; \
+ } \
+ \
+ while ((ret = sendmsg (fd, msg, flags)) == -1 && errno == EINTR) \
+ ; \
+ return ret; \
+ } \
+ static pid_t _assuan_pth_waitpid (assuan_context_t ctx, pid_t pid, \
+ int nowait, int *status, int options) \
+ { (void) ctx; \
+ if (!nowait) return pth_waitpid (pid, status, options); \
+ else return 0; } \
+ \
+ struct assuan_system_hooks _assuan_system_pth = \
+ { ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_pth_usleep, __assuan_pipe, \
+ __assuan_close, _assuan_pth_read, _assuan_pth_write, \
+ _assuan_pth_recvmsg, _assuan_pth_sendmsg, \
+ __assuan_spawn, _assuan_pth_waitpid, __assuan_socketpair, \
+ __assuan_socket, __assuan_connect }
+
+extern struct assuan_system_hooks _assuan_system_pth;
+#define ASSUAN_SYSTEM_PTH &_assuan_system_pth
+
+/* Standard system hooks for nPth. */
+#define ASSUAN_SYSTEM_NPTH_IMPL \
+ static void _assuan_npth_usleep (assuan_context_t ctx, unsigned int usec) \
+ { npth_unprotect(); \
+ __assuan_usleep (ctx, usec); \
+ npth_protect(); } \
+ static ssize_t _assuan_npth_read (assuan_context_t ctx, assuan_fd_t fd, \
+ void *buffer, size_t size) \
+ { ssize_t res; (void) ctx; npth_unprotect(); \
+ res = __assuan_read (ctx, fd, buffer, size); \
+ npth_protect(); return res; } \
+ static ssize_t _assuan_npth_write (assuan_context_t ctx, assuan_fd_t fd, \
+ const void *buffer, size_t size) \
+ { ssize_t res; (void) ctx; npth_unprotect(); \
+ res = __assuan_write (ctx, fd, buffer, size); \
+ npth_protect(); return res; } \
+ static int _assuan_npth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \
+ assuan_msghdr_t msg, int flags) \
+ { int res; (void) ctx; npth_unprotect(); \
+ res = __assuan_recvmsg (ctx, fd, msg, flags); \
+ npth_protect(); return res; } \
+ static int _assuan_npth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \
+ const assuan_msghdr_t msg, int flags) \
+ { int res; (void) ctx; npth_unprotect(); \
+ res = __assuan_sendmsg (ctx, fd, msg, flags); \
+ npth_protect(); return res; } \
+ static pid_t _assuan_npth_waitpid (assuan_context_t ctx, pid_t pid, \
+ int nowait, int *status, int options) \
+ { pid_t res; (void) ctx; npth_unprotect(); \
+ res = __assuan_waitpid (ctx, pid, nowait, status, options); \
+ npth_protect(); return res; } \
+ static int _assuan_npth_connect (assuan_context_t ctx, int sock, \
+ struct sockaddr *addr, socklen_t len)\
+ { int res; npth_unprotect(); \
+ res = __assuan_connect (ctx, sock, addr, len); \
+ npth_protect(); return res; } \
+ static int _assuan_npth_close (assuan_context_t ctx, assuan_fd_t fd) \
+ { int res; npth_unprotect(); \
+ res = __assuan_close (ctx, fd); \
+ npth_protect(); return res; } \
+ \
+ struct assuan_system_hooks _assuan_system_npth = \
+ { ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_npth_usleep, __assuan_pipe, \
+ _assuan_npth_close, _assuan_npth_read, _assuan_npth_write, \
+ _assuan_npth_recvmsg, _assuan_npth_sendmsg, \
+ __assuan_spawn, _assuan_npth_waitpid, __assuan_socketpair, \
+ __assuan_socket, _assuan_npth_connect }
+
+extern struct assuan_system_hooks _assuan_system_npth;
+#define ASSUAN_SYSTEM_NPTH &_assuan_system_npth
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ASSUAN_H */
+/*
+Local Variables:
+buffer-read-only: t
+End:
+*/
diff --git a/utils/gpgme/include/gpg-error.h b/utils/gpgme/include/gpg-error.h
new file mode 100644
index 00000000..f5325cf5
--- /dev/null
+++ b/utils/gpgme/include/gpg-error.h
@@ -0,0 +1,2005 @@
+/* gpg-error.h or gpgrt.h - Common code for GnuPG and others. -*- c -*-
+ * Copyright (C) 2001-2020 g10 Code GmbH
+ *
+ * This file is part of libgpg-error (aka libgpgrt).
+ *
+ * libgpg-error is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * libgpg-error is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1+
+ *
+ * Do not edit. Generated from gpg-error.h.in for:
+ x86_64-unknown-linux-gnu (x86_64-pc-linux-gnu)
+ */
+
+/* The GnuPG project consists of many components. Error codes are
+ * exchanged between all components. The common error codes and their
+ * user-presentable descriptions are kept into a shared library to
+ * allow adding new error codes and components without recompiling any
+ * of the other components. In addition to error codes this library
+ * also features several other groups of functions which are common to
+ * all GnuPG components. They may be used by independet project as
+ * well. The interfaces will not change in a backward incompatible way.
+ *
+ * An error code together with an error source build up an error
+ * value. As the error value is been passed from one component to
+ * another, it preserves the information about the source and nature
+ * of the error.
+ *
+ * A component of the GnuPG project can define the following macros to
+ * tune the behaviour of the library:
+ *
+ * GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
+ * gpg_err_source_t to make that source the default for gpg_error().
+ * Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default.
+ *
+ * GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the
+ * internal gettext API to standard names. This has only an effect on
+ * Windows platforms.
+ *
+ * GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the
+ * estream functions.
+ *
+ * GPGRT_ENABLE_LOG_MACROS: Define to provide short versions of the
+ * log functions.
+ *
+ * GPGRT_ENABLE_ARGPARSE_MACROS: Needs to be defined to provide the
+ * mandatory macros of the argparse interface.
+ */
+
+#ifndef GPG_ERROR_H
+#define GPG_ERROR_H 1
+#ifndef GPGRT_H
+#define GPGRT_H 1
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+/* The version string of this header. */
+#define GPG_ERROR_VERSION "1.42"
+#define GPGRT_VERSION "1.42"
+
+/* The version number of this header. */
+#define GPG_ERROR_VERSION_NUMBER 0x012a00
+#define GPGRT_VERSION_NUMBER 0x012a00
+
+
+#ifdef __GNUC__
+# define GPG_ERR_INLINE __inline__
+#elif defined(_MSC_VER) && _MSC_VER >= 1300
+# define GPG_ERR_INLINE __inline
+#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+# define GPG_ERR_INLINE inline
+#else
+# ifndef GPG_ERR_INLINE
+# define GPG_ERR_INLINE
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* just to make Emacs auto-indent happy */
+}
+#endif
+#endif /* __cplusplus */
+
+
+
+/* The error source type gpg_err_source_t.
+ *
+ * Where as the Poo out of a welle small
+ * Taketh his firste springing and his sours.
+ * --Chaucer.
+ */
+
+/* Only use free slots, never change or reorder the existing
+ * entries. */
+typedef enum
+ {
+ GPG_ERR_SOURCE_UNKNOWN = 0,
+ GPG_ERR_SOURCE_GCRYPT = 1,
+ GPG_ERR_SOURCE_GPG = 2,
+ GPG_ERR_SOURCE_GPGSM = 3,
+ GPG_ERR_SOURCE_GPGAGENT = 4,
+ GPG_ERR_SOURCE_PINENTRY = 5,
+ GPG_ERR_SOURCE_SCD = 6,
+ GPG_ERR_SOURCE_GPGME = 7,
+ GPG_ERR_SOURCE_KEYBOX = 8,
+ GPG_ERR_SOURCE_KSBA = 9,
+ GPG_ERR_SOURCE_DIRMNGR = 10,
+ GPG_ERR_SOURCE_GSTI = 11,
+ GPG_ERR_SOURCE_GPA = 12,
+ GPG_ERR_SOURCE_KLEO = 13,
+ GPG_ERR_SOURCE_G13 = 14,
+ GPG_ERR_SOURCE_ASSUAN = 15,
+ GPG_ERR_SOURCE_TPM2D = 16,
+ GPG_ERR_SOURCE_TLS = 17,
+ GPG_ERR_SOURCE_ANY = 31,
+ GPG_ERR_SOURCE_USER_1 = 32,
+ GPG_ERR_SOURCE_USER_2 = 33,
+ GPG_ERR_SOURCE_USER_3 = 34,
+ GPG_ERR_SOURCE_USER_4 = 35,
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_SOURCE_DIM = 128
+ } gpg_err_source_t;
+
+
+/* The error code type gpg_err_code_t. */
+
+/* Only use free slots, never change or reorder the existing
+ * entries. */
+typedef enum
+ {
+ GPG_ERR_NO_ERROR = 0,
+ GPG_ERR_GENERAL = 1,
+ GPG_ERR_UNKNOWN_PACKET = 2,
+ GPG_ERR_UNKNOWN_VERSION = 3,
+ GPG_ERR_PUBKEY_ALGO = 4,
+ GPG_ERR_DIGEST_ALGO = 5,
+ GPG_ERR_BAD_PUBKEY = 6,
+ GPG_ERR_BAD_SECKEY = 7,
+ GPG_ERR_BAD_SIGNATURE = 8,
+ GPG_ERR_NO_PUBKEY = 9,
+ GPG_ERR_CHECKSUM = 10,
+ GPG_ERR_BAD_PASSPHRASE = 11,
+ GPG_ERR_CIPHER_ALGO = 12,
+ GPG_ERR_KEYRING_OPEN = 13,
+ GPG_ERR_INV_PACKET = 14,
+ GPG_ERR_INV_ARMOR = 15,
+ GPG_ERR_NO_USER_ID = 16,
+ GPG_ERR_NO_SECKEY = 17,
+ GPG_ERR_WRONG_SECKEY = 18,
+ GPG_ERR_BAD_KEY = 19,
+ GPG_ERR_COMPR_ALGO = 20,
+ GPG_ERR_NO_PRIME = 21,
+ GPG_ERR_NO_ENCODING_METHOD = 22,
+ GPG_ERR_NO_ENCRYPTION_SCHEME = 23,
+ GPG_ERR_NO_SIGNATURE_SCHEME = 24,
+ GPG_ERR_INV_ATTR = 25,
+ GPG_ERR_NO_VALUE = 26,
+ GPG_ERR_NOT_FOUND = 27,
+ GPG_ERR_VALUE_NOT_FOUND = 28,
+ GPG_ERR_SYNTAX = 29,
+ GPG_ERR_BAD_MPI = 30,
+ GPG_ERR_INV_PASSPHRASE = 31,
+ GPG_ERR_SIG_CLASS = 32,
+ GPG_ERR_RESOURCE_LIMIT = 33,
+ GPG_ERR_INV_KEYRING = 34,
+ GPG_ERR_TRUSTDB = 35,
+ GPG_ERR_BAD_CERT = 36,
+ GPG_ERR_INV_USER_ID = 37,
+ GPG_ERR_UNEXPECTED = 38,
+ GPG_ERR_TIME_CONFLICT = 39,
+ GPG_ERR_KEYSERVER = 40,
+ GPG_ERR_WRONG_PUBKEY_ALGO = 41,
+ GPG_ERR_TRIBUTE_TO_D_A = 42,
+ GPG_ERR_WEAK_KEY = 43,
+ GPG_ERR_INV_KEYLEN = 44,
+ GPG_ERR_INV_ARG = 45,
+ GPG_ERR_BAD_URI = 46,
+ GPG_ERR_INV_URI = 47,
+ GPG_ERR_NETWORK = 48,
+ GPG_ERR_UNKNOWN_HOST = 49,
+ GPG_ERR_SELFTEST_FAILED = 50,
+ GPG_ERR_NOT_ENCRYPTED = 51,
+ GPG_ERR_NOT_PROCESSED = 52,
+ GPG_ERR_UNUSABLE_PUBKEY = 53,
+ GPG_ERR_UNUSABLE_SECKEY = 54,
+ GPG_ERR_INV_VALUE = 55,
+ GPG_ERR_BAD_CERT_CHAIN = 56,
+ GPG_ERR_MISSING_CERT = 57,
+ GPG_ERR_NO_DATA = 58,
+ GPG_ERR_BUG = 59,
+ GPG_ERR_NOT_SUPPORTED = 60,
+ GPG_ERR_INV_OP = 61,
+ GPG_ERR_TIMEOUT = 62,
+ GPG_ERR_INTERNAL = 63,
+ GPG_ERR_EOF_GCRYPT = 64,
+ GPG_ERR_INV_OBJ = 65,
+ GPG_ERR_TOO_SHORT = 66,
+ GPG_ERR_TOO_LARGE = 67,
+ GPG_ERR_NO_OBJ = 68,
+ GPG_ERR_NOT_IMPLEMENTED = 69,
+ GPG_ERR_CONFLICT = 70,
+ GPG_ERR_INV_CIPHER_MODE = 71,
+ GPG_ERR_INV_FLAG = 72,
+ GPG_ERR_INV_HANDLE = 73,
+ GPG_ERR_TRUNCATED = 74,
+ GPG_ERR_INCOMPLETE_LINE = 75,
+ GPG_ERR_INV_RESPONSE = 76,
+ GPG_ERR_NO_AGENT = 77,
+ GPG_ERR_AGENT = 78,
+ GPG_ERR_INV_DATA = 79,
+ GPG_ERR_ASSUAN_SERVER_FAULT = 80,
+ GPG_ERR_ASSUAN = 81,
+ GPG_ERR_INV_SESSION_KEY = 82,
+ GPG_ERR_INV_SEXP = 83,
+ GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
+ GPG_ERR_NO_PIN_ENTRY = 85,
+ GPG_ERR_PIN_ENTRY = 86,
+ GPG_ERR_BAD_PIN = 87,
+ GPG_ERR_INV_NAME = 88,
+ GPG_ERR_BAD_DATA = 89,
+ GPG_ERR_INV_PARAMETER = 90,
+ GPG_ERR_WRONG_CARD = 91,
+ GPG_ERR_NO_DIRMNGR = 92,
+ GPG_ERR_DIRMNGR = 93,
+ GPG_ERR_CERT_REVOKED = 94,
+ GPG_ERR_NO_CRL_KNOWN = 95,
+ GPG_ERR_CRL_TOO_OLD = 96,
+ GPG_ERR_LINE_TOO_LONG = 97,
+ GPG_ERR_NOT_TRUSTED = 98,
+ GPG_ERR_CANCELED = 99,
+ GPG_ERR_BAD_CA_CERT = 100,
+ GPG_ERR_CERT_EXPIRED = 101,
+ GPG_ERR_CERT_TOO_YOUNG = 102,
+ GPG_ERR_UNSUPPORTED_CERT = 103,
+ GPG_ERR_UNKNOWN_SEXP = 104,
+ GPG_ERR_UNSUPPORTED_PROTECTION = 105,
+ GPG_ERR_CORRUPTED_PROTECTION = 106,
+ GPG_ERR_AMBIGUOUS_NAME = 107,
+ GPG_ERR_CARD = 108,
+ GPG_ERR_CARD_RESET = 109,
+ GPG_ERR_CARD_REMOVED = 110,
+ GPG_ERR_INV_CARD = 111,
+ GPG_ERR_CARD_NOT_PRESENT = 112,
+ GPG_ERR_NO_PKCS15_APP = 113,
+ GPG_ERR_NOT_CONFIRMED = 114,
+ GPG_ERR_CONFIGURATION = 115,
+ GPG_ERR_NO_POLICY_MATCH = 116,
+ GPG_ERR_INV_INDEX = 117,
+ GPG_ERR_INV_ID = 118,
+ GPG_ERR_NO_SCDAEMON = 119,
+ GPG_ERR_SCDAEMON = 120,
+ GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
+ GPG_ERR_BAD_PIN_METHOD = 122,
+ GPG_ERR_CARD_NOT_INITIALIZED = 123,
+ GPG_ERR_UNSUPPORTED_OPERATION = 124,
+ GPG_ERR_WRONG_KEY_USAGE = 125,
+ GPG_ERR_NOTHING_FOUND = 126,
+ GPG_ERR_WRONG_BLOB_TYPE = 127,
+ GPG_ERR_MISSING_VALUE = 128,
+ GPG_ERR_HARDWARE = 129,
+ GPG_ERR_PIN_BLOCKED = 130,
+ GPG_ERR_USE_CONDITIONS = 131,
+ GPG_ERR_PIN_NOT_SYNCED = 132,
+ GPG_ERR_INV_CRL = 133,
+ GPG_ERR_BAD_BER = 134,
+ GPG_ERR_INV_BER = 135,
+ GPG_ERR_ELEMENT_NOT_FOUND = 136,
+ GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
+ GPG_ERR_INV_TAG = 138,
+ GPG_ERR_INV_LENGTH = 139,
+ GPG_ERR_INV_KEYINFO = 140,
+ GPG_ERR_UNEXPECTED_TAG = 141,
+ GPG_ERR_NOT_DER_ENCODED = 142,
+ GPG_ERR_NO_CMS_OBJ = 143,
+ GPG_ERR_INV_CMS_OBJ = 144,
+ GPG_ERR_UNKNOWN_CMS_OBJ = 145,
+ GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
+ GPG_ERR_UNSUPPORTED_ENCODING = 147,
+ GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
+ GPG_ERR_UNKNOWN_ALGORITHM = 149,
+ GPG_ERR_INV_ENGINE = 150,
+ GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
+ GPG_ERR_DECRYPT_FAILED = 152,
+ GPG_ERR_KEY_EXPIRED = 153,
+ GPG_ERR_SIG_EXPIRED = 154,
+ GPG_ERR_ENCODING_PROBLEM = 155,
+ GPG_ERR_INV_STATE = 156,
+ GPG_ERR_DUP_VALUE = 157,
+ GPG_ERR_MISSING_ACTION = 158,
+ GPG_ERR_MODULE_NOT_FOUND = 159,
+ GPG_ERR_INV_OID_STRING = 160,
+ GPG_ERR_INV_TIME = 161,
+ GPG_ERR_INV_CRL_OBJ = 162,
+ GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
+ GPG_ERR_INV_CERT_OBJ = 164,
+ GPG_ERR_UNKNOWN_NAME = 165,
+ GPG_ERR_LOCALE_PROBLEM = 166,
+ GPG_ERR_NOT_LOCKED = 167,
+ GPG_ERR_PROTOCOL_VIOLATION = 168,
+ GPG_ERR_INV_MAC = 169,
+ GPG_ERR_INV_REQUEST = 170,
+ GPG_ERR_UNKNOWN_EXTN = 171,
+ GPG_ERR_UNKNOWN_CRIT_EXTN = 172,
+ GPG_ERR_LOCKED = 173,
+ GPG_ERR_UNKNOWN_OPTION = 174,
+ GPG_ERR_UNKNOWN_COMMAND = 175,
+ GPG_ERR_NOT_OPERATIONAL = 176,
+ GPG_ERR_NO_PASSPHRASE = 177,
+ GPG_ERR_NO_PIN = 178,
+ GPG_ERR_NOT_ENABLED = 179,
+ GPG_ERR_NO_ENGINE = 180,
+ GPG_ERR_MISSING_KEY = 181,
+ GPG_ERR_TOO_MANY = 182,
+ GPG_ERR_LIMIT_REACHED = 183,
+ GPG_ERR_NOT_INITIALIZED = 184,
+ GPG_ERR_MISSING_ISSUER_CERT = 185,
+ GPG_ERR_NO_KEYSERVER = 186,
+ GPG_ERR_INV_CURVE = 187,
+ GPG_ERR_UNKNOWN_CURVE = 188,
+ GPG_ERR_DUP_KEY = 189,
+ GPG_ERR_AMBIGUOUS = 190,
+ GPG_ERR_NO_CRYPT_CTX = 191,
+ GPG_ERR_WRONG_CRYPT_CTX = 192,
+ GPG_ERR_BAD_CRYPT_CTX = 193,
+ GPG_ERR_CRYPT_CTX_CONFLICT = 194,
+ GPG_ERR_BROKEN_PUBKEY = 195,
+ GPG_ERR_BROKEN_SECKEY = 196,
+ GPG_ERR_MAC_ALGO = 197,
+ GPG_ERR_FULLY_CANCELED = 198,
+ GPG_ERR_UNFINISHED = 199,
+ GPG_ERR_BUFFER_TOO_SHORT = 200,
+ GPG_ERR_SEXP_INV_LEN_SPEC = 201,
+ GPG_ERR_SEXP_STRING_TOO_LONG = 202,
+ GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
+ GPG_ERR_SEXP_NOT_CANONICAL = 204,
+ GPG_ERR_SEXP_BAD_CHARACTER = 205,
+ GPG_ERR_SEXP_BAD_QUOTATION = 206,
+ GPG_ERR_SEXP_ZERO_PREFIX = 207,
+ GPG_ERR_SEXP_NESTED_DH = 208,
+ GPG_ERR_SEXP_UNMATCHED_DH = 209,
+ GPG_ERR_SEXP_UNEXPECTED_PUNC = 210,
+ GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
+ GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
+ GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
+ GPG_ERR_SUBKEYS_EXP_OR_REV = 217,
+ GPG_ERR_DB_CORRUPTED = 218,
+ GPG_ERR_SERVER_FAILED = 219,
+ GPG_ERR_NO_NAME = 220,
+ GPG_ERR_NO_KEY = 221,
+ GPG_ERR_LEGACY_KEY = 222,
+ GPG_ERR_REQUEST_TOO_SHORT = 223,
+ GPG_ERR_REQUEST_TOO_LONG = 224,
+ GPG_ERR_OBJ_TERM_STATE = 225,
+ GPG_ERR_NO_CERT_CHAIN = 226,
+ GPG_ERR_CERT_TOO_LARGE = 227,
+ GPG_ERR_INV_RECORD = 228,
+ GPG_ERR_BAD_MAC = 229,
+ GPG_ERR_UNEXPECTED_MSG = 230,
+ GPG_ERR_COMPR_FAILED = 231,
+ GPG_ERR_WOULD_WRAP = 232,
+ GPG_ERR_FATAL_ALERT = 233,
+ GPG_ERR_NO_CIPHER = 234,
+ GPG_ERR_MISSING_CLIENT_CERT = 235,
+ GPG_ERR_CLOSE_NOTIFY = 236,
+ GPG_ERR_TICKET_EXPIRED = 237,
+ GPG_ERR_BAD_TICKET = 238,
+ GPG_ERR_UNKNOWN_IDENTITY = 239,
+ GPG_ERR_BAD_HS_CERT = 240,
+ GPG_ERR_BAD_HS_CERT_REQ = 241,
+ GPG_ERR_BAD_HS_CERT_VER = 242,
+ GPG_ERR_BAD_HS_CHANGE_CIPHER = 243,
+ GPG_ERR_BAD_HS_CLIENT_HELLO = 244,
+ GPG_ERR_BAD_HS_SERVER_HELLO = 245,
+ GPG_ERR_BAD_HS_SERVER_HELLO_DONE = 246,
+ GPG_ERR_BAD_HS_FINISHED = 247,
+ GPG_ERR_BAD_HS_SERVER_KEX = 248,
+ GPG_ERR_BAD_HS_CLIENT_KEX = 249,
+ GPG_ERR_BOGUS_STRING = 250,
+ GPG_ERR_FORBIDDEN = 251,
+ GPG_ERR_KEY_DISABLED = 252,
+ GPG_ERR_KEY_ON_CARD = 253,
+ GPG_ERR_INV_LOCK_OBJ = 254,
+ GPG_ERR_TRUE = 255,
+ GPG_ERR_FALSE = 256,
+ GPG_ERR_ASS_GENERAL = 257,
+ GPG_ERR_ASS_ACCEPT_FAILED = 258,
+ GPG_ERR_ASS_CONNECT_FAILED = 259,
+ GPG_ERR_ASS_INV_RESPONSE = 260,
+ GPG_ERR_ASS_INV_VALUE = 261,
+ GPG_ERR_ASS_INCOMPLETE_LINE = 262,
+ GPG_ERR_ASS_LINE_TOO_LONG = 263,
+ GPG_ERR_ASS_NESTED_COMMANDS = 264,
+ GPG_ERR_ASS_NO_DATA_CB = 265,
+ GPG_ERR_ASS_NO_INQUIRE_CB = 266,
+ GPG_ERR_ASS_NOT_A_SERVER = 267,
+ GPG_ERR_ASS_NOT_A_CLIENT = 268,
+ GPG_ERR_ASS_SERVER_START = 269,
+ GPG_ERR_ASS_READ_ERROR = 270,
+ GPG_ERR_ASS_WRITE_ERROR = 271,
+ GPG_ERR_ASS_TOO_MUCH_DATA = 273,
+ GPG_ERR_ASS_UNEXPECTED_CMD = 274,
+ GPG_ERR_ASS_UNKNOWN_CMD = 275,
+ GPG_ERR_ASS_SYNTAX = 276,
+ GPG_ERR_ASS_CANCELED = 277,
+ GPG_ERR_ASS_NO_INPUT = 278,
+ GPG_ERR_ASS_NO_OUTPUT = 279,
+ GPG_ERR_ASS_PARAMETER = 280,
+ GPG_ERR_ASS_UNKNOWN_INQUIRE = 281,
+ GPG_ERR_ENGINE_TOO_OLD = 300,
+ GPG_ERR_WINDOW_TOO_SMALL = 301,
+ GPG_ERR_WINDOW_TOO_LARGE = 302,
+ GPG_ERR_MISSING_ENVVAR = 303,
+ GPG_ERR_USER_ID_EXISTS = 304,
+ GPG_ERR_NAME_EXISTS = 305,
+ GPG_ERR_DUP_NAME = 306,
+ GPG_ERR_TOO_YOUNG = 307,
+ GPG_ERR_TOO_OLD = 308,
+ GPG_ERR_UNKNOWN_FLAG = 309,
+ GPG_ERR_INV_ORDER = 310,
+ GPG_ERR_ALREADY_FETCHED = 311,
+ GPG_ERR_TRY_LATER = 312,
+ GPG_ERR_WRONG_NAME = 313,
+ GPG_ERR_NO_AUTH = 314,
+ GPG_ERR_BAD_AUTH = 315,
+ GPG_ERR_NO_KEYBOXD = 316,
+ GPG_ERR_KEYBOXD = 317,
+ GPG_ERR_NO_SERVICE = 318,
+ GPG_ERR_SERVICE = 319,
+ GPG_ERR_SYSTEM_BUG = 666,
+ GPG_ERR_DNS_UNKNOWN = 711,
+ GPG_ERR_DNS_SECTION = 712,
+ GPG_ERR_DNS_ADDRESS = 713,
+ GPG_ERR_DNS_NO_QUERY = 714,
+ GPG_ERR_DNS_NO_ANSWER = 715,
+ GPG_ERR_DNS_CLOSED = 716,
+ GPG_ERR_DNS_VERIFY = 717,
+ GPG_ERR_DNS_TIMEOUT = 718,
+ GPG_ERR_LDAP_GENERAL = 721,
+ GPG_ERR_LDAP_ATTR_GENERAL = 722,
+ GPG_ERR_LDAP_NAME_GENERAL = 723,
+ GPG_ERR_LDAP_SECURITY_GENERAL = 724,
+ GPG_ERR_LDAP_SERVICE_GENERAL = 725,
+ GPG_ERR_LDAP_UPDATE_GENERAL = 726,
+ GPG_ERR_LDAP_E_GENERAL = 727,
+ GPG_ERR_LDAP_X_GENERAL = 728,
+ GPG_ERR_LDAP_OTHER_GENERAL = 729,
+ GPG_ERR_LDAP_X_CONNECTING = 750,
+ GPG_ERR_LDAP_REFERRAL_LIMIT = 751,
+ GPG_ERR_LDAP_CLIENT_LOOP = 752,
+ GPG_ERR_LDAP_NO_RESULTS = 754,
+ GPG_ERR_LDAP_CONTROL_NOT_FOUND = 755,
+ GPG_ERR_LDAP_NOT_SUPPORTED = 756,
+ GPG_ERR_LDAP_CONNECT = 757,
+ GPG_ERR_LDAP_NO_MEMORY = 758,
+ GPG_ERR_LDAP_PARAM = 759,
+ GPG_ERR_LDAP_USER_CANCELLED = 760,
+ GPG_ERR_LDAP_FILTER = 761,
+ GPG_ERR_LDAP_AUTH_UNKNOWN = 762,
+ GPG_ERR_LDAP_TIMEOUT = 763,
+ GPG_ERR_LDAP_DECODING = 764,
+ GPG_ERR_LDAP_ENCODING = 765,
+ GPG_ERR_LDAP_LOCAL = 766,
+ GPG_ERR_LDAP_SERVER_DOWN = 767,
+ GPG_ERR_LDAP_SUCCESS = 768,
+ GPG_ERR_LDAP_OPERATIONS = 769,
+ GPG_ERR_LDAP_PROTOCOL = 770,
+ GPG_ERR_LDAP_TIMELIMIT = 771,
+ GPG_ERR_LDAP_SIZELIMIT = 772,
+ GPG_ERR_LDAP_COMPARE_FALSE = 773,
+ GPG_ERR_LDAP_COMPARE_TRUE = 774,
+ GPG_ERR_LDAP_UNSUPPORTED_AUTH = 775,
+ GPG_ERR_LDAP_STRONG_AUTH_RQRD = 776,
+ GPG_ERR_LDAP_PARTIAL_RESULTS = 777,
+ GPG_ERR_LDAP_REFERRAL = 778,
+ GPG_ERR_LDAP_ADMINLIMIT = 779,
+ GPG_ERR_LDAP_UNAVAIL_CRIT_EXTN = 780,
+ GPG_ERR_LDAP_CONFIDENT_RQRD = 781,
+ GPG_ERR_LDAP_SASL_BIND_INPROG = 782,
+ GPG_ERR_LDAP_NO_SUCH_ATTRIBUTE = 784,
+ GPG_ERR_LDAP_UNDEFINED_TYPE = 785,
+ GPG_ERR_LDAP_BAD_MATCHING = 786,
+ GPG_ERR_LDAP_CONST_VIOLATION = 787,
+ GPG_ERR_LDAP_TYPE_VALUE_EXISTS = 788,
+ GPG_ERR_LDAP_INV_SYNTAX = 789,
+ GPG_ERR_LDAP_NO_SUCH_OBJ = 800,
+ GPG_ERR_LDAP_ALIAS_PROBLEM = 801,
+ GPG_ERR_LDAP_INV_DN_SYNTAX = 802,
+ GPG_ERR_LDAP_IS_LEAF = 803,
+ GPG_ERR_LDAP_ALIAS_DEREF = 804,
+ GPG_ERR_LDAP_X_PROXY_AUTH_FAIL = 815,
+ GPG_ERR_LDAP_BAD_AUTH = 816,
+ GPG_ERR_LDAP_INV_CREDENTIALS = 817,
+ GPG_ERR_LDAP_INSUFFICIENT_ACC = 818,
+ GPG_ERR_LDAP_BUSY = 819,
+ GPG_ERR_LDAP_UNAVAILABLE = 820,
+ GPG_ERR_LDAP_UNWILL_TO_PERFORM = 821,
+ GPG_ERR_LDAP_LOOP_DETECT = 822,
+ GPG_ERR_LDAP_NAMING_VIOLATION = 832,
+ GPG_ERR_LDAP_OBJ_CLS_VIOLATION = 833,
+ GPG_ERR_LDAP_NOT_ALLOW_NONLEAF = 834,
+ GPG_ERR_LDAP_NOT_ALLOW_ON_RDN = 835,
+ GPG_ERR_LDAP_ALREADY_EXISTS = 836,
+ GPG_ERR_LDAP_NO_OBJ_CLASS_MODS = 837,
+ GPG_ERR_LDAP_RESULTS_TOO_LARGE = 838,
+ GPG_ERR_LDAP_AFFECTS_MULT_DSAS = 839,
+ GPG_ERR_LDAP_VLV = 844,
+ GPG_ERR_LDAP_OTHER = 848,
+ GPG_ERR_LDAP_CUP_RESOURCE_LIMIT = 881,
+ GPG_ERR_LDAP_CUP_SEC_VIOLATION = 882,
+ GPG_ERR_LDAP_CUP_INV_DATA = 883,
+ GPG_ERR_LDAP_CUP_UNSUP_SCHEME = 884,
+ GPG_ERR_LDAP_CUP_RELOAD = 885,
+ GPG_ERR_LDAP_CANCELLED = 886,
+ GPG_ERR_LDAP_NO_SUCH_OPERATION = 887,
+ GPG_ERR_LDAP_TOO_LATE = 888,
+ GPG_ERR_LDAP_CANNOT_CANCEL = 889,
+ GPG_ERR_LDAP_ASSERTION_FAILED = 890,
+ GPG_ERR_LDAP_PROX_AUTH_DENIED = 891,
+ GPG_ERR_USER_1 = 1024,
+ GPG_ERR_USER_2 = 1025,
+ GPG_ERR_USER_3 = 1026,
+ GPG_ERR_USER_4 = 1027,
+ GPG_ERR_USER_5 = 1028,
+ GPG_ERR_USER_6 = 1029,
+ GPG_ERR_USER_7 = 1030,
+ GPG_ERR_USER_8 = 1031,
+ GPG_ERR_USER_9 = 1032,
+ GPG_ERR_USER_10 = 1033,
+ GPG_ERR_USER_11 = 1034,
+ GPG_ERR_USER_12 = 1035,
+ GPG_ERR_USER_13 = 1036,
+ GPG_ERR_USER_14 = 1037,
+ GPG_ERR_USER_15 = 1038,
+ GPG_ERR_USER_16 = 1039,
+ GPG_ERR_SQL_OK = 1500,
+ GPG_ERR_SQL_ERROR = 1501,
+ GPG_ERR_SQL_INTERNAL = 1502,
+ GPG_ERR_SQL_PERM = 1503,
+ GPG_ERR_SQL_ABORT = 1504,
+ GPG_ERR_SQL_BUSY = 1505,
+ GPG_ERR_SQL_LOCKED = 1506,
+ GPG_ERR_SQL_NOMEM = 1507,
+ GPG_ERR_SQL_READONLY = 1508,
+ GPG_ERR_SQL_INTERRUPT = 1509,
+ GPG_ERR_SQL_IOERR = 1510,
+ GPG_ERR_SQL_CORRUPT = 1511,
+ GPG_ERR_SQL_NOTFOUND = 1512,
+ GPG_ERR_SQL_FULL = 1513,
+ GPG_ERR_SQL_CANTOPEN = 1514,
+ GPG_ERR_SQL_PROTOCOL = 1515,
+ GPG_ERR_SQL_EMPTY = 1516,
+ GPG_ERR_SQL_SCHEMA = 1517,
+ GPG_ERR_SQL_TOOBIG = 1518,
+ GPG_ERR_SQL_CONSTRAINT = 1519,
+ GPG_ERR_SQL_MISMATCH = 1520,
+ GPG_ERR_SQL_MISUSE = 1521,
+ GPG_ERR_SQL_NOLFS = 1522,
+ GPG_ERR_SQL_AUTH = 1523,
+ GPG_ERR_SQL_FORMAT = 1524,
+ GPG_ERR_SQL_RANGE = 1525,
+ GPG_ERR_SQL_NOTADB = 1526,
+ GPG_ERR_SQL_NOTICE = 1527,
+ GPG_ERR_SQL_WARNING = 1528,
+ GPG_ERR_SQL_ROW = 1600,
+ GPG_ERR_SQL_DONE = 1601,
+ GPG_ERR_MISSING_ERRNO = 16381,
+ GPG_ERR_UNKNOWN_ERRNO = 16382,
+ GPG_ERR_EOF = 16383,
+
+ /* The following error codes are used to map system errors. */
+#define GPG_ERR_SYSTEM_ERROR (1 << 15)
+ GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
+ GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
+ GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
+ GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
+ GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
+ GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
+ GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
+ GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
+ GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
+ GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
+ GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
+ GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
+ GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
+ GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
+ GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
+ GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
+ GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
+ GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
+ GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
+ GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
+ GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20,
+ GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
+ GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
+ GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
+ GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
+ GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
+ GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
+ GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
+ GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
+ GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
+ GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
+ GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
+ GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
+ GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
+ GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
+ GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
+ GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
+ GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
+ GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
+ GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
+ GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
+ GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
+ GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
+ GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
+ GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
+ GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
+ GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
+ GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
+ GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
+ GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
+ GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
+ GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
+ GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
+ GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
+ GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
+ GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
+ GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
+ GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
+ GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
+ GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
+ GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
+ GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
+ GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
+ GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
+ GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
+ GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
+ GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
+ GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
+ GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
+ GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
+ GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
+ GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
+ GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
+ GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
+ GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
+ GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
+ GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
+ GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
+ GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
+ GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
+ GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
+ GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
+ GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
+ GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
+ GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
+ GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
+ GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
+ GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
+ GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
+ GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
+ GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
+ GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
+ GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
+ GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
+ GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
+ GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
+ GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
+ GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
+ GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
+ GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
+ GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
+ GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
+ GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
+ GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
+ GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
+ GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
+ GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
+ GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
+ GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
+ GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
+ GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
+ GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
+ GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
+ GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
+ GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
+ GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
+ GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
+ GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
+ GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
+ GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
+ GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
+ GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
+ GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
+ GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
+ GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
+ GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
+ GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
+ GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
+ GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
+ GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
+ GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
+ GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
+ GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
+ GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
+ GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
+ GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
+ GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
+ GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
+ GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
+ GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
+ GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_CODE_DIM = 65536
+ } gpg_err_code_t;
+
+
+/* The error value type gpg_error_t. */
+
+/* We would really like to use bit-fields in a struct, but using
+ * structs as return values can cause binary compatibility issues, in
+ * particular if you want to do it efficiently (also see
+ * -freg-struct-return option to GCC). */
+typedef unsigned int gpg_error_t;
+
+/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
+ * bit indicates system errors. */
+#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
+
+/* Bits 17 to 24 are reserved. */
+
+/* We use the upper 7 bits of gpg_error_t for error sources. */
+#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
+#define GPG_ERR_SOURCE_SHIFT 24
+
+/* The highest bit is reserved. It shouldn't be used to prevent
+ * potential negative numbers when transmitting error values as
+ * text. */
+
+
+/*
+ * GCC feature test.
+ */
+#if __GNUC__
+# define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+#else
+# define _GPG_ERR_GCC_VERSION 0
+#endif
+
+#undef _GPG_ERR_HAVE_CONSTRUCTOR
+#if _GPG_ERR_GCC_VERSION > 30100
+# define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__))
+# define _GPG_ERR_HAVE_CONSTRUCTOR
+#else
+# define _GPG_ERR_CONSTRUCTOR
+#endif
+
+#define GPGRT_GCC_VERSION _GPG_ERR_GCC_VERSION
+
+#if _GPG_ERR_GCC_VERSION >= 29200
+# define _GPGRT__RESTRICT __restrict__
+#else
+# define _GPGRT__RESTRICT
+#endif
+
+/* The noreturn attribute. */
+#if _GPG_ERR_GCC_VERSION >= 20500
+# define GPGRT_ATTR_NORETURN __attribute__ ((__noreturn__))
+#else
+# define GPGRT_ATTR_NORETURN
+#endif
+
+/* The printf attributes. */
+#if _GPG_ERR_GCC_VERSION >= 40400
+# define GPGRT_ATTR_PRINTF(f, a) \
+ __attribute__ ((format(__gnu_printf__,f,a)))
+# define GPGRT_ATTR_NR_PRINTF(f, a) \
+ __attribute__ ((__noreturn__, format(__gnu_printf__,f,a)))
+#elif _GPG_ERR_GCC_VERSION >= 20500
+# define GPGRT_ATTR_PRINTF(f, a) \
+ __attribute__ ((format(printf,f,a)))
+# define GPGRT_ATTR_NR_PRINTF(f, a) \
+ __attribute__ ((__noreturn__, format(printf,f,a)))
+#else
+# define GPGRT_ATTR_PRINTF(f, a)
+# define GPGRT_ATTR_NR_PRINTF(f, a)
+#endif
+#if _GPG_ERR_GCC_VERSION >= 20800
+# define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
+#else
+# define GPGRT_ATTR_FORMAT_ARG(a)
+#endif
+
+/* The sentinel attribute. */
+#if _GPG_ERR_GCC_VERSION >= 40000
+# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
+#else
+# define GPGRT_ATTR_SENTINEL(a)
+#endif
+
+/* The used and unused attributes.
+ * I am not sure since when the unused attribute is really supported.
+ * In any case it it only needed for gcc versions which print a
+ * warning. Thus let us require gcc >= 3.5. */
+#if _GPG_ERR_GCC_VERSION >= 40000
+# define GPGRT_ATTR_USED __attribute__ ((used))
+#else
+# define GPGRT_ATTR_USED
+#endif
+#if _GPG_ERR_GCC_VERSION >= 30500
+# define GPGRT_ATTR_UNUSED __attribute__ ((unused))
+#else
+# define GPGRT_ATTR_UNUSED
+#endif
+
+/* The deprecated attribute. */
+#if _GPG_ERR_GCC_VERSION >= 30100
+# define GPGRT_ATTR_DEPRECATED __attribute__ ((__deprecated__))
+#else
+# define GPGRT_ATTR_DEPRECATED
+#endif
+
+/* The pure attribute. */
+#if _GPG_ERR_GCC_VERSION >= 29600
+# define GPGRT_ATTR_PURE __attribute__ ((__pure__))
+#else
+# define GPGRT_ATTR_PURE
+#endif
+
+/* The malloc attribute. */
+#if _GPG_ERR_GCC_VERSION >= 30200
+# define GPGRT_ATTR_MALLOC __attribute__ ((__malloc__))
+#else
+# define GPGRT_ATTR_MALLOC
+#endif
+
+/* A macro defined if a GCC style __FUNCTION__ macro is available. */
+#undef GPGRT_HAVE_MACRO_FUNCTION
+#if _GPG_ERR_GCC_VERSION >= 20500
+# define GPGRT_HAVE_MACRO_FUNCTION 1
+#endif
+
+/* A macro defined if the pragma GCC push_options is available. */
+#undef GPGRT_HAVE_PRAGMA_GCC_PUSH
+#if _GPG_ERR_GCC_VERSION >= 40400
+# define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
+#endif
+
+/* Detect LeakSanitizer (LSan) support for GCC and Clang based on
+ * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address).
+ * Note that -fsanitize=leak just affect the linker options which
+ * cannot be detected here. In that case you have to define the
+ * GPGRT_HAVE_LEAK_SANITIZER macro manually. */
+#ifdef __GNUC__
+# ifdef __SANITIZE_ADDRESS__
+# define GPGRT_HAVE_LEAK_SANITIZER
+# elif defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define GPGRT_HAVE_LEAK_SANITIZER
+# endif
+# endif
+#endif
+
+
+/* The new name for the inline macro. */
+#define GPGRT_INLINE GPG_ERR_INLINE
+
+#ifdef GPGRT_HAVE_LEAK_SANITIZER
+# include <sanitizer/lsan_interface.h>
+#endif
+
+/* Mark heap objects as non-leaked memory. */
+static GPGRT_INLINE void
+gpgrt_annotate_leaked_object (const void *p)
+{
+#ifdef GPGRT_HAVE_LEAK_SANITIZER
+ __lsan_ignore_object(p);
+#else
+ (void)p;
+#endif
+}
+
+
+/*
+ * Initialization function.
+ */
+
+/* Initialize the library. This function should be run early. */
+gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR;
+
+/* If this is defined, the library is already initialized by the
+ constructor and does not need to be initialized explicitely. */
+#undef GPG_ERR_INITIALIZED
+#ifdef _GPG_ERR_HAVE_CONSTRUCTOR
+# define GPG_ERR_INITIALIZED 1
+# define gpgrt_init() do { gpg_err_init (); } while (0)
+#else
+# define gpgrt_init() do { ; } while (0)
+#endif
+
+/* See the source on how to use the deinit function; it is usually not
+ required. */
+void gpg_err_deinit (int mode);
+
+/* Register blocking system I/O clamping functions. */
+void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void));
+
+/* Get current I/O clamping functions. */
+void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void));
+
+/* Register a custom malloc/realloc/free function. */
+void gpgrt_set_alloc_func (void *(*f)(void *a, size_t n));
+
+/* Register an emergency cleanup handler. */
+void gpgrt_add_emergency_cleanup (void (*f)(void));
+
+/* Wrapper around abort to make sure emergency cleanups are run. */
+void gpgrt_abort (void) GPGRT_ATTR_NORETURN;
+
+
+
+/*
+ * Constructor and accessor functions.
+ */
+
+/* Construct an error value from an error code and source. Within a
+ * subsystem, use gpg_error. */
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
+{
+ return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
+ : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
+ | (code & GPG_ERR_CODE_MASK));
+}
+
+
+/* The user should define GPG_ERR_SOURCE_DEFAULT before including this
+ * file to specify a default source for gpg_error. */
+#ifndef GPG_ERR_SOURCE_DEFAULT
+#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
+#endif
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error (gpg_err_code_t code)
+{
+ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
+}
+
+
+/* Retrieve the error code from an error value. */
+static GPG_ERR_INLINE gpg_err_code_t
+gpg_err_code (gpg_error_t err)
+{
+ return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
+}
+
+
+/* Retrieve the error source from an error value. */
+static GPG_ERR_INLINE gpg_err_source_t
+gpg_err_source (gpg_error_t err)
+{
+ return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
+ & GPG_ERR_SOURCE_MASK);
+}
+
+
+/* String functions. */
+
+/* Return a pointer to a string containing a description of the error
+ * code in the error value ERR. This function is not thread-safe. */
+const char *gpg_strerror (gpg_error_t err);
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ * size BUFLEN. This function is, in contrast to gpg_strerror,
+ * thread-safe if a thread-safe strerror_r() function is provided by
+ * the system. If the function succeeds, 0 is returned and BUF
+ * contains the string describing the error. If the buffer was not
+ * large enough, ERANGE is returned and BUF contains as much of the
+ * beginning of the error string as fits into the buffer. */
+int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+
+/* Return a pointer to a string containing a description of the error
+ * source in the error value ERR. */
+const char *gpg_strsource (gpg_error_t err);
+
+
+/*
+ * Mapping of system errors (errno).
+ */
+
+/* Retrieve the error code for the system error ERR. This returns
+ * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ * this). */
+gpg_err_code_t gpg_err_code_from_errno (int err);
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ * if CODE is not a system error code. */
+int gpg_err_code_to_errno (gpg_err_code_t code);
+
+/* Retrieve the error code directly from the ERRNO variable. This
+ * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
+ * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
+gpg_err_code_t gpg_err_code_from_syserror (void);
+
+/* Mapper for SQLite primary error codes. */
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_code_from_sqlite (int sqlres)
+{
+ return sqlres? GPG_ERR_SQL_OK + (sqlres & 0xff) : 0;
+}
+
+
+/* Set the ERRNO variable. This function is the preferred way to set
+ * ERRNO due to peculiarities on WindowsCE. */
+void gpg_err_set_errno (int err);
+
+/* Return or check the version. Both functions are identical. */
+const char *gpgrt_check_version (const char *req_version);
+const char *gpg_error_check_version (const char *req_version);
+
+/* System specific type definitions. */
+#include <sys/types.h>
+
+typedef ssize_t gpgrt_ssize_t;
+
+typedef long gpgrt_off_t;
+
+
+
+
+/* Self-documenting convenience functions. */
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_err_make (source, gpg_err_code_from_errno (err));
+}
+
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_errno (int err)
+{
+ return gpg_error (gpg_err_code_from_errno (err));
+}
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_syserror (void)
+{
+ return gpg_error (gpg_err_code_from_syserror ());
+}
+
+
+
+/*
+ * Malloc and friends
+ */
+
+void *gpgrt_realloc (void *a, size_t n);
+void *gpgrt_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size);
+void *gpgrt_malloc (size_t n);
+void *gpgrt_calloc (size_t n, size_t m);
+char *gpgrt_strdup (const char *string);
+char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
+void gpgrt_free (void *a);
+
+
+/*
+ * System specific function wrappers.
+ */
+
+/* A getenv replacement which mallocs the returned string. */
+char *gpgrt_getenv (const char *name);
+
+/* A setenv and a unsetenv replacement.*/
+gpg_err_code_t gpgrt_setenv (const char *name,
+ const char *value, int overwrite);
+#define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1)
+
+/* A wrapper around mkdir using a string for the mode. */
+gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr);
+
+/* A simple wrapper around chdir. */
+gpg_err_code_t gpgrt_chdir (const char *name);
+
+/* Return the current WD as a malloced string. */
+char *gpgrt_getcwd (void);
+
+/* A wrapper around access to handle UTF-8 on Windows. */
+gpg_err_code_t gpgrt_access (const char *fname, int mode);
+
+
+
+
+/*
+ * Lock functions.
+ */
+
+
+typedef struct
+{
+ long _vers;
+ union {
+ volatile char _priv[40];
+ long _x_align;
+ long *_xp_align;
+ } u;
+} gpgrt_lock_t;
+
+#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
+ 0,0,0,0,0,0,0,0, \
+ 0,0,0,0,0,0,0,0, \
+ 0,0,0,0,0,0,0,0, \
+ 0,0,0,0,0,0,0,0}}}
+
+
+#define GPGRT_LOCK_DEFINE(name) \
+ static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER
+
+/* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
+ before passing it to gpgrt_lock_init. */
+gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
+gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
+gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd);
+gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
+gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
+
+
+
+/*
+ * Thread functions.
+ */
+
+gpg_err_code_t gpgrt_yield (void);
+
+
+
+
+/*
+ * Estream
+ */
+
+/* The definition of this struct is entirely private. You must not
+ use it for anything. It is only here so some functions can be
+ implemented as macros. */
+struct _gpgrt_stream_internal;
+struct _gpgrt__stream
+{
+ /* The layout of this struct must never change. It may be grown,
+ but only if all functions which access the new members are
+ versioned. */
+
+ /* Various flags. */
+ struct {
+ unsigned int magic: 16;
+ unsigned int writing: 1;
+ unsigned int reserved: 15;
+ } flags;
+
+ /* A pointer to the stream buffer. */
+ unsigned char *buffer;
+
+ /* The size of the buffer in bytes. */
+ size_t buffer_size;
+
+ /* The length of the usable data in the buffer, only valid when in
+ read mode (see flags). */
+ size_t data_len;
+
+ /* The current position of the offset pointer, valid in read and
+ write mode. */
+ size_t data_offset;
+
+ size_t data_flushed;
+ unsigned char *unread_buffer;
+ size_t unread_buffer_size;
+
+ /* The number of unread bytes. */
+ size_t unread_data_len;
+
+ /* A pointer to our internal data for this stream. */
+ struct _gpgrt_stream_internal *intern;
+};
+
+/* The opaque type for an estream. */
+typedef struct _gpgrt__stream *gpgrt_stream_t;
+#ifdef GPGRT_ENABLE_ES_MACROS
+typedef struct _gpgrt__stream *estream_t;
+#endif
+
+typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie,
+ void *buffer, size_t size);
+typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie,
+ const void *buffer,
+ size_t size);
+typedef int (*gpgrt_cookie_seek_function_t) (void *cookie,
+ gpgrt_off_t *pos, int whence);
+typedef int (*gpgrt_cookie_close_function_t) (void *cookie);
+
+struct _gpgrt_cookie_io_functions
+{
+ gpgrt_cookie_read_function_t func_read;
+ gpgrt_cookie_write_function_t func_write;
+ gpgrt_cookie_seek_function_t func_seek;
+ gpgrt_cookie_close_function_t func_close;
+};
+typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t;
+#ifdef GPGRT_ENABLE_ES_MACROS
+typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t;
+#define es_cookie_read_function_t gpgrt_cookie_read_function_t
+#define es_cookie_write_function_t gpgrt_cookie_read_function_t
+#define es_cookie_seek_function_t gpgrt_cookie_read_function_t
+#define es_cookie_close_function_t gpgrt_cookie_read_function_t
+#endif
+
+enum gpgrt_syshd_types
+ {
+ GPGRT_SYSHD_NONE = 0, /* No system handle available. */
+ GPGRT_SYSHD_FD = 1, /* A file descriptor as returned by open(). */
+ GPGRT_SYSHD_SOCK = 2, /* A socket as returned by socket(). */
+ GPGRT_SYSHD_RVID = 3, /* A rendezvous id (see libassuan's gpgcedev.c). */
+ GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows). */
+ };
+
+struct _gpgrt_syshd
+{
+ enum gpgrt_syshd_types type;
+ union {
+ int fd;
+ int sock;
+ int rvid;
+ void *handle;
+ } u;
+};
+typedef struct _gpgrt_syshd gpgrt_syshd_t;
+#ifdef GPGRT_ENABLE_ES_MACROS
+typedef struct _gpgrt_syshd es_syshd_t;
+#define ES_SYSHD_NONE GPGRT_SYSHD_NONE
+#define ES_SYSHD_FD GPGRT_SYSHD_FD
+#define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK
+#define ES_SYSHD_RVID GPGRT_SYSHD_RVID
+#define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE
+#endif
+
+/* The object used with gpgrt_poll. */
+struct _gpgrt_poll_s
+{
+ gpgrt_stream_t stream;
+ unsigned int want_read:1;
+ unsigned int want_write:1;
+ unsigned int want_oob:1;
+ unsigned int want_rdhup:1;
+ unsigned int _reserv1:4;
+ unsigned int got_read:1;
+ unsigned int got_write:1;
+ unsigned int got_oob:1;
+ unsigned int got_rdhup:1;
+ unsigned int _reserv2:4;
+ unsigned int got_err:1;
+ unsigned int got_hup:1;
+ unsigned int got_nval:1;
+ unsigned int _reserv3:4;
+ unsigned int ignore:1;
+ unsigned int user:8; /* For application use. */
+};
+typedef struct _gpgrt_poll_s gpgrt_poll_t;
+#ifdef GPGRT_ENABLE_ES_MACROS
+typedef struct _gpgrt_poll_s es_poll_t;
+#endif
+
+/* The type of the string filter function as used by fprintf_sf et al. */
+typedef char *(*gpgrt_string_filter_t) (const char *s, int n, void *opaque);
+
+
+
+gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path,
+ const char *_GPGRT__RESTRICT mode);
+gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data,
+ size_t data_n, size_t data_len,
+ unsigned int grow,
+ void *(*func_realloc) (void *mem, size_t size),
+ void (*func_free) (void *mem),
+ const char *_GPGRT__RESTRICT mode);
+gpgrt_stream_t gpgrt_fopenmem (size_t memlimit,
+ const char *_GPGRT__RESTRICT mode);
+gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit,
+ const char *_GPGRT__RESTRICT mode,
+ const void *data, size_t datalen);
+gpgrt_stream_t gpgrt_fdopen (int filedes, const char *mode);
+gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode);
+gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const char *mode);
+gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode);
+gpgrt_stream_t gpgrt_fpopen (FILE *fp, const char *mode);
+gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode);
+gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path,
+ const char *_GPGRT__RESTRICT mode,
+ gpgrt_stream_t _GPGRT__RESTRICT stream);
+gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie,
+ const char *_GPGRT__RESTRICT mode,
+ gpgrt_cookie_io_functions_t functions);
+int gpgrt_fclose (gpgrt_stream_t stream);
+int gpgrt_fcancel (gpgrt_stream_t stream);
+int gpgrt_fclose_snatch (gpgrt_stream_t stream,
+ void **r_buffer, size_t *r_buflen);
+int gpgrt_onclose (gpgrt_stream_t stream, int mode,
+ void (*fnc) (gpgrt_stream_t, void*), void *fnc_value);
+int gpgrt_fileno (gpgrt_stream_t stream);
+int gpgrt_fileno_unlocked (gpgrt_stream_t stream);
+int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
+int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd);
+
+void _gpgrt_set_std_fd (int no, int fd);
+gpgrt_stream_t _gpgrt_get_std_stream (int fd);
+
+#define gpgrt_stdin _gpgrt_get_std_stream (0)
+#define gpgrt_stdout _gpgrt_get_std_stream (1)
+#define gpgrt_stderr _gpgrt_get_std_stream (2)
+
+
+void gpgrt_flockfile (gpgrt_stream_t stream);
+int gpgrt_ftrylockfile (gpgrt_stream_t stream);
+void gpgrt_funlockfile (gpgrt_stream_t stream);
+
+int gpgrt_feof (gpgrt_stream_t stream);
+int gpgrt_feof_unlocked (gpgrt_stream_t stream);
+int gpgrt_ferror (gpgrt_stream_t stream);
+int gpgrt_ferror_unlocked (gpgrt_stream_t stream);
+void gpgrt_clearerr (gpgrt_stream_t stream);
+void gpgrt_clearerr_unlocked (gpgrt_stream_t stream);
+
+int _gpgrt_pending (gpgrt_stream_t stream); /* (private) */
+int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */
+
+#define gpgrt_pending(stream) _gpgrt_pending (stream)
+
+#define gpgrt_pending_unlocked(stream) \
+ (((!(stream)->flags.writing) \
+ && (((stream)->data_offset < (stream)->data_len) \
+ || ((stream)->unread_data_len))) \
+ ? 1 : _gpgrt_pending_unlocked ((stream)))
+
+int gpgrt_fflush (gpgrt_stream_t stream);
+int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence);
+int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence);
+int gpgrt_ftruncate (gpgrt_stream_t stream, gpgrt_off_t length);
+long int gpgrt_ftell (gpgrt_stream_t stream);
+gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream);
+void gpgrt_rewind (gpgrt_stream_t stream);
+
+int gpgrt_fgetc (gpgrt_stream_t stream);
+int gpgrt_fputc (int c, gpgrt_stream_t stream);
+
+int _gpgrt_getc_underflow (gpgrt_stream_t stream); /* (private) */
+int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */
+
+#define gpgrt_getc_unlocked(stream) \
+ (((!(stream)->flags.writing) \
+ && ((stream)->data_offset < (stream)->data_len) \
+ && (! (stream)->unread_data_len)) \
+ ? ((int) (stream)->buffer[((stream)->data_offset)++]) \
+ : _gpgrt_getc_underflow ((stream)))
+
+#define gpgrt_putc_unlocked(c, stream) \
+ (((stream)->flags.writing \
+ && ((stream)->data_offset < (stream)->buffer_size) \
+ && (c != '\n')) \
+ ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \
+ : _gpgrt_putc_overflow ((c), (stream)))
+
+#define gpgrt_getc(stream) gpgrt_fgetc (stream)
+#define gpgrt_putc(c, stream) gpgrt_fputc (c, stream)
+
+int gpgrt_ungetc (int c, gpgrt_stream_t stream);
+
+int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ void *_GPGRT__RESTRICT buffer, size_t bytes_to_read,
+ size_t *_GPGRT__RESTRICT bytes_read);
+int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write,
+ size_t *_GPGRT__RESTRICT bytes_written);
+int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const void *_GPGRT__RESTRICT buffer, size_t length,
+ const char *delimiters,
+ size_t *_GPGRT__RESTRICT bytes_written);
+int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const void *_GPGRT__RESTRICT buffer, size_t length,
+ int reserved,
+ size_t *_GPGRT__RESTRICT bytes_written);
+
+size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems,
+ gpgrt_stream_t _GPGRT__RESTRICT stream);
+size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size,
+ size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream);
+
+char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n,
+ gpgrt_stream_t _GPGRT__RESTRICT stream);
+int gpgrt_fputs (const char *_GPGRT__RESTRICT s,
+ gpgrt_stream_t _GPGRT__RESTRICT stream);
+int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s,
+ gpgrt_stream_t _GPGRT__RESTRICT stream);
+
+ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr,
+ size_t *_GPGRT__RESTRICT n,
+ gpgrt_stream_t stream);
+ssize_t gpgrt_read_line (gpgrt_stream_t stream,
+ char **addr_of_buffer, size_t *length_of_buffer,
+ size_t *max_length);
+
+int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const char *_GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(2,3);
+int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const char *_GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(2,3);
+
+int gpgrt_fprintf_sf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ gpgrt_string_filter_t sf, void *sfvalue,
+ const char *_GPGRT__RESTRICT format,
+ ...) GPGRT_ATTR_PRINTF(4,5);
+int gpgrt_fprintf_sf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ gpgrt_string_filter_t sf, void *sfvalue,
+ const char *_GPGRT__RESTRICT format,
+ ...) GPGRT_ATTR_PRINTF(4,5);
+
+int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(1,2);
+int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(1,2);
+
+int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const char *_GPGRT__RESTRICT format, va_list ap)
+ GPGRT_ATTR_PRINTF(2,0);
+int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ const char *_GPGRT__RESTRICT format, va_list ap)
+ GPGRT_ATTR_PRINTF(2,0);
+
+int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ char *_GPGRT__RESTRICT buf, int mode, size_t size);
+void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ char *_GPGRT__RESTRICT buf);
+
+void gpgrt_set_binary (gpgrt_stream_t stream);
+int gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff);
+int gpgrt_get_nonblock (gpgrt_stream_t stream);
+
+int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout);
+
+gpgrt_stream_t gpgrt_tmpfile (void);
+
+void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream,
+ void *_GPGRT__RESTRICT opaque);
+void *gpgrt_opaque_get (gpgrt_stream_t stream);
+
+void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
+const char *gpgrt_fname_get (gpgrt_stream_t stream);
+
+int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(2,3);
+int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
+ va_list ap)
+ GPGRT_ATTR_PRINTF(2,0);
+char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(1,2);
+char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
+ GPGRT_ATTR_PRINTF(1,0);
+int gpgrt_snprintf (char *buf, size_t bufsize,
+ const char * _GPGRT__RESTRICT format, ...)
+ GPGRT_ATTR_PRINTF(3,4);
+int gpgrt_vsnprintf (char *buf,size_t bufsize,
+ const char * _GPGRT__RESTRICT format, va_list arg_ptr)
+ GPGRT_ATTR_PRINTF(3,0);
+
+
+#ifdef GPGRT_ENABLE_ES_MACROS
+# define es_fopen gpgrt_fopen
+# define es_mopen gpgrt_mopen
+# define es_fopenmem gpgrt_fopenmem
+# define es_fopenmem_init gpgrt_fopenmem_init
+# define es_fdopen gpgrt_fdopen
+# define es_fdopen_nc gpgrt_fdopen_nc
+# define es_sysopen gpgrt_sysopen
+# define es_sysopen_nc gpgrt_sysopen_nc
+# define es_fpopen gpgrt_fpopen
+# define es_fpopen_nc gpgrt_fpopen_nc
+# define es_freopen gpgrt_freopen
+# define es_fopencookie gpgrt_fopencookie
+# define es_fclose gpgrt_fclose
+# define es_fclose_snatch gpgrt_fclose_snatch
+# define es_onclose gpgrt_onclose
+# define es_fileno gpgrt_fileno
+# define es_fileno_unlocked gpgrt_fileno_unlocked
+# define es_syshd gpgrt_syshd
+# define es_syshd_unlocked gpgrt_syshd_unlocked
+# define es_stdin _gpgrt_get_std_stream (0)
+# define es_stdout _gpgrt_get_std_stream (1)
+# define es_stderr _gpgrt_get_std_stream (2)
+# define es_flockfile gpgrt_flockfile
+# define es_ftrylockfile gpgrt_ftrylockfile
+# define es_funlockfile gpgrt_funlockfile
+# define es_feof gpgrt_feof
+# define es_feof_unlocked gpgrt_feof_unlocked
+# define es_ferror gpgrt_ferror
+# define es_ferror_unlocked gpgrt_ferror_unlocked
+# define es_clearerr gpgrt_clearerr
+# define es_clearerr_unlocked gpgrt_clearerr_unlocked
+# define es_pending gpgrt_pending
+# define es_pending_unlocked gpgrt_pending_unlocked
+# define es_fflush gpgrt_fflush
+# define es_fseek gpgrt_fseek
+# define es_fseeko gpgrt_fseeko
+# define es_ftruncate gpgrt_ftruncate
+# define es_ftell gpgrt_ftell
+# define es_ftello gpgrt_ftello
+# define es_rewind gpgrt_rewind
+# define es_fgetc gpgrt_fgetc
+# define es_fputc gpgrt_fputc
+# define es_getc_unlocked gpgrt_getc_unlocked
+# define es_putc_unlocked gpgrt_putc_unlocked
+# define es_getc gpgrt_getc
+# define es_putc gpgrt_putc
+# define es_ungetc gpgrt_ungetc
+# define es_read gpgrt_read
+# define es_write gpgrt_write
+# define es_write_sanitized gpgrt_write_sanitized
+# define es_write_hexstring gpgrt_write_hexstring
+# define es_fread gpgrt_fread
+# define es_fwrite gpgrt_fwrite
+# define es_fgets gpgrt_fgets
+# define es_fputs gpgrt_fputs
+# define es_fputs_unlocked gpgrt_fputs_unlocked
+# define es_getline gpgrt_getline
+# define es_read_line gpgrt_read_line
+# define es_free gpgrt_free
+# define es_fprintf gpgrt_fprintf
+# define es_fprintf_unlocked gpgrt_fprintf_unlocked
+# define es_printf gpgrt_printf
+# define es_printf_unlocked gpgrt_printf_unlocked
+# define es_vfprintf gpgrt_vfprintf
+# define es_vfprintf_unlocked gpgrt_vfprintf_unlocked
+# define es_setvbuf gpgrt_setvbuf
+# define es_setbuf gpgrt_setbuf
+# define es_set_binary gpgrt_set_binary
+# define es_set_nonblock gpgrt_set_nonblock
+# define es_get_nonblock gpgrt_get_nonblock
+# define es_poll gpgrt_poll
+# define es_tmpfile gpgrt_tmpfile
+# define es_opaque_set gpgrt_opaque_set
+# define es_opaque_get gpgrt_opaque_get
+# define es_fname_set gpgrt_fname_set
+# define es_fname_get gpgrt_fname_get
+# define es_asprintf gpgrt_asprintf
+# define es_vasprintf gpgrt_vasprintf
+# define es_bsprintf gpgrt_bsprintf
+# define es_vbsprintf gpgrt_vbsprintf
+#endif /*GPGRT_ENABLE_ES_MACROS*/
+
+
+
+/*
+ * Base64 encode and decode functions.
+ */
+
+struct _gpgrt_b64state;
+typedef struct _gpgrt_b64state *gpgrt_b64state_t;
+
+gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title);
+gpg_err_code_t gpgrt_b64enc_write (gpgrt_b64state_t state,
+ const void *buffer, size_t nbytes);
+gpg_err_code_t gpgrt_b64enc_finish (gpgrt_b64state_t state);
+
+gpgrt_b64state_t gpgrt_b64dec_start (const char *title);
+gpg_error_t gpgrt_b64dec_proc (gpgrt_b64state_t state,
+ void *buffer, size_t length,
+ size_t *r_nbytes);
+gpg_error_t gpgrt_b64dec_finish (gpgrt_b64state_t state);
+
+
+
+/*
+ * Logging functions
+ */
+
+/* Flag values for gpgrt_log_set_prefix. */
+#define GPGRT_LOG_WITH_PREFIX 1
+#define GPGRT_LOG_WITH_TIME 2
+#define GPGRT_LOG_WITH_PID 4
+#define GPGRT_LOG_RUN_DETACHED 256
+#define GPGRT_LOG_NO_REGISTRY 512
+
+/* Log levels as used by gpgrt_log. */
+enum gpgrt_log_levels
+ {
+ GPGRT_LOGLVL_BEGIN,
+ GPGRT_LOGLVL_CONT,
+ GPGRT_LOGLVL_INFO,
+ GPGRT_LOGLVL_WARN,
+ GPGRT_LOGLVL_ERROR,
+ GPGRT_LOGLVL_FATAL,
+ GPGRT_LOGLVL_BUG,
+ GPGRT_LOGLVL_DEBUG
+ };
+
+
+/* The next 4 functions are not thread-safe - call them early. */
+void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd);
+void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void));
+void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
+void gpgrt_log_set_prefix (const char *text, unsigned int flags);
+
+int gpgrt_get_errorcount (int clear);
+void gpgrt_inc_errorcount (void);
+const char *gpgrt_log_get_prefix (unsigned int *flags);
+int gpgrt_log_test_fd (int fd);
+int gpgrt_log_get_fd (void);
+gpgrt_stream_t gpgrt_log_get_stream (void);
+
+void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
+void gpgrt_logv (int level, const char *fmt, va_list arg_ptr);
+void gpgrt_logv_prefix (int level, const char *prefix,
+ const char *fmt, va_list arg_ptr);
+void gpgrt_log_string (int level, const char *string);
+void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
+void gpgrt_log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2);
+void gpgrt_log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
+void gpgrt_log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
+void gpgrt_log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
+void gpgrt_log_debug_string (const char *string,
+ const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3);
+void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
+void gpgrt_log_printhex (const void *buffer, size_t length,
+ const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4);
+void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
+void gpgrt_log_flush (void);
+void _gpgrt_log_assert (const char *expr, const char *file, int line,
+ const char *func) GPGRT_ATTR_NORETURN;
+
+#ifdef GPGRT_HAVE_MACRO_FUNCTION
+# define gpgrt_assert(expr) \
+ ((expr) \
+ ? (void) 0 \
+ : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
+#else /*!GPGRT_HAVE_MACRO_FUNCTION*/
+# define gpgrt_assert(expr) \
+ ((expr) \
+ ? (void) 0 \
+ : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
+#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
+
+#ifdef GPGRT_ENABLE_LOG_MACROS
+# define log_get_errorcount gpgrt_get_errorcount
+# define log_inc_errorcount gpgrt_inc_errorcount
+# define log_set_file(a) gpgrt_log_set_sink ((a), NULL, -1)
+# define log_set_fd(a) gpgrt_log_set_sink (NULL, NULL, (a))
+# define log_set_stream(a) gpgrt_log_set_sink (NULL, (a), -1)
+# define log_set_socket_dir_cb gpgrt_log_set_socket_dir_cb
+# define log_set_pid_suffix_cb gpgrt_log_set_pid_suffix_cb
+# define log_set_prefix gpgrt_log_set_prefix
+# define log_get_prefix gpgrt_log_get_prefix
+# define log_test_fd gpgrt_log_test_fd
+# define log_get_fd gpgrt_log_get_fd
+# define log_get_stream gpgrt_log_get_stream
+# define log_log gpgrt_log
+# define log_logv gpgrt_logv
+# define log_logv_prefix gpgrt_logv_prefix
+# define log_string gpgrt_log_string
+# define log_bug gpgrt_log_bug
+# define log_fatal gpgrt_log_fatal
+# define log_error gpgrt_log_error
+# define log_info gpgrt_log_info
+# define log_debug gpgrt_log_debug
+# define log_debug_string gpgrt_log_debug_string
+# define log_printf gpgrt_log_printf
+# define log_printhex gpgrt_log_printhex
+# define log_clock gpgrt_log_clock
+# define log_flush gpgrt_log_flush
+# ifdef GPGRT_HAVE_MACRO_FUNCTION
+# define log_assert(expr) \
+ ((expr) \
+ ? (void) 0 \
+ : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
+# else /*!GPGRT_HAVE_MACRO_FUNCTION*/
+# define log_assert(expr) \
+ ((expr) \
+ ? (void) 0 \
+ : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL))
+# endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
+
+#endif /*GPGRT_ENABLE_LOG_MACROS*/
+
+
+/*
+ * Spawn functions (Not yet available)
+ */
+#define GPGRT_SPAWN_NONBLOCK 16 /* Set the streams to non-blocking. */
+#define GPGRT_SPAWN_RUN_ASFW 64 /* Use AllowSetForegroundWindow on W32. */
+#define GPGRT_SPAWN_DETACHED 128 /* Start the process in the background. */
+
+#if 0
+
+/* Function and convenience macros to create pipes. */
+gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp,
+ int direction, int nonblock);
+#define gpgrt_create_pipe(a) gpgrt_make_pipe ((a),NULL, 0, 0);
+#define gpgrt_create_inbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), -1,(c));
+#define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), 1,(c));
+
+
+/* Fork and exec PGMNAME. */
+gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[],
+ int *execpt, void (*preexec)(void),
+ unsigned int flags,
+ gpgrt_stream_t *r_infp,
+ gpgrt_stream_t *r_outfp,
+ gpgrt_stream_t *r_errfp,
+ pid_t *pid);
+
+/* Fork and exec PGNNAME and connect the process to the given FDs. */
+gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
+ int infd, int outfd, int errfd,
+ pid_t *pid);
+
+/* Fork and exec PGMNAME as a detached process. */
+gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname,
+ const char *argv[],
+ const char *envp[] );
+
+/* Wait for a single process. */
+gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
+ int *r_exitcode);
+
+/* Wait for a multiple processes. */
+gpg_err_code_t gpgrt_wait_processes (const char **pgmnames, pid_t *pids,
+ size_t count, int hang, int *r_exitcodes);
+
+/* Kill the process identified by PID. */
+void gpgrt_kill_process (pid_t pid);
+
+/* Release process resources identified by PID. */
+void gpgrt_release_process (pid_t pid);
+
+#endif /*0*/
+
+
+
+/*
+ * Option parsing.
+ */
+
+struct _gpgrt_argparse_internal_s;
+typedef struct
+{
+ int *argc; /* Pointer to ARGC (value subject to change). */
+ char ***argv; /* Pointer to ARGV (value subject to change). */
+ unsigned int flags; /* Global flags. May be set prior to calling the
+ parser. The parser may change the value. */
+ int err; /* Print error description for last option.
+ Either 0, ARGPARSE_PRINT_WARNING or
+ ARGPARSE_PRINT_ERROR. */
+ unsigned int lineno;/* The current line number. */
+ int r_opt; /* Returns option code. */
+ int r_type; /* Returns type of option value. */
+ union {
+ int ret_int;
+ long ret_long;
+ unsigned long ret_ulong;
+ char *ret_str;
+ } r; /* Return values */
+
+ struct _gpgrt_argparse_internal_s *internal;
+} gpgrt_argparse_t;
+
+
+typedef struct
+{
+ int short_opt;
+ const char *long_opt;
+ unsigned int flags;
+ const char *description; /* Optional description. */
+} gpgrt_opt_t;
+
+
+#ifdef GPGRT_ENABLE_ARGPARSE_MACROS
+
+/* Global flags for (gpgrt_argparse_t).flags. */
+#define ARGPARSE_FLAG_KEEP 1 /* Do not remove options form argv. */
+#define ARGPARSE_FLAG_ALL 2 /* Do not stop at last option but return
+ remaining args with R_OPT set to -1. */
+#define ARGPARSE_FLAG_MIXED 4 /* Assume options and args are mixed. */
+#define ARGPARSE_FLAG_NOSTOP 8 /* Do not stop processing at "--". */
+#define ARGPARSE_FLAG_ARG0 16 /* Do not skip the first arg. */
+#define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */
+#define ARGPARSE_FLAG_NOVERSION 64 /* No output for "--version". */
+#define ARGPARSE_FLAG_RESET 128 /* Request to reset the internal state. */
+#define ARGPARSE_FLAG_STOP_SEEN 256 /* Set to true if a "--" has been seen. */
+#define ARGPARSE_FLAG_NOLINENO 512 /* Do not zero the lineno field. */
+#define ARGPARSE_FLAG_SYS 1024 /* Use system config file. */
+#define ARGPARSE_FLAG_USER 2048 /* Use user config file. */
+#define ARGPARSE_FLAG_VERBOSE 4096 /* Print additional argparser info. */
+#define ARGPARSE_FLAG_USERVERS 8192 /* Try version-ed user config files. */
+#define ARGPARSE_FLAG_WITHATTR 16384 /* Return attribute bits. */
+
+/* Constants for (gpgrt_argparse_t).err. */
+#define ARGPARSE_PRINT_WARNING 1 /* Print a diagnostic. */
+#define ARGPARSE_PRINT_ERROR 2 /* Print a diagnostic and call exit. */
+
+/* Special return values of gpgrt_argparse. */
+#define ARGPARSE_IS_ARG (-1)
+#define ARGPARSE_INVALID_OPTION (-2)
+#define ARGPARSE_MISSING_ARG (-3)
+#define ARGPARSE_KEYWORD_TOO_LONG (-4)
+#define ARGPARSE_READ_ERROR (-5)
+#define ARGPARSE_UNEXPECTED_ARG (-6)
+#define ARGPARSE_INVALID_COMMAND (-7)
+#define ARGPARSE_AMBIGUOUS_OPTION (-8)
+#define ARGPARSE_AMBIGUOUS_COMMAND (-9)
+#define ARGPARSE_INVALID_ALIAS (-10)
+#define ARGPARSE_OUT_OF_CORE (-11)
+#define ARGPARSE_INVALID_ARG (-12)
+#define ARGPARSE_PERMISSION_ERROR (-13)
+#define ARGPARSE_NO_CONFFILE (-14)
+#define ARGPARSE_CONFFILE (-15)
+#define ARGPARSE_INVALID_META (-16)
+#define ARGPARSE_UNKNOWN_META (-17)
+#define ARGPARSE_UNEXPECTED_META (-18)
+
+/* Flags for the option descriptor (gpgrt_opt_t)->flags. Note that a
+ * TYPE constant may be or-ed with the OPT constants but when used as
+ * return value in r_type these OPT constants are normally not
+ * included. However with ARGPARSE_FLAG_WITHATTR used and an option
+ * would normally not be returned, it is returned but
+ * ARGPARSE_OPT_IGNORE is then set; further ARPARSE_ATTR_* are set.
+ */
+#define ARGPARSE_TYPE_MASK 0x0007 /* Mask for the type bits. */
+#define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */
+#define ARGPARSE_TYPE_INT 1 /* Takes an int argument. */
+#define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */
+#define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */
+#define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */
+#define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */
+#define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */
+#define ARGPARSE_OPT_IGNORE (1<<6) /* Ignore command or option. */
+#define ARGPARSE_OPT_COMMAND (1<<7) /* The argument is a command. */
+#define ARGPARSE_OPT_CONFFILE (1<<8) /* The value is a conffile. */
+#define ARGPARSE_OPT_HEADER (1<<9) /* The value is printed as a header. */
+#define ARGPARSE_OPT_VERBATIM (1<<10)/* The value is printed verbatim. */
+#define ARGPARSE_ATTR_FORCE (1<<14)/* Attribute force is set. */
+#define ARGPARSE_ATTR_IGNORE (1<<15)/* Attribute ignore is set. */
+
+/* A set of macros to make option definitions easier to read. */
+#define ARGPARSE_x(s,l,t,f,d) \
+ { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) }
+
+#define ARGPARSE_s(s,l,t,d) \
+ { (s), (l), ARGPARSE_TYPE_ ## t, (d) }
+#define ARGPARSE_s_n(s,l,d) \
+ { (s), (l), ARGPARSE_TYPE_NONE, (d) }
+#define ARGPARSE_s_i(s,l,d) \
+ { (s), (l), ARGPARSE_TYPE_INT, (d) }
+#define ARGPARSE_s_s(s,l,d) \
+ { (s), (l), ARGPARSE_TYPE_STRING, (d) }
+#define ARGPARSE_s_l(s,l,d) \
+ { (s), (l), ARGPARSE_TYPE_LONG, (d) }
+#define ARGPARSE_s_u(s,l,d) \
+ { (s), (l), ARGPARSE_TYPE_ULONG, (d) }
+
+#define ARGPARSE_o(s,l,t,d) \
+ { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_OPTIONAL), (d) }
+#define ARGPARSE_o_n(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_OPTIONAL), (d) }
+#define ARGPARSE_o_i(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_OPTIONAL), (d) }
+#define ARGPARSE_o_s(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) }
+#define ARGPARSE_o_l(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_OPTIONAL), (d) }
+#define ARGPARSE_o_u(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_OPTIONAL), (d) }
+
+#define ARGPARSE_p(s,l,t,d) \
+ { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_p_n(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_p_i(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_p_s(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_p_l(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_p_u(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_PREFIX), (d) }
+
+#define ARGPARSE_op(s,l,t,d) \
+ { (s), (l), (ARGPARSE_TYPE_ ## t \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_op_n(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_NONE \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_op_i(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_INT \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_op_s(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_STRING \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_op_l(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_LONG \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+#define ARGPARSE_op_u(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_ULONG \
+ | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) }
+
+#define ARGPARSE_c(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) }
+
+#define ARGPARSE_conffile(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_STRING|ARGPARSE_OPT_CONFFILE), (d) }
+
+#define ARGPARSE_noconffile(s,l,d) \
+ { (s), (l), (ARGPARSE_TYPE_NONE|ARGPARSE_OPT_CONFFILE), (d) }
+
+/* This macro is for stub or obsolete options. */
+#define ARGPARSE_ignore(s,l) \
+ { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
+
+/* This is a legacy version of ARGPARSE_verbatim which really does
+ * verbatim printing. */
+#define ARGPARSE_group(s,d) \
+ { (s), NULL, 0, (d) }
+
+/* Verbatim print the string D in the help output. It does not make
+ * use of the "@" hack as ARGPARSE_group does. */
+#define ARGPARSE_verbatim(d) \
+ { 1, NULL, (ARGPARSE_OPT_VERBATIM), (d) }
+
+/* Same as ARGPARSE_verbatim but also print a colon and a LF. N can
+ * be used give a symbolic name to the header. Nothing is printed if
+ * D is the empty string. */
+#define ARGPARSE_header(n,d) \
+ { 1, (n), (ARGPARSE_OPT_HEADER), (d) }
+
+/* Mark the end of the list (mandatory). */
+#define ARGPARSE_end() \
+ { 0, NULL, 0, NULL }
+
+#endif /* GPGRT_ENABLE_ARGPARSE_MACROS */
+
+/* Values used for gpgrt_set_confdir. */
+#define GPGRT_CONFDIR_USER 1 /* The user's configuration dir. */
+#define GPGRT_CONFDIR_SYS 2 /* The systems's configuration dir. */
+
+/* Take care: gpgrt_argparse keeps state in ARG and requires that
+ * either ARGPARSE_FLAG_RESET is used after OPTS has been changed or
+ * gpgrt_argparse (NULL, ARG, NULL) is called first. */
+int gpgrt_argparse (gpgrt_stream_t fp,
+ gpgrt_argparse_t *arg, gpgrt_opt_t *opts);
+int gpgrt_argparser (gpgrt_argparse_t *arg, gpgrt_opt_t *opts,
+ const char *confname);
+void gpgrt_usage (int level);
+const char *gpgrt_strusage (int level);
+void gpgrt_set_strusage (const char *(*f)(int));
+void gpgrt_set_usage_outfnc (int (*f)(int, const char *));
+void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*));
+void gpgrt_set_confdir (int what, const char *name);
+
+
+/*
+ * Various helper functions
+ */
+
+/* Compare arbitrary version strings. For the standard m.n.o version
+ * numbering scheme a LEVEL of 3 is suitable; see the manual. */
+int gpgrt_cmp_version (const char *a, const char *b, int level);
+
+/* Construct a filename from the NULL terminated list of parts. Tilde
+ * expansion is done for the first argument. The caller must release
+ * the result using gpgrt_free; on error ERRNO is set and NULL
+ * returned. The second function returns an absolute filename. */
+char *gpgrt_fnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
+char *gpgrt_absfnameconcat (const char *first, ...) GPGRT_ATTR_SENTINEL(0);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* GPGRT_H */
+#endif /* GPG_ERROR_H */
+/*
+Local Variables:
+buffer-read-only: t
+End:
+*/
diff --git a/utils/gpgme/include/gpgme.h b/utils/gpgme/include/gpgme.h
new file mode 100644
index 00000000..91c54c83
--- /dev/null
+++ b/utils/gpgme/include/gpgme.h
@@ -0,0 +1,2841 @@
+/* gpgme.h - Public interface to GnuPG Made Easy. -*- c -*-
+ * Copyright (C) 2000 Werner Koch (dd9jn)
+ * Copyright (C) 2001-2018 g10 Code GmbH
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * GPGME is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <https://gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Generated from gpgme.h.in for x86_64-pc-linux-gnu.
+ */
+
+#ifndef GPGME_H
+#define GPGME_H
+
+/* Include stdio.h for the FILE type definition. */
+#include <stdio.h>
+#include <time.h>
+#include <gpg-error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /*(Make Emacsen's auto-indent happy.)*/
+}
+#endif
+#endif /* __cplusplus */
+
+
+/* The version of this header should match the one of the library. Do
+ * not use this symbol in your application, use gpgme_check_version
+ * instead. The purpose of this macro is to let autoconf (using the
+ * AM_PATH_GPGME macro) check that this header matches the installed
+ * library. */
+#define GPGME_VERSION "1.15.2-unknown"
+
+/* The version number of this header. It may be used to handle minor
+ * API incompatibilities. */
+#define GPGME_VERSION_NUMBER 0x010f02
+
+
+/* System specific typedefs. */
+
+#include <sys/types.h>
+typedef off_t gpgme_off_t;
+typedef ssize_t gpgme_ssize_t;
+
+
+
+/*
+ * Check for compiler features.
+ */
+#ifdef GPGRT_INLINE
+# define _GPGME_INLINE GPGRT_INLINE
+#elif defined(__GNUC__)
+# define _GPGME_INLINE __inline__
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+# define _GPGME_INLINE inline
+#else
+# define _GPGME_INLINE
+#endif
+
+
+/* The deprecated macro takes the version number of GPGME which
+ * introduced the deprecation as parameter for documentation. */
+#ifdef GPGRT_ATTR_DEPRECATED
+# define _GPGME_DEPRECATED(a,b) GPGRT_ATTR_DEPRECATED
+#elif defined(__GNUC__)
+# define _GPGME_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+
+# if _GPGME_GCC_VERSION > 30100
+# define _GPGME_DEPRECATED(a,b) __attribute__ ((__deprecated__))
+# else
+# define _GPGME_DEPRECATED(a,b)
+# endif
+#else
+# define _GPGME_DEPRECATED(a,b)
+#endif
+
+
+/* The macro _GPGME_DEPRECATED_OUTSIDE_GPGME suppresses warnings for
+ * fields we must access in GPGME for ABI compatibility. */
+#ifdef _GPGME_IN_GPGME
+#define _GPGME_DEPRECATED_OUTSIDE_GPGME(a,b)
+#else
+#define _GPGME_DEPRECATED_OUTSIDE_GPGME(a,b) _GPGME_DEPRECATED(a,b)
+#endif
+
+/* We used to use some symbols which clash with keywords in some
+ * languages. This macro is used to obsolete them. */
+#if defined(__cplusplus) || defined(SWIGPYTHON)
+# define _GPGME_OBSOLETE_SOME_SYMBOLS 1
+#endif
+
+
+/* Check for a matching _FILE_OFFSET_BITS definition. */
+#if 0
+#ifndef _FILE_OFFSET_BITS
+#error GPGME was compiled with _FILE_OFFSET_BITS = 0, please see the section "Largefile support (LFS)" in the GPGME manual.
+#else
+#if (_FILE_OFFSET_BITS) != (0)
+#error GPGME was compiled with a different value for _FILE_OFFSET_BITS, namely 0, please see the section "Largefile support (LFS)" in the GPGME manual.
+#endif
+#endif
+#endif
+
+
+
+/*
+ * Some opaque data types used by GPGME.
+ */
+
+/* The context holds some global state and configuration options, as
+ * well as the results of a crypto operation. */
+struct gpgme_context;
+typedef struct gpgme_context *gpgme_ctx_t;
+
+/* The data object is used by GPGME to exchange arbitrary data. */
+struct gpgme_data;
+typedef struct gpgme_data *gpgme_data_t;
+
+
+
+/*
+ * Wrappers for the libgpg-error library. They are generally not
+ * needed and the gpg-error versions may be used instead.
+ */
+
+typedef gpg_error_t gpgme_error_t;
+typedef gpg_err_code_t gpgme_err_code_t;
+typedef gpg_err_source_t gpgme_err_source_t;
+
+
+static _GPGME_INLINE gpgme_error_t
+gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code)
+{
+ return gpg_err_make (source, code);
+}
+
+
+/* The user can define GPGME_ERR_SOURCE_DEFAULT before including this
+ * file to specify a default source for gpgme_error. */
+#ifndef GPGME_ERR_SOURCE_DEFAULT
+#define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
+#endif
+
+static _GPGME_INLINE gpgme_error_t
+gpgme_error (gpgme_err_code_t code)
+{
+ return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code);
+}
+
+
+static _GPGME_INLINE gpgme_err_code_t
+gpgme_err_code (gpgme_error_t err)
+{
+ return gpg_err_code (err);
+}
+
+
+static _GPGME_INLINE gpgme_err_source_t
+gpgme_err_source (gpgme_error_t err)
+{
+ return gpg_err_source (err);
+}
+
+
+/* Return a pointer to a string containing a description of the error
+ * code in the error value ERR. This function is not thread safe. */
+const char *gpgme_strerror (gpgme_error_t err);
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ * size BUFLEN. This function is, in contrast to gpg_strerror,
+ * thread-safe if a thread-safe strerror_r() function is provided by
+ * the system. If the function succeeds, 0 is returned and BUF
+ * contains the string describing the error. If the buffer was not
+ * large enough, ERANGE is returned and BUF contains as much of the
+ * beginning of the error string as fits into the buffer. */
+int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+
+/* Return a pointer to a string containing a description of the error
+ * source in the error value ERR. */
+const char *gpgme_strsource (gpgme_error_t err);
+
+/* Retrieve the error code for the system error ERR. This returns
+ * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ * this). */
+gpgme_err_code_t gpgme_err_code_from_errno (int err);
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ * if CODE is not a system error code. */
+int gpgme_err_code_to_errno (gpgme_err_code_t code);
+
+/* Retrieve the error code directly from the ERRNO variable. This
+ * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
+ * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
+gpgme_err_code_t gpgme_err_code_from_syserror (void);
+
+/* Set the ERRNO variable. This function is the preferred way to set
+ * ERRNO due to peculiarities on WindowsCE. */
+void gpgme_err_set_errno (int err);
+
+/* Return an error value with the error source SOURCE and the system
+ * error ERR. FIXME: Should be inline. */
+gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err);
+
+/* Return an error value with the system error ERR.
+ * inline. */
+gpgme_error_t gpgme_error_from_errno (int err);
+
+
+static _GPGME_INLINE gpgme_error_t
+gpgme_error_from_syserror (void)
+{
+ return gpgme_error (gpgme_err_code_from_syserror ());
+}
+
+
+
+/*
+ * Various constants and types
+ */
+
+/* The possible encoding mode of gpgme_data_t objects. */
+typedef enum
+ {
+ GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */
+ GPGME_DATA_ENCODING_BINARY = 1,
+ GPGME_DATA_ENCODING_BASE64 = 2,
+ GPGME_DATA_ENCODING_ARMOR = 3, /* Either PEM or OpenPGP Armor. */
+ GPGME_DATA_ENCODING_URL = 4, /* LF delimited URL list. */
+ GPGME_DATA_ENCODING_URLESC = 5, /* Ditto, but percent escaped. */
+ GPGME_DATA_ENCODING_URL0 = 6, /* Nul delimited URL list. */
+ GPGME_DATA_ENCODING_MIME = 7 /* Data is a MIME part. */
+ }
+gpgme_data_encoding_t;
+
+
+/* Known data types. */
+typedef enum
+ {
+ GPGME_DATA_TYPE_INVALID = 0, /* Not detected. */
+ GPGME_DATA_TYPE_UNKNOWN = 1,
+ GPGME_DATA_TYPE_PGP_SIGNED = 0x10,
+ GPGME_DATA_TYPE_PGP_ENCRYPTED= 0x11,
+ GPGME_DATA_TYPE_PGP_OTHER = 0x12,
+ GPGME_DATA_TYPE_PGP_KEY = 0x13,
+ GPGME_DATA_TYPE_PGP_SIGNATURE= 0x18, /* Detached signature */
+ GPGME_DATA_TYPE_CMS_SIGNED = 0x20,
+ GPGME_DATA_TYPE_CMS_ENCRYPTED= 0x21,
+ GPGME_DATA_TYPE_CMS_OTHER = 0x22,
+ GPGME_DATA_TYPE_X509_CERT = 0x23,
+ GPGME_DATA_TYPE_PKCS12 = 0x24,
+ }
+gpgme_data_type_t;
+
+
+/* Public key algorithms. */
+typedef enum
+ {
+ GPGME_PK_RSA = 1,
+ GPGME_PK_RSA_E = 2,
+ GPGME_PK_RSA_S = 3,
+ GPGME_PK_ELG_E = 16,
+ GPGME_PK_DSA = 17,
+ GPGME_PK_ECC = 18,
+ GPGME_PK_ELG = 20,
+ GPGME_PK_ECDSA = 301,
+ GPGME_PK_ECDH = 302,
+ GPGME_PK_EDDSA = 303
+ }
+gpgme_pubkey_algo_t;
+
+
+/* Hash algorithms (the values match those from libgcrypt). */
+typedef enum
+ {
+ GPGME_MD_NONE = 0,
+ GPGME_MD_MD5 = 1,
+ GPGME_MD_SHA1 = 2,
+ GPGME_MD_RMD160 = 3,
+ GPGME_MD_MD2 = 5,
+ GPGME_MD_TIGER = 6, /* TIGER/192. */
+ GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */
+ GPGME_MD_SHA256 = 8,
+ GPGME_MD_SHA384 = 9,
+ GPGME_MD_SHA512 = 10,
+ GPGME_MD_SHA224 = 11,
+ GPGME_MD_MD4 = 301,
+ GPGME_MD_CRC32 = 302,
+ GPGME_MD_CRC32_RFC1510 = 303,
+ GPGME_MD_CRC24_RFC2440 = 304
+ }
+gpgme_hash_algo_t;
+
+
+/* The available signature modes. */
+typedef enum
+ {
+ GPGME_SIG_MODE_NORMAL = 0,
+ GPGME_SIG_MODE_DETACH = 1,
+ GPGME_SIG_MODE_CLEAR = 2
+ }
+gpgme_sig_mode_t;
+
+
+/* The available validities for a key. */
+typedef enum
+ {
+ GPGME_VALIDITY_UNKNOWN = 0,
+ GPGME_VALIDITY_UNDEFINED = 1,
+ GPGME_VALIDITY_NEVER = 2,
+ GPGME_VALIDITY_MARGINAL = 3,
+ GPGME_VALIDITY_FULL = 4,
+ GPGME_VALIDITY_ULTIMATE = 5
+ }
+gpgme_validity_t;
+
+
+/* The TOFU policies. */
+typedef enum
+ {
+ GPGME_TOFU_POLICY_NONE = 0,
+ GPGME_TOFU_POLICY_AUTO = 1,
+ GPGME_TOFU_POLICY_GOOD = 2,
+ GPGME_TOFU_POLICY_UNKNOWN = 3,
+ GPGME_TOFU_POLICY_BAD = 4,
+ GPGME_TOFU_POLICY_ASK = 5
+ }
+gpgme_tofu_policy_t;
+
+
+/* The key origin values. */
+typedef enum
+ {
+ GPGME_KEYORG_UNKNOWN = 0,
+ GPGME_KEYORG_KS = 1,
+ GPGME_KEYORG_DANE = 3,
+ GPGME_KEYORG_WKD = 4,
+ GPGME_KEYORG_URL = 5,
+ GPGME_KEYORG_FILE = 6,
+ GPGME_KEYORG_SELF = 7,
+ GPGME_KEYORG_OTHER = 31
+ }
+gpgme_keyorg_t;
+
+
+/* The available protocols. */
+typedef enum
+ {
+ GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
+ GPGME_PROTOCOL_CMS = 1,
+ GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */
+ GPGME_PROTOCOL_ASSUAN = 3, /* Low-level access to an Assuan server. */
+ GPGME_PROTOCOL_G13 = 4,
+ GPGME_PROTOCOL_UISERVER= 5,
+ GPGME_PROTOCOL_SPAWN = 6, /* Direct access to any program. */
+ GPGME_PROTOCOL_DEFAULT = 254,
+ GPGME_PROTOCOL_UNKNOWN = 255
+ }
+gpgme_protocol_t;
+/* Convenience macro for the surprisingly mixed spelling. */
+#define GPGME_PROTOCOL_OPENPGP GPGME_PROTOCOL_OpenPGP
+
+
+/* The available keylist mode flags. */
+#define GPGME_KEYLIST_MODE_LOCAL 1
+#define GPGME_KEYLIST_MODE_EXTERN 2
+#define GPGME_KEYLIST_MODE_SIGS 4
+#define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8
+#define GPGME_KEYLIST_MODE_WITH_SECRET 16
+#define GPGME_KEYLIST_MODE_WITH_TOFU 32
+#define GPGME_KEYLIST_MODE_WITH_KEYGRIP 64
+#define GPGME_KEYLIST_MODE_EPHEMERAL 128
+#define GPGME_KEYLIST_MODE_VALIDATE 256
+
+#define GPGME_KEYLIST_MODE_LOCATE (1|2)
+
+typedef unsigned int gpgme_keylist_mode_t;
+
+
+/* The pinentry modes. */
+typedef enum
+ {
+ GPGME_PINENTRY_MODE_DEFAULT = 0,
+ GPGME_PINENTRY_MODE_ASK = 1,
+ GPGME_PINENTRY_MODE_CANCEL = 2,
+ GPGME_PINENTRY_MODE_ERROR = 3,
+ GPGME_PINENTRY_MODE_LOOPBACK = 4
+ }
+gpgme_pinentry_mode_t;
+
+
+/* The available export mode flags. */
+#define GPGME_EXPORT_MODE_EXTERN 2
+#define GPGME_EXPORT_MODE_MINIMAL 4
+#define GPGME_EXPORT_MODE_SECRET 16
+#define GPGME_EXPORT_MODE_RAW 32
+#define GPGME_EXPORT_MODE_PKCS12 64
+#define GPGME_EXPORT_MODE_SSH 256
+
+typedef unsigned int gpgme_export_mode_t;
+
+
+/* Flags for the audit log functions. */
+#define GPGME_AUDITLOG_DEFAULT 0
+#define GPGME_AUDITLOG_HTML 1
+#define GPGME_AUDITLOG_DIAG 2
+#define GPGME_AUDITLOG_WITH_HELP 128
+
+
+/* The available signature notation flags. */
+#define GPGME_SIG_NOTATION_HUMAN_READABLE 1
+#define GPGME_SIG_NOTATION_CRITICAL 2
+
+typedef unsigned int gpgme_sig_notation_flags_t;
+
+/* An object to hold information about notation data. This structure
+ * shall be considered read-only and an application must not allocate
+ * such a structure on its own. */
+struct _gpgme_sig_notation
+{
+ struct _gpgme_sig_notation *next;
+
+ /* If NAME is a null pointer, then VALUE contains a policy URL
+ * rather than a notation. */
+ char *name;
+
+ /* The value of the notation data. */
+ char *value;
+
+ /* The length of the name of the notation data. */
+ int name_len;
+
+ /* The length of the value of the notation data. */
+ int value_len;
+
+ /* The accumulated flags. */
+ gpgme_sig_notation_flags_t flags;
+
+ /* Notation data is human-readable. */
+ unsigned int human_readable : 1;
+
+ /* Notation data is critical. */
+ unsigned int critical : 1;
+
+ /* Internal to GPGME, do not use. */
+ int _unused : 30;
+};
+typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
+
+
+
+/*
+ * Public structures.
+ */
+
+/* The engine information structure.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_engine_info
+{
+ struct _gpgme_engine_info *next;
+
+ /* The protocol ID. */
+ gpgme_protocol_t protocol;
+
+ /* The file name of the engine binary. */
+ char *file_name;
+
+ /* The version string of the installed engine. */
+ char *version;
+
+ /* The minimum version required for GPGME. */
+ const char *req_version;
+
+ /* The home directory used, or NULL if default. */
+ char *home_dir;
+};
+typedef struct _gpgme_engine_info *gpgme_engine_info_t;
+
+
+/* An object with TOFU information.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_tofu_info
+{
+ struct _gpgme_tofu_info *next;
+
+ /* The TOFU validity:
+ * 0 := conflict
+ * 1 := key without history
+ * 2 := key with too little history
+ * 3 := key with enough history for basic trust
+ * 4 := key with a lot of history
+ */
+ unsigned int validity : 3;
+
+ /* The TOFU policy (gpgme_tofu_policy_t). */
+ unsigned int policy : 4;
+
+ unsigned int _rfu : 25;
+
+ /* Number of signatures seen for this binding. Capped at USHRT_MAX. */
+ unsigned short signcount;
+ /* Number of encryptions done with this binding. Capped at USHRT_MAX. */
+ unsigned short encrcount;
+
+ /* Number of seconds since Epoch when the first and the most
+ * recently seen message were verified/decrypted. 0 means unknown. */
+ unsigned long signfirst;
+ unsigned long signlast;
+ unsigned long encrfirst;
+ unsigned long encrlast;
+
+ /* If non-NULL a human readable string summarizing the TOFU data. */
+ char *description;
+};
+typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
+
+
+/* A subkey from a key.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_subkey
+{
+ struct _gpgme_subkey *next;
+
+ /* True if subkey is revoked. */
+ unsigned int revoked : 1;
+
+ /* True if subkey is expired. */
+ unsigned int expired : 1;
+
+ /* True if subkey is disabled. */
+ unsigned int disabled : 1;
+
+ /* True if subkey is invalid. */
+ unsigned int invalid : 1;
+
+ /* True if subkey can be used for encryption. */
+ unsigned int can_encrypt : 1;
+
+ /* True if subkey can be used for signing. */
+ unsigned int can_sign : 1;
+
+ /* True if subkey can be used for certification. */
+ unsigned int can_certify : 1;
+
+ /* True if subkey is secret. */
+ unsigned int secret : 1;
+
+ /* True if subkey can be used for authentication. */
+ unsigned int can_authenticate : 1;
+
+ /* True if subkey is qualified for signatures according to German law. */
+ unsigned int is_qualified : 1;
+
+ /* True if the secret key is stored on a smart card. */
+ unsigned int is_cardkey : 1;
+
+ /* True if the key is compliant to the de-vs mode. */
+ unsigned int is_de_vs : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 20;
+
+ /* Public key algorithm supported by this subkey. */
+ gpgme_pubkey_algo_t pubkey_algo;
+
+ /* Length of the subkey. */
+ unsigned int length;
+
+ /* The key ID of the subkey. */
+ char *keyid;
+
+ /* Internal to GPGME, do not use. */
+ char _keyid[16 + 1];
+
+ /* The fingerprint of the subkey in hex digit form. */
+ char *fpr;
+
+ /* The creation timestamp, -1 if invalid, 0 if not available. */
+ long int timestamp;
+
+ /* The expiration timestamp, 0 if the subkey does not expire. */
+ long int expires;
+
+ /* The serial number of a smart card holding this key or NULL. */
+ char *card_number;
+
+ /* The name of the curve for ECC algorithms or NULL. */
+ char *curve;
+
+ /* The keygrip of the subkey in hex digit form or NULL if not available. */
+ char *keygrip;
+};
+typedef struct _gpgme_subkey *gpgme_subkey_t;
+
+
+/* A signature on a user ID.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_key_sig
+{
+ struct _gpgme_key_sig *next;
+
+ /* True if the signature is a revocation signature. */
+ unsigned int revoked : 1;
+
+ /* True if the signature is expired. */
+ unsigned int expired : 1;
+
+ /* True if the signature is invalid. */
+ unsigned int invalid : 1;
+
+ /* True if the signature should be exported. */
+ unsigned int exportable : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 12;
+
+ /* The depth of a trust signature, 0 if no trust signature. */
+ unsigned int trust_depth : 8;
+
+ /* The trust value of a trust signature, 0 if no trust signature. */
+ unsigned int trust_value : 8;
+
+ /* The public key algorithm used to create the signature. */
+ gpgme_pubkey_algo_t pubkey_algo;
+
+ /* The key ID of key used to create the signature. */
+ char *keyid;
+
+ /* Internal to GPGME, do not use. */
+ char _keyid[16 + 1];
+
+ /* The creation timestamp, -1 if invalid, 0 if not available. */
+ long int timestamp;
+
+ /* The expiration timestamp, 0 if the subkey does not expire. */
+ long int expires;
+
+ /* The scope of a trust signature. Might be NULL. */
+ char *trust_scope;
+
+ /* Same as in gpgme_signature_t. */
+ gpgme_error_t status;
+
+ /* Deprecated; use SIG_CLASS instead. */
+#ifdef _GPGME_OBSOLETE_SOME_SYMBOLS
+ unsigned int _obsolete_class _GPGME_DEPRECATED(0,4);
+#else
+ unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
+#endif
+
+ /* The user ID string. */
+ char *uid;
+
+ /* The name part of the user ID. */
+ char *name;
+
+ /* The email part of the user ID. */
+ char *email;
+
+ /* The comment part of the user ID. */
+ char *comment;
+
+ /* Crypto backend specific signature class. */
+ unsigned int sig_class;
+
+ /* Notation data and policy URLs. */
+ gpgme_sig_notation_t notations;
+
+ /* Internal to GPGME, do not use. */
+ gpgme_sig_notation_t _last_notation;
+};
+typedef struct _gpgme_key_sig *gpgme_key_sig_t;
+
+
+/* An user ID from a key.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_user_id
+{
+ struct _gpgme_user_id *next;
+
+ /* True if the user ID is revoked. */
+ unsigned int revoked : 1;
+
+ /* True if the user ID is invalid. */
+ unsigned int invalid : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 25;
+
+ /* Origin of this user ID. */
+ unsigned int origin : 5;
+
+ /* The validity of the user ID. */
+ gpgme_validity_t validity;
+
+ /* The user ID string. */
+ char *uid;
+
+ /* The name part of the user ID. */
+ char *name;
+
+ /* The email part of the user ID. */
+ char *email;
+
+ /* The comment part of the user ID. */
+ char *comment;
+
+ /* The signatures of the user ID. */
+ gpgme_key_sig_t signatures;
+
+ /* Internal to GPGME, do not use. */
+ gpgme_key_sig_t _last_keysig;
+
+ /* The mail address (addr-spec from RFC5322) of the UID string.
+ * This is general the same as the EMAIL part of this struct but
+ * might be slightly different. If no mail address is available
+ * NULL is stored. */
+ char *address;
+
+ /* The malloced TOFU information or NULL. */
+ gpgme_tofu_info_t tofu;
+
+ /* Time of the last refresh of this user id. 0 if unknown. */
+ unsigned long last_update;
+
+ /* The string to exactly identify a userid. Might be NULL. */
+ char *uidhash;
+};
+typedef struct _gpgme_user_id *gpgme_user_id_t;
+
+
+/* A key from the keyring.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_key
+{
+ /* Internal to GPGME, do not use. */
+ unsigned int _refs;
+
+ /* True if key is revoked. */
+ unsigned int revoked : 1;
+
+ /* True if key is expired. */
+ unsigned int expired : 1;
+
+ /* True if key is disabled. */
+ unsigned int disabled : 1;
+
+ /* True if key is invalid. */
+ unsigned int invalid : 1;
+
+ /* True if key can be used for encryption. */
+ unsigned int can_encrypt : 1;
+
+ /* True if key can be used for signing. */
+ unsigned int can_sign : 1;
+
+ /* True if key can be used for certification. */
+ unsigned int can_certify : 1;
+
+ /* True if key is secret. */
+ unsigned int secret : 1;
+
+ /* True if key can be used for authentication. */
+ unsigned int can_authenticate : 1;
+
+ /* True if subkey is qualified for signatures according to German law. */
+ unsigned int is_qualified : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 17;
+
+ /* Origin of this key. */
+ unsigned int origin : 5;
+
+ /* This is the protocol supported by this key. */
+ gpgme_protocol_t protocol;
+
+ /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
+ issuer serial. */
+ char *issuer_serial;
+
+ /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
+ issuer name. */
+ char *issuer_name;
+
+ /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
+ ID. */
+ char *chain_id;
+
+ /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
+ owner trust. */
+ gpgme_validity_t owner_trust;
+
+ /* The subkeys of the key. */
+ gpgme_subkey_t subkeys;
+
+ /* The user IDs of the key. */
+ gpgme_user_id_t uids;
+
+ /* Internal to GPGME, do not use. */
+ gpgme_subkey_t _last_subkey;
+
+ /* Internal to GPGME, do not use. */
+ gpgme_user_id_t _last_uid;
+
+ /* The keylist mode that was active when listing the key. */
+ gpgme_keylist_mode_t keylist_mode;
+
+ /* This field gives the fingerprint of the primary key. Note that
+ * this is a copy of the FPR of the first subkey. We need it here
+ * to allow for an incomplete key object. */
+ char *fpr;
+
+ /* Time of the last refresh of the entire key. 0 if unknown. */
+ unsigned long last_update;
+};
+typedef struct _gpgme_key *gpgme_key_t;
+
+
+/* An invalid key object.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_invalid_key
+{
+ struct _gpgme_invalid_key *next;
+
+ /* The string used to request the key. Despite the name this may
+ * not be a fingerprint. */
+ char *fpr;
+
+ /* The error code. */
+ gpgme_error_t reason;
+};
+typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
+
+
+
+/*
+ * Types for callback functions.
+ */
+
+/* Request a passphrase from the user. */
+typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
+ const char *uid_hint,
+ const char *passphrase_info,
+ int prev_was_bad, int fd);
+
+/* Inform the user about progress made. */
+typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
+ int type, int current, int total);
+
+/* Status messages from gpg. */
+typedef gpgme_error_t (*gpgme_status_cb_t) (void *opaque, const char *keyword,
+ const char *args);
+
+/* Interact with the user about an edit operation. */
+typedef gpgme_error_t (*gpgme_interact_cb_t) (void *opaque,
+ const char *keyword,
+ const char *args, int fd);
+
+
+
+/*
+ * Context management functions.
+ */
+
+/* Create a new context and return it in CTX. */
+gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
+
+/* Release the context CTX. */
+void gpgme_release (gpgme_ctx_t ctx);
+
+/* Set the flag NAME for CTX to VALUE. */
+gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
+ const char *name, const char *value);
+
+/* Get the value of the flag NAME from CTX. */
+const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name);
+
+/* Set the protocol to be used by CTX to PROTO. */
+gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
+
+/* Get the protocol used with CTX */
+gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
+
+/* Set the crypto protocol to be used by CTX to PROTO.
+ * gpgme_set_protocol actually sets the backend engine. This sets the
+ * crypto protocol used in engines that support more than one crypto
+ * prococol (for example, an UISERVER can support OpenPGP and CMS).
+ * This is reset to the default with gpgme_set_protocol. */
+gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx,
+ gpgme_protocol_t proto);
+
+/* Get the sub protocol. */
+gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx);
+
+/* Get the string describing protocol PROTO, or NULL if invalid. */
+const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
+
+/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
+void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
+
+/* Return non-zero if armor mode is set in CTX. */
+int gpgme_get_armor (gpgme_ctx_t ctx);
+
+/* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
+void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
+
+/* Return non-zero if text mode is set in CTX. */
+int gpgme_get_textmode (gpgme_ctx_t ctx);
+
+/* If YES is non-zero, enable offline mode in CTX, disable it otherwise. */
+void gpgme_set_offline (gpgme_ctx_t ctx, int yes);
+
+/* Return non-zero if offline mode is set in CTX. */
+int gpgme_get_offline (gpgme_ctx_t ctx);
+
+/* Use whatever the default of the backend crypto engine is. */
+#define GPGME_INCLUDE_CERTS_DEFAULT -256
+
+/* Include up to NR_OF_CERTS certificates in an S/MIME message. */
+void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
+
+/* Return the number of certs to include in an S/MIME message. */
+int gpgme_get_include_certs (gpgme_ctx_t ctx);
+
+/* Set keylist mode in CTX to MODE. */
+gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
+ gpgme_keylist_mode_t mode);
+
+/* Get keylist mode in CTX. */
+gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
+
+/* Set the pinentry mode for CTX to MODE. */
+gpgme_error_t gpgme_set_pinentry_mode (gpgme_ctx_t ctx,
+ gpgme_pinentry_mode_t mode);
+
+/* Get the pinentry mode of CTX. */
+gpgme_pinentry_mode_t gpgme_get_pinentry_mode (gpgme_ctx_t ctx);
+
+/* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
+ * passed as first argument to the passphrase callback function. */
+void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
+ gpgme_passphrase_cb_t cb, void *hook_value);
+
+/* Get the current passphrase callback function in *CB and the current
+ * hook value in *HOOK_VALUE. */
+void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
+ void **hook_value);
+
+/* Set the progress callback function in CTX to CB. HOOK_VALUE is
+ * passed as first argument to the progress callback function. */
+void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
+ void *hook_value);
+
+/* Get the current progress callback function in *CB and the current
+ * hook value in *HOOK_VALUE. */
+void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
+ void **hook_value);
+
+/* Set the status callback function in CTX to CB. HOOK_VALUE is
+ * passed as first argument to the status callback function. */
+void gpgme_set_status_cb (gpgme_ctx_t c, gpgme_status_cb_t cb,
+ void *hook_value);
+
+/* Get the current status callback function in *CB and the current
+ * hook value in *HOOK_VALUE. */
+void gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *cb,
+ void **hook_value);
+
+/* This function sets the locale for the context CTX, or the default
+ * locale if CTX is a null pointer. */
+gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
+ const char *value);
+
+/* Get the information about the configured engines. A pointer to the
+ * first engine in the statically allocated linked list is returned.
+ * The returned data is valid until the next gpgme_ctx_set_engine_info. */
+gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
+
+/* Set the engine info for the context CTX, protocol PROTO, to the
+ * file name FILE_NAME and the home directory HOME_DIR. */
+gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
+ gpgme_protocol_t proto,
+ const char *file_name,
+ const char *home_dir);
+
+/* Delete all signers from CTX. */
+void gpgme_signers_clear (gpgme_ctx_t ctx);
+
+/* Add KEY to list of signers in CTX. */
+gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
+
+/* Return the number of signers in CTX. */
+unsigned int gpgme_signers_count (const gpgme_ctx_t ctx);
+
+/* Return the SEQth signer's key in CTX. */
+gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
+
+/* Clear all notation data from the context. */
+void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
+
+/* Add the human-readable notation data with name NAME and value VALUE
+ * to the context CTX, using the flags FLAGS. If NAME is NULL, then
+ * VALUE should be a policy URL. The flag
+ * GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
+ * data, and false for policy URLs. */
+gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
+ const char *value,
+ gpgme_sig_notation_flags_t flags);
+
+/* Get the sig notations for this context. */
+gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
+
+/* Store a sender address in the context. */
+gpgme_error_t gpgme_set_sender (gpgme_ctx_t ctx, const char *address);
+
+/* Get the sender address from the context. */
+const char *gpgme_get_sender (gpgme_ctx_t ctx);
+
+
+
+/*
+ * Run control.
+ */
+
+/* The type of an I/O callback function. */
+typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
+
+/* The type of a function that can register FNC as the I/O callback
+ * function for the file descriptor FD with direction dir (0: for writing,
+ * 1: for reading). FNC_DATA should be passed as DATA to FNC. The
+ * function should return a TAG suitable for the corresponding
+ * gpgme_remove_io_cb_t, and an error value. */
+typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
+ gpgme_io_cb_t fnc,
+ void *fnc_data, void **tag);
+
+/* The type of a function that can remove a previously registered I/O
+ * callback function given TAG as returned by the register
+ * function. */
+typedef void (*gpgme_remove_io_cb_t) (void *tag);
+
+typedef enum
+ {
+ GPGME_EVENT_START,
+ GPGME_EVENT_DONE,
+ GPGME_EVENT_NEXT_KEY,
+ GPGME_EVENT_NEXT_TRUSTITEM /* NOT USED. */
+ }
+gpgme_event_io_t;
+
+struct gpgme_io_event_done_data
+{
+ /* A fatal IPC error or an operational error in state-less
+ * protocols. */
+ gpgme_error_t err;
+
+ /* An operational errors in session-based protocols. */
+ gpgme_error_t op_err;
+};
+typedef struct gpgme_io_event_done_data *gpgme_io_event_done_data_t;
+
+/* The type of a function that is called when a context finished an
+ * operation. */
+typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
+ void *type_data);
+
+struct gpgme_io_cbs
+{
+ gpgme_register_io_cb_t add;
+ void *add_priv;
+ gpgme_remove_io_cb_t remove;
+ gpgme_event_io_cb_t event;
+ void *event_priv;
+};
+typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
+
+/* Set the I/O callback functions in CTX to IO_CBS. */
+void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
+
+/* Get the current I/O callback functions. */
+void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
+
+/* Wrappers around the internal I/O functions for use with
+ * gpgme_passphrase_cb_t and gpgme_interact_cb_t. */
+ssize_t gpgme_io_read (int fd, void *buffer, size_t count);
+ssize_t gpgme_io_write (int fd, const void *buffer, size_t count);
+int gpgme_io_writen (int fd, const void *buffer, size_t count);
+
+/* Process the pending operation and, if HANG is non-zero, wait for
+ * the pending operation to finish. */
+gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
+
+gpgme_ctx_t gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status,
+ gpgme_error_t *op_err, int hang);
+
+/* Cancel a pending asynchronous operation. */
+gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
+
+/* Cancel a pending operation asynchronously. */
+gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
+
+
+
+/*
+ * Functions to handle data objects.
+ */
+
+/* Read up to SIZE bytes into buffer BUFFER from the data object with
+ * the handle HANDLE. Return the number of characters read, 0 on EOF
+ * and -1 on error. If an error occurs, errno is set. */
+typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer,
+ size_t size);
+
+/* Write up to SIZE bytes from buffer BUFFER to the data object with
+ * the handle HANDLE. Return the number of characters written, or -1
+ * on error. If an error occurs, errno is set. */
+typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
+ size_t size);
+
+/* Set the current position from where the next read or write starts
+ * in the data object with the handle HANDLE to OFFSET, relativ to
+ * WHENCE. Returns the new offset in bytes from the beginning of the
+ * data object. */
+typedef off_t (*gpgme_data_seek_cb_t) (void *handle,
+ off_t offset, int whence);
+
+/* Close the data object with the handle HANDLE. */
+typedef void (*gpgme_data_release_cb_t) (void *handle);
+
+struct gpgme_data_cbs
+{
+ gpgme_data_read_cb_t read;
+ gpgme_data_write_cb_t write;
+ gpgme_data_seek_cb_t seek;
+ gpgme_data_release_cb_t release;
+};
+typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
+
+/* Read up to SIZE bytes into buffer BUFFER from the data object with
+ * the handle DH. Return the number of characters read, 0 on EOF and
+ * -1 on error. If an error occurs, errno is set. */
+ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
+
+/* Write up to SIZE bytes from buffer BUFFER to the data object with
+ * the handle DH. Return the number of characters written, or -1 on
+ * error. If an error occurs, errno is set. */
+ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
+
+/* Set the current position from where the next read or write starts
+ * in the data object with the handle DH to OFFSET, relativ to WHENCE.
+ * Returns the new offset in bytes from the beginning of the data
+ * object. */
+off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
+
+/* Create a new data buffer and return it in R_DH. */
+gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
+
+/* Destroy the data buffer DH. */
+void gpgme_data_release (gpgme_data_t dh);
+
+/* Create a new data buffer filled with SIZE bytes starting from
+ * BUFFER. If COPY is zero, copying is delayed until necessary, and
+ * the data is taken from the original location when needed. */
+gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
+ const char *buffer, size_t size,
+ int copy);
+
+/* Destroy the data buffer DH and return a pointer to its content.
+ * The memory has be to released with gpgme_free() by the user. It's
+ * size is returned in R_LEN. */
+char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
+
+/* Release the memory returned by gpgme_data_release_and_get_mem() and
+ * some other functions. */
+void gpgme_free (void *buffer);
+
+gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
+ gpgme_data_cbs_t cbs,
+ void *handle);
+
+gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
+
+gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
+gpgme_error_t gpgme_data_new_from_estream (gpgme_data_t *r_dh,
+ gpgrt_stream_t stream);
+
+/* Return the encoding attribute of the data buffer DH */
+gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
+
+/* Set the encoding attribute of data buffer DH to ENC */
+gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
+ gpgme_data_encoding_t enc);
+
+/* Get the file name associated with the data object with handle DH, or
+ * NULL if there is none. */
+char *gpgme_data_get_file_name (gpgme_data_t dh);
+
+/* Set the file name associated with the data object with handle DH to
+ * FILE_NAME. */
+gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
+ const char *file_name);
+
+/* Set a flag for the data object DH. See the manual for details. */
+gpg_error_t gpgme_data_set_flag (gpgme_data_t dh,
+ const char *name, const char *value);
+
+/* Try to identify the type of the data in DH. */
+gpgme_data_type_t gpgme_data_identify (gpgme_data_t dh, int reserved);
+
+
+/* Create a new data buffer filled with the content of file FNAME.
+ * COPY must be non-zero. For delayed read, please use
+ * gpgme_data_new_from_fd or gpgme_data_new_from_stream instead. */
+gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
+ const char *fname,
+ int copy);
+
+/* Create a new data buffer filled with LENGTH bytes starting from
+ * OFFSET within the file FNAME or stream FP (exactly one must be
+ * non-zero). */
+gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
+ const char *fname, FILE *fp,
+ off_t offset, size_t length);
+
+/* Convenience function to do a gpgme_data_seek (dh, 0, SEEK_SET). */
+gpgme_error_t gpgme_data_rewind (gpgme_data_t dh);
+
+
+
+/*
+ * Key and trust functions.
+ */
+
+/* Get the key with the fingerprint FPR from the crypto backend. If
+ * SECRET is true, get the secret key. */
+gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
+ gpgme_key_t *r_key, int secret);
+
+/* Create a dummy key to specify an email address. */
+gpgme_error_t gpgme_key_from_uid (gpgme_key_t *key, const char *name);
+
+/* Acquire a reference to KEY. */
+void gpgme_key_ref (gpgme_key_t key);
+
+/* Release a reference to KEY. If this was the last one the key is
+ * destroyed. */
+void gpgme_key_unref (gpgme_key_t key);
+void gpgme_key_release (gpgme_key_t key);
+
+
+
+/*
+ * Encryption.
+ */
+
+/* An object to return results from an encryption operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_encrypt_result
+{
+ /* The list of invalid recipients. */
+ gpgme_invalid_key_t invalid_recipients;
+};
+typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
+
+/* Retrieve a pointer to the result of the encrypt operation. */
+gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
+
+/* The valid encryption flags. */
+typedef enum
+ {
+ GPGME_ENCRYPT_ALWAYS_TRUST = 1,
+ GPGME_ENCRYPT_NO_ENCRYPT_TO = 2,
+ GPGME_ENCRYPT_PREPARE = 4,
+ GPGME_ENCRYPT_EXPECT_SIGN = 8,
+ GPGME_ENCRYPT_NO_COMPRESS = 16,
+ GPGME_ENCRYPT_SYMMETRIC = 32,
+ GPGME_ENCRYPT_THROW_KEYIDS = 64,
+ GPGME_ENCRYPT_WRAP = 128,
+ GPGME_ENCRYPT_WANT_ADDRESS = 256
+ }
+gpgme_encrypt_flags_t;
+
+/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
+ * store the resulting ciphertext in CIPHER. */
+gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt_ext_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ const char *recpstring,
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt_ext (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ const char *recpstring,
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+
+/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
+ * store the resulting ciphertext in CIPHER. Also sign the ciphertext
+ * with the signers in CTX. */
+gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
+ gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt_sign_ext_start (gpgme_ctx_t ctx,
+ gpgme_key_t recp[],
+ const char *recpstring,
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+gpgme_error_t gpgme_op_encrypt_sign_ext (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ const char *recpstring,
+ gpgme_encrypt_flags_t flags,
+ gpgme_data_t plain,
+ gpgme_data_t cipher);
+
+
+/*
+ * Decryption.
+ */
+
+/* An object to hold information about a recipient.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_recipient
+{
+ struct _gpgme_recipient *next;
+
+ /* The key ID of key for which the text was encrypted. */
+ char *keyid;
+
+ /* Internal to GPGME, do not use. */
+ char _keyid[16 + 1];
+
+ /* The public key algorithm of the recipient key. */
+ gpgme_pubkey_algo_t pubkey_algo;
+
+ /* The status of the recipient. */
+ gpgme_error_t status;
+};
+typedef struct _gpgme_recipient *gpgme_recipient_t;
+
+
+/* An object to return results from a decryption operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_decrypt_result
+{
+ char *unsupported_algorithm;
+
+ /* Key should not have been used for encryption. */
+ unsigned int wrong_key_usage : 1;
+
+ /* True if the message was encrypted in compliance to the de-vs
+ * mode. */
+ unsigned int is_de_vs : 1;
+
+ /* The message claims that the content is a MIME object. */
+ unsigned int is_mime : 1;
+
+ /* The message was made by a legacy algorithm without any integrity
+ * protection. This might be an old but legitimate message. */
+ unsigned int legacy_cipher_nomdc : 1;
+
+ /* Internal to GPGME, do not use. */
+ int _unused : 28;
+
+ gpgme_recipient_t recipients;
+
+ /* The original file name of the plaintext message, if
+ * available. */
+ char *file_name;
+
+ /* A textual representation of the session key used to decrypt the
+ * message, if available */
+ char *session_key;
+
+ /* A string with the symmetric encryption algorithm and mode using
+ * the format "<algo>.<mode>". */
+ char *symkey_algo;
+};
+typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
+
+
+/* Retrieve a pointer to the result of the decrypt operation. */
+gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
+
+
+/* The valid decryption flags. */
+typedef enum
+ {
+ GPGME_DECRYPT_VERIFY = 1,
+ GPGME_DECRYPT_UNWRAP = 128
+ }
+gpgme_decrypt_flags_t;
+
+
+/* Decrypt ciphertext CIPHER within CTX and store the resulting
+ * plaintext in PLAIN. */
+gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
+ gpgme_data_t plain);
+gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
+ gpgme_data_t cipher, gpgme_data_t plain);
+
+/* Decrypt ciphertext CIPHER and make a signature verification within
+ * CTX and store the resulting plaintext in PLAIN. */
+gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
+ gpgme_data_t cipher,
+ gpgme_data_t plain);
+gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
+ gpgme_data_t plain);
+
+/* Decrypt ciphertext CIPHER within CTX and store the resulting
+ * plaintext in PLAIN. With the flag GPGME_DECRYPT_VERIFY also do a
+ * signature verification pn the plaintext. */
+gpgme_error_t gpgme_op_decrypt_ext_start (gpgme_ctx_t ctx,
+ gpgme_decrypt_flags_t flags,
+ gpgme_data_t cipher,
+ gpgme_data_t plain);
+gpgme_error_t gpgme_op_decrypt_ext (gpgme_ctx_t ctx,
+ gpgme_decrypt_flags_t flags,
+ gpgme_data_t cipher,
+ gpgme_data_t plain);
+
+
+
+/*
+ * Signing.
+ */
+
+/* An object with signatures data.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_new_signature
+{
+ struct _gpgme_new_signature *next;
+
+ /* The type of the signature. */
+ gpgme_sig_mode_t type;
+
+ /* The public key algorithm used to create the signature. */
+ gpgme_pubkey_algo_t pubkey_algo;
+
+ /* The hash algorithm used to create the signature. */
+ gpgme_hash_algo_t hash_algo;
+
+ /* Internal to GPGME, do not use. Must be set to the same value as
+ * CLASS below. */
+ unsigned long _obsolete_class;
+
+ /* Signature creation time. */
+ long int timestamp;
+
+ /* The fingerprint of the signature. */
+ char *fpr;
+
+ /* Deprecated; use SIG_CLASS instead. */
+#ifdef _GPGME_OBSOLETE_SOME_SYMBOLS
+ unsigned int _obsolete_class_2;
+#else
+ unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
+#endif
+
+ /* Crypto backend specific signature class. */
+ unsigned int sig_class;
+};
+typedef struct _gpgme_new_signature *gpgme_new_signature_t;
+
+
+/* An object to return results from a signing operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_sign_result
+{
+ /* The list of invalid signers. */
+ gpgme_invalid_key_t invalid_signers;
+ gpgme_new_signature_t signatures;
+};
+typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
+
+
+/* Retrieve a pointer to the result of the signing operation. */
+gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
+
+/* Sign the plaintext PLAIN and store the signature in SIG. */
+gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
+ gpgme_data_t plain, gpgme_data_t sig,
+ gpgme_sig_mode_t mode);
+gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
+ gpgme_data_t plain, gpgme_data_t sig,
+ gpgme_sig_mode_t mode);
+
+
+/*
+ * Verify.
+ */
+
+/* Flags used for the SUMMARY field in a gpgme_signature_t. */
+typedef enum
+ {
+ GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
+ GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
+ GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
+ GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
+ GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
+ GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
+ GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
+ GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
+ GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
+ GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
+ GPGME_SIGSUM_SYS_ERROR = 0x0800, /* A system error occurred. */
+ GPGME_SIGSUM_TOFU_CONFLICT=0x1000 /* Tofu conflict detected. */
+ }
+gpgme_sigsum_t;
+
+
+/* An object to hold the verification status of a signature.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_signature
+{
+ struct _gpgme_signature *next;
+
+ /* A summary of the signature status. */
+ gpgme_sigsum_t summary;
+
+ /* The fingerprint of the signature. This can be a subkey. */
+ char *fpr;
+
+ /* The status of the signature. */
+ gpgme_error_t status;
+
+ /* Notation data and policy URLs. */
+ gpgme_sig_notation_t notations;
+
+ /* Signature creation time. */
+ unsigned long timestamp;
+
+ /* Signature expiration time or 0. */
+ unsigned long exp_timestamp;
+
+ /* Key should not have been used for signing. */
+ unsigned int wrong_key_usage : 1;
+
+ /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
+ unsigned int pka_trust : 2;
+
+ /* Validity has been verified using the chain model. */
+ unsigned int chain_model : 1;
+
+ /* True if the signature is in compliance to the de-vs mode. */
+ unsigned int is_de_vs : 1;
+
+ /* Internal to GPGME, do not use. */
+ int _unused : 27;
+
+ gpgme_validity_t validity;
+ gpgme_error_t validity_reason;
+
+ /* The public key algorithm used to create the signature. */
+ gpgme_pubkey_algo_t pubkey_algo;
+
+ /* The hash algorithm used to create the signature. */
+ gpgme_hash_algo_t hash_algo;
+
+ /* The mailbox from the PKA information or NULL. */
+ char *pka_address;
+
+ /* If non-NULL, a possible incomplete key object with the data
+ * available for the signature. */
+ gpgme_key_t key;
+};
+typedef struct _gpgme_signature *gpgme_signature_t;
+
+
+/* An object to return the results of a verify operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_verify_result
+{
+ gpgme_signature_t signatures;
+
+ /* The original file name of the plaintext message, if available.
+ * Warning: This information is not covered by the signature. */
+ char *file_name;
+
+ /* The message claims that the content is a MIME object. */
+ /* Warning: This flag is not covered by the signature. */
+ unsigned int is_mime : 1;
+
+ /* Internal to GPGME; do not use. */
+ unsigned int _unused : 31;
+};
+typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
+
+
+/* Retrieve a pointer to the result of the verify operation. */
+gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
+
+/* Verify within CTX that SIG is a valid signature for TEXT. */
+gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
+ gpgme_data_t signed_text,
+ gpgme_data_t plaintext);
+gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
+ gpgme_data_t signed_text,
+ gpgme_data_t plaintext);
+
+
+/*
+ * Import/Export
+ */
+
+#define GPGME_IMPORT_NEW 1 /* The key was new. */
+#define GPGME_IMPORT_UID 2 /* The key contained new user IDs. */
+#define GPGME_IMPORT_SIG 4 /* The key contained new signatures. */
+#define GPGME_IMPORT_SUBKEY 8 /* The key contained new sub keys. */
+#define GPGME_IMPORT_SECRET 16 /* The key contained a secret key. */
+
+
+/* An object to hold results for one imported key.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_import_status
+{
+ struct _gpgme_import_status *next;
+
+ /* Fingerprint. */
+ char *fpr;
+
+ /* If a problem occurred, the reason why the key could not be
+ imported. Otherwise GPGME_No_Error. */
+ gpgme_error_t result;
+
+ /* The result of the import, the GPGME_IMPORT_* values bit-wise
+ ORed. 0 means the key was already known and no new components
+ have been added. */
+ unsigned int status;
+};
+typedef struct _gpgme_import_status *gpgme_import_status_t;
+
+
+/* Import result object.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_import_result
+{
+ /* Number of considered keys. */
+ int considered;
+
+ /* Keys without user ID. */
+ int no_user_id;
+
+ /* Imported keys. */
+ int imported;
+
+ /* Imported RSA keys. */
+ int imported_rsa;
+
+ /* Unchanged keys. */
+ int unchanged;
+
+ /* Number of new user ids. */
+ int new_user_ids;
+
+ /* Number of new sub keys. */
+ int new_sub_keys;
+
+ /* Number of new signatures. */
+ int new_signatures;
+
+ /* Number of new revocations. */
+ int new_revocations;
+
+ /* Number of secret keys read. */
+ int secret_read;
+
+ /* Number of secret keys imported. */
+ int secret_imported;
+
+ /* Number of secret keys unchanged. */
+ int secret_unchanged;
+
+ /* Number of new keys skipped. */
+ int skipped_new_keys;
+
+ /* Number of keys not imported. */
+ int not_imported;
+
+ /* List of keys for which an import was attempted. */
+ gpgme_import_status_t imports;
+
+ /* Number of v3 keys skipped. */
+ int skipped_v3_keys;
+};
+typedef struct _gpgme_op_import_result *gpgme_import_result_t;
+
+
+/* Retrieve a pointer to the result of the import operation. */
+gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
+
+/* Import the key in KEYDATA into the keyring. */
+gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
+gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
+
+/* Import the keys from the array KEYS into the keyring. */
+gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]);
+gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]);
+
+
+/* Export the keys found by PATTERN into KEYDATA. */
+gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+
+gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
+ const char *pattern[],
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+
+/* Export the keys from the array KEYS into KEYDATA. */
+gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx,
+ gpgme_key_t keys[],
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx,
+ gpgme_key_t keys[],
+ gpgme_export_mode_t mode,
+ gpgme_data_t keydata);
+
+
+
+/*
+ * Key generation.
+ */
+
+/* Flags for the key creation functions. */
+#define GPGME_CREATE_SIGN (1 << 0) /* Allow usage: signing. */
+#define GPGME_CREATE_ENCR (1 << 1) /* Allow usage: encryption. */
+#define GPGME_CREATE_CERT (1 << 2) /* Allow usage: certification. */
+#define GPGME_CREATE_AUTH (1 << 3) /* Allow usage: authentication. */
+#define GPGME_CREATE_NOPASSWD (1 << 7) /* Create w/o passphrase. */
+#define GPGME_CREATE_SELFSIGNED (1 << 8) /* Create self-signed cert. */
+#define GPGME_CREATE_NOSTORE (1 << 9) /* Do not store the key. */
+#define GPGME_CREATE_WANTPUB (1 << 10) /* Return the public key. */
+#define GPGME_CREATE_WANTSEC (1 << 11) /* Return the secret key. */
+#define GPGME_CREATE_FORCE (1 << 12) /* Force creation. */
+#define GPGME_CREATE_NOEXPIRE (1 << 13) /* Create w/o expiration. */
+
+
+/* An object to return result from a key generation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_genkey_result
+{
+ /* A primary key was generated. */
+ unsigned int primary : 1;
+
+ /* A sub key was generated. */
+ unsigned int sub : 1;
+
+ /* A user id was generated. */
+ unsigned int uid : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 29;
+
+ /* The fingerprint of the generated key. */
+ char *fpr;
+
+ /* A memory data object with the created public key. Only set when
+ * GPGME_CREATE_WANTPUB has been used. */
+ gpgme_data_t pubkey;
+
+ /* A memory data object with the created secret key. Only set when
+ * GPGME_CREATE_WANTSEC has been used. */
+ gpgme_data_t seckey;
+};
+typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
+
+
+/* Generate a new keypair and add it to the keyring. PUBKEY and
+ * SECKEY should be null for now. PARMS specifies what keys should be
+ * generated. */
+gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
+ gpgme_data_t pubkey, gpgme_data_t seckey);
+gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
+ gpgme_data_t pubkey, gpgme_data_t seckey);
+
+/* Generate a key pair using the modern interface. */
+gpgme_error_t gpgme_op_createkey_start (gpgme_ctx_t ctx,
+ const char *userid,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ gpgme_key_t certkey,
+ unsigned int flags);
+gpgme_error_t gpgme_op_createkey (gpgme_ctx_t ctx,
+ const char *userid,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ gpgme_key_t certkey,
+ unsigned int flags);
+/* Add a new subkey to KEY. */
+gpgme_error_t gpgme_op_createsubkey_start (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ unsigned int flags);
+gpgme_error_t gpgme_op_createsubkey (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ const char *algo,
+ unsigned long reserved,
+ unsigned long expires,
+ unsigned int flags);
+
+/* Add USERID to an existing KEY. */
+gpgme_error_t gpgme_op_adduid_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
+gpgme_error_t gpgme_op_adduid (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
+
+/* Revoke a USERID from a KEY. */
+gpgme_error_t gpgme_op_revuid_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
+gpgme_error_t gpgme_op_revuid (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
+
+/* Set a flag on the USERID of KEY. See the manual for supported flags. */
+gpgme_error_t gpgme_op_set_uid_flag_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ const char *name, const char *value);
+gpgme_error_t gpgme_op_set_uid_flag (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ const char *name, const char *value);
+
+/* Change the expiry of a key. */
+gpgme_error_t gpgme_op_setexpire_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, unsigned long expires,
+ const char *subfprs, unsigned int reserved);
+gpgme_error_t gpgme_op_setexpire (gpgme_ctx_t ctx,
+ gpgme_key_t key, unsigned long expires,
+ const char *subfprs, unsigned int reserved);
+
+/* Retrieve a pointer to the result of a genkey, createkey, or
+ * createsubkey operation. */
+gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
+
+
+/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
+ * keys are also deleted. */
+gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
+ int allow_secret);
+gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
+ int allow_secret);
+
+/* Flags for the key delete functions. */
+#define GPGME_DELETE_ALLOW_SECRET (1 << 0) /* Also delete secret key. */
+#define GPGME_DELETE_FORCE (1 << 1) /* Do not ask user to confirm. */
+
+gpgme_error_t gpgme_op_delete_ext_start (gpgme_ctx_t ctx, const gpgme_key_t key,
+ unsigned int flags);
+gpgme_error_t gpgme_op_delete_ext (gpgme_ctx_t ctx, const gpgme_key_t key,
+ unsigned int flags);
+
+
+/*
+ * Key signing interface
+ */
+
+/* Flags for the key signing functions. */
+#define GPGME_KEYSIGN_LOCAL (1 << 7) /* Create a local signature. */
+#define GPGME_KEYSIGN_LFSEP (1 << 8) /* Indicate LF separated user ids. */
+#define GPGME_KEYSIGN_NOEXPIRE (1 << 9) /* Force no expiration. */
+#define GPGME_KEYSIGN_FORCE (1 << 10) /* Force creation. */
+
+
+/* Sign the USERID of KEY using the current set of signers. */
+gpgme_error_t gpgme_op_keysign_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned long expires,
+ unsigned int flags);
+gpgme_error_t gpgme_op_keysign (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned long expires,
+ unsigned int flags);
+
+
+/* Flags for the signature revoking functions. */
+#define GPGME_REVSIG_LFSEP (1 << 8) /* Indicate LF separated user ids. */
+
+/* Revoke the signatures made with SIGNING_KEY on the USERID(s) of KEY. */
+gpgme_error_t gpgme_op_revsig_start (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ gpgme_key_t signing_key,
+ const char *userid,
+ unsigned int flags);
+gpgme_error_t gpgme_op_revsig (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ gpgme_key_t signing_key,
+ const char *userid,
+ unsigned int flags);
+
+
+/*
+ * Key edit interface
+ */
+
+/* Flags to select the mode of the interact. */
+#define GPGME_INTERACT_CARD (1 << 0) /* Use --card-edit mode. */
+
+
+/* Edit the KEY. Send status and command requests to FNC and
+ output of edit commands to OUT. */
+gpgme_error_t gpgme_op_interact_start (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ unsigned int flags,
+ gpgme_interact_cb_t fnc,
+ void *fnc_value,
+ gpgme_data_t out);
+gpgme_error_t gpgme_op_interact (gpgme_ctx_t ctx, gpgme_key_t key,
+ unsigned int flags,
+ gpgme_interact_cb_t fnc,
+ void *fnc_value,
+ gpgme_data_t out);
+
+
+/* Set the Tofu policy of KEY to POLCIY. */
+gpgme_error_t gpgme_op_tofu_policy_start (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ gpgme_tofu_policy_t policy);
+gpgme_error_t gpgme_op_tofu_policy (gpgme_ctx_t ctx,
+ gpgme_key_t key,
+ gpgme_tofu_policy_t policy);
+
+
+
+
+/*
+ * Key listing
+ */
+
+/* An object to return results from a key listing operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_keylist_result
+{
+ unsigned int truncated : 1;
+
+ /* Internal to GPGME, do not use. */
+ unsigned int _unused : 31;
+};
+typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
+
+/* Retrieve a pointer to the result of the key listing operation. */
+gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
+
+/* Start a keylist operation within CTX, searching for keys which
+ * match PATTERN. If SECRET_ONLY is true, only secret keys are
+ * returned. */
+gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
+ int secret_only);
+gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
+ const char *pattern[],
+ int secret_only, int reserved);
+
+/* List the keys contained in DATA. */
+gpgme_error_t gpgme_op_keylist_from_data_start (gpgme_ctx_t ctx,
+ gpgme_data_t data,
+ int reserved);
+
+/* Return the next key from the keylist in R_KEY. */
+gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
+
+/* Terminate a pending keylist operation within CTX. */
+gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
+
+
+
+/*
+ * Protecting keys
+ */
+
+/* Change the passphrase for KEY. FLAGS is reserved for future use
+ * and must be passed as 0. */
+gpgme_error_t gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key,
+ unsigned int flags);
+gpgme_error_t gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key,
+ unsigned int flags);
+
+
+
+/*
+ * Trust items and operations. DO NOT USE.
+ * Note: This does not work because the experimental support in the
+ * GnuPG engine has been removed a very long time; for API and ABI
+ * compatibilty we keep the functions but let them return an error.
+ * See https://dev.gnupg.org/T4834
+ */
+struct _gpgme_trust_item
+{
+ unsigned int _refs;
+ char *keyid;
+ char _keyid[16 + 1];
+ int type;
+ int level;
+ char *owner_trust;
+ char _owner_trust[2];
+ char *validity;
+ char _validity[2];
+ char *name;
+};
+typedef struct _gpgme_trust_item *gpgme_trust_item_t;
+gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
+ const char *pattern, int max_level);
+gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
+ gpgme_trust_item_t *r_item);
+gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
+void gpgme_trust_item_ref (gpgme_trust_item_t item);
+void gpgme_trust_item_unref (gpgme_trust_item_t item);
+
+
+
+/*
+ * Audit log
+ */
+
+/* Return the auditlog for the current session. This may be called
+ after a successful or failed operation. If no audit log is
+ available GPG_ERR_NO_DATA is returned. */
+gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
+ unsigned int flags);
+gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
+ unsigned int flags);
+
+
+
+/*
+ * Spawn interface
+ */
+
+/* Flags for the spawn operations. */
+#define GPGME_SPAWN_DETACHED 1
+#define GPGME_SPAWN_ALLOW_SET_FG 2
+#define GPGME_SPAWN_SHOW_WINDOW 4
+
+
+/* Run the command FILE with the arguments in ARGV. Connect stdin to
+ * DATAIN, stdout to DATAOUT, and STDERR to DATAERR. If one the data
+ * streams is NULL, connect to /dev/null instead. */
+gpgme_error_t gpgme_op_spawn_start (gpgme_ctx_t ctx,
+ const char *file, const char *argv[],
+ gpgme_data_t datain,
+ gpgme_data_t dataout, gpgme_data_t dataerr,
+ unsigned int flags);
+gpgme_error_t gpgme_op_spawn (gpgme_ctx_t ctx,
+ const char *file, const char *argv[],
+ gpgme_data_t datain,
+ gpgme_data_t dataout, gpgme_data_t dataerr,
+ unsigned int flags);
+
+
+/*
+ * Low-level Assuan protocol access.
+ */
+
+typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
+ (void *opaque, const void *data, size_t datalen);
+
+typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
+ (void *opaque, const char *name, const char *args,
+ gpgme_data_t *r_data);
+
+typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
+ (void *opaque, const char *status, const char *args);
+
+/* Send the Assuan COMMAND and return results via the callbacks.
+ * Asynchronous variant. */
+gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
+ const char *command,
+ gpgme_assuan_data_cb_t data_cb,
+ void *data_cb_value,
+ gpgme_assuan_inquire_cb_t inq_cb,
+ void *inq_cb_value,
+ gpgme_assuan_status_cb_t stat_cb,
+ void *stat_cb_value);
+
+/* Send the Assuan COMMAND and return results via the callbacks.
+ * Synchronous variant. */
+gpgme_error_t gpgme_op_assuan_transact_ext (gpgme_ctx_t ctx,
+ const char *command,
+ gpgme_assuan_data_cb_t data_cb,
+ void *data_cb_value,
+ gpgme_assuan_inquire_cb_t inq_cb,
+ void *inq_cb_value,
+ gpgme_assuan_status_cb_t stat_cb,
+ void *stat_cb_value,
+ gpgme_error_t *op_err);
+
+
+/*
+ * Crypto container support.
+ */
+
+/* An object to return results from a VFS mount operation.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_vfs_mount_result
+{
+ char *mount_dir;
+};
+typedef struct _gpgme_op_vfs_mount_result *gpgme_vfs_mount_result_t;
+
+gpgme_vfs_mount_result_t gpgme_op_vfs_mount_result (gpgme_ctx_t ctx);
+
+/* The container is automatically unmounted when the context is reset
+ * or destroyed. Transmission errors are returned directly,
+ * operational errors are returned in OP_ERR. */
+gpgme_error_t gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file,
+ const char *mount_dir, unsigned int flags,
+ gpgme_error_t *op_err);
+
+gpgme_error_t gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[],
+ const char *container_file,
+ unsigned int flags, gpgme_error_t *op_err);
+
+
+/*
+ * Interface to gpgconf(1).
+ */
+
+/* The expert level at which a configuration option or group of
+ * options should be displayed. See the gpgconf(1) documentation for
+ * more details. */
+typedef enum
+ {
+ GPGME_CONF_BASIC = 0,
+ GPGME_CONF_ADVANCED = 1,
+ GPGME_CONF_EXPERT = 2,
+ GPGME_CONF_INVISIBLE = 3,
+ GPGME_CONF_INTERNAL = 4
+ }
+gpgme_conf_level_t;
+
+
+/* The data type of a configuration option argument. See the gpgconf(1)
+ * documentation for more details. */
+typedef enum
+ {
+ /* Basic types. */
+ GPGME_CONF_NONE = 0,
+ GPGME_CONF_STRING = 1,
+ GPGME_CONF_INT32 = 2,
+ GPGME_CONF_UINT32 = 3,
+
+ /* Complex types. */
+ GPGME_CONF_FILENAME = 32,
+ GPGME_CONF_LDAP_SERVER = 33,
+ GPGME_CONF_KEY_FPR = 34,
+ GPGME_CONF_PUB_KEY = 35,
+ GPGME_CONF_SEC_KEY = 36,
+ GPGME_CONF_ALIAS_LIST = 37
+ }
+gpgme_conf_type_t;
+
+/* For now, compatibility. */
+#define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
+
+
+/* This represents a single argument for a configuration option.
+ * Which of the members of value is used depends on the ALT_TYPE. */
+typedef struct gpgme_conf_arg
+{
+ struct gpgme_conf_arg *next;
+ /* True if the option appears without an (optional) argument. */
+ unsigned int no_arg;
+ union
+ {
+ unsigned int count;
+ unsigned int uint32;
+ int int32;
+ char *string;
+ } value;
+} *gpgme_conf_arg_t;
+
+
+/* The flags of a configuration option. See the gpgconf
+ * documentation for details. */
+#define GPGME_CONF_GROUP (1 << 0)
+#define GPGME_CONF_OPTIONAL (1 << 1)
+#define GPGME_CONF_LIST (1 << 2)
+#define GPGME_CONF_RUNTIME (1 << 3)
+#define GPGME_CONF_DEFAULT (1 << 4)
+#define GPGME_CONF_DEFAULT_DESC (1 << 5)
+#define GPGME_CONF_NO_ARG_DESC (1 << 6)
+#define GPGME_CONF_NO_CHANGE (1 << 7)
+
+
+/* The representation of a single configuration option. See the
+ * gpg-conf documentation for details. */
+typedef struct gpgme_conf_opt
+{
+ struct gpgme_conf_opt *next;
+
+ /* The option name. */
+ char *name;
+
+ /* The flags for this option. */
+ unsigned int flags;
+
+ /* The level of this option. */
+ gpgme_conf_level_t level;
+
+ /* The localized description of this option. */
+ char *description;
+
+ /* The type and alternate type of this option. */
+ gpgme_conf_type_t type;
+ gpgme_conf_type_t alt_type;
+
+ /* The localized (short) name of the argument, if any. */
+ char *argname;
+
+ /* The default value. */
+ gpgme_conf_arg_t default_value;
+ char *default_description;
+
+ /* The default value if the option is not set. */
+ gpgme_conf_arg_t no_arg_value;
+ char *no_arg_description;
+
+ /* The current value if the option is set. */
+ gpgme_conf_arg_t value;
+
+ /* The new value, if any. NULL means reset to default. */
+ int change_value;
+ gpgme_conf_arg_t new_value;
+
+ /* Free for application use. */
+ void *user_data;
+} *gpgme_conf_opt_t;
+
+
+/* The representation of a component that can be configured. See the
+ * gpg-conf documentation for details. */
+typedef struct gpgme_conf_comp
+{
+ struct gpgme_conf_comp *next;
+
+ /* Internal to GPGME, do not use! */
+ gpgme_conf_opt_t *_last_opt_p;
+
+ /* The component name. */
+ char *name;
+
+ /* A human-readable description for the component. */
+ char *description;
+
+ /* The program name (an absolute path to the program). */
+ char *program_name;
+
+ /* A linked list of options for this component. */
+ struct gpgme_conf_opt *options;
+} *gpgme_conf_comp_t;
+
+
+/* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
+ * default" is prepared. If type is a string type, VALUE should point
+ * to the string. Else, it should point to an unsigned or signed
+ * integer respectively. */
+gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
+ gpgme_conf_type_t type, const void *value);
+
+/* This also releases all chained argument structures! */
+void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
+
+/* Register a change for the value of OPT to ARG. If RESET is 1 (do
+ * not use any values but 0 or 1), ARG is ignored and the option is
+ * not changed (reverting a previous change). Otherwise, if ARG is
+ * NULL, the option is cleared or reset to its default. The change
+ * is done with gpgconf's --runtime option to immediately take effect. */
+gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
+ gpgme_conf_arg_t arg);
+
+/* Release a set of configurations. */
+void gpgme_conf_release (gpgme_conf_comp_t conf);
+
+/* Retrieve the current configurations. */
+gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
+
+/* Save the configuration of component comp. This function does not
+ follow chained components! */
+gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
+
+/* Retrieve the configured directory. */
+gpgme_error_t gpgme_op_conf_dir(gpgme_ctx_t ctx, const char *what,
+ char **result);
+
+
+/* Information about software versions.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+typedef struct _gpgme_op_query_swdb_result
+{
+ /* RFU */
+ struct _gpgme_op_query_swdb_result *next;
+
+ /* The name of the package (e.g. "gpgme", "gnupg") */
+ char *name;
+
+ /* The version number of the installed version. */
+ char *iversion;
+
+ /* The time the online info was created. */
+ unsigned long created;
+
+ /* The time the online info was retrieved. */
+ unsigned long retrieved;
+
+ /* This bit is set if an error occured or some of the information
+ * in this structure may not be set. */
+ unsigned int warning : 1;
+
+ /* An update is available. */
+ unsigned int update : 1;
+
+ /* The update is important. */
+ unsigned int urgent : 1;
+
+ /* No information at all available. */
+ unsigned int noinfo : 1;
+
+ /* The package name is not known. */
+ unsigned int unknown : 1;
+
+ /* The information here is too old. */
+ unsigned int tooold : 1;
+
+ /* Other error. */
+ unsigned int error : 1;
+
+ unsigned int _reserved : 25;
+
+ /* The version number of the latest released version. */
+ char *version;
+
+ /* The release date of that version. */
+ unsigned long reldate;
+
+} *gpgme_query_swdb_result_t;
+
+
+/* Run the gpgconf --query-swdb command. */
+gpgme_error_t gpgme_op_query_swdb (gpgme_ctx_t ctx,
+ const char *name, const char *iversion,
+ unsigned int reserved);
+
+/* Return the result from the last query_swdb operation. */
+gpgme_query_swdb_result_t gpgme_op_query_swdb_result (gpgme_ctx_t ctx);
+
+
+
+
+/*
+ * Various functions.
+ */
+
+/* Set special global flags; consult the manual before use. */
+int gpgme_set_global_flag (const char *name, const char *value);
+
+/* Check that the library fulfills the version requirement. Note:
+ * This is here only for the case where a user takes a pointer from
+ * the old version of this function. The new version and macro for
+ * run-time checks are below. */
+const char *gpgme_check_version (const char *req_version);
+
+/* Do not call this directly; use the macro below. */
+const char *gpgme_check_version_internal (const char *req_version,
+ size_t offset_sig_validity);
+
+/* Check that the library fulfills the version requirement and check
+ * for struct layout mismatch involving bitfields. */
+#define gpgme_check_version(req_version) \
+ gpgme_check_version_internal (req_version, \
+ offsetof (struct _gpgme_signature, validity))
+
+/* Return the default values for various directories. */
+const char *gpgme_get_dirinfo (const char *what);
+
+/* Get the information about the configured and installed engines. A
+ * pointer to the first engine in the statically allocated linked list
+ * is returned in *INFO. If an error occurs, it is returned. The
+ * returned data is valid until the next gpgme_set_engine_info. */
+gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
+
+/* Set the default engine info for the protocol PROTO to the file name
+ * FILE_NAME and the home directory HOME_DIR. */
+gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
+ const char *file_name,
+ const char *home_dir);
+
+/* Verify that the engine implementing PROTO is installed and
+ * available. */
+gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
+
+
+/* Reference counting for result objects. */
+void gpgme_result_ref (void *result);
+void gpgme_result_unref (void *result);
+
+/* Return a public key algorithm string (e.g. "rsa2048"). Caller must
+ * free using gpgme_free. */
+char *gpgme_pubkey_algo_string (gpgme_subkey_t subkey);
+
+/* Return a statically allocated string with the name of the public
+ * key algorithm ALGO, or NULL if that name is not known. */
+const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
+
+/* Return a statically allocated string with the name of the hash
+ * algorithm ALGO, or NULL if that name is not known. */
+const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
+
+/* Return the addr-spec from a user id. Caller must free the result
+ * with gpgme_free. */
+char *gpgme_addrspec_from_uid (const char *uid);
+
+
+
+/*
+ * Deprecated types, constants and functions.
+ */
+
+/* This is a former experimental only features. The constant is
+ * provided to not break existing code in the compiler phase. */
+#define GPGME_EXPORT_MODE_NOUID 128 /* Do not use! */
+
+
+/* The possible stati for gpgme_op_edit. The use of that function and
+ * these status codes are deprecated in favor of gpgme_op_interact. */
+typedef enum
+ {
+ GPGME_STATUS_EOF = 0,
+ /* mkstatus processing starts here */
+ GPGME_STATUS_ENTER = 1,
+ GPGME_STATUS_LEAVE = 2,
+ GPGME_STATUS_ABORT = 3,
+
+ GPGME_STATUS_GOODSIG = 4,
+ GPGME_STATUS_BADSIG = 5,
+ GPGME_STATUS_ERRSIG = 6,
+
+ GPGME_STATUS_BADARMOR = 7,
+
+ GPGME_STATUS_RSA_OR_IDEA = 8, /* (legacy) */
+ GPGME_STATUS_KEYEXPIRED = 9,
+ GPGME_STATUS_KEYREVOKED = 10,
+
+ GPGME_STATUS_TRUST_UNDEFINED = 11,
+ GPGME_STATUS_TRUST_NEVER = 12,
+ GPGME_STATUS_TRUST_MARGINAL = 13,
+ GPGME_STATUS_TRUST_FULLY = 14,
+ GPGME_STATUS_TRUST_ULTIMATE = 15,
+
+ GPGME_STATUS_SHM_INFO = 16, /* (legacy) */
+ GPGME_STATUS_SHM_GET = 17, /* (legacy) */
+ GPGME_STATUS_SHM_GET_BOOL = 18, /* (legacy) */
+ GPGME_STATUS_SHM_GET_HIDDEN = 19, /* (legacy) */
+
+ GPGME_STATUS_NEED_PASSPHRASE = 20,
+ GPGME_STATUS_VALIDSIG = 21,
+ GPGME_STATUS_SIG_ID = 22,
+ GPGME_STATUS_ENC_TO = 23,
+ GPGME_STATUS_NODATA = 24,
+ GPGME_STATUS_BAD_PASSPHRASE = 25,
+ GPGME_STATUS_NO_PUBKEY = 26,
+ GPGME_STATUS_NO_SECKEY = 27,
+ GPGME_STATUS_NEED_PASSPHRASE_SYM = 28,
+ GPGME_STATUS_DECRYPTION_FAILED = 29,
+ GPGME_STATUS_DECRYPTION_OKAY = 30,
+ GPGME_STATUS_MISSING_PASSPHRASE = 31,
+ GPGME_STATUS_GOOD_PASSPHRASE = 32,
+ GPGME_STATUS_GOODMDC = 33,
+ GPGME_STATUS_BADMDC = 34,
+ GPGME_STATUS_ERRMDC = 35,
+ GPGME_STATUS_IMPORTED = 36,
+ GPGME_STATUS_IMPORT_OK = 37,
+ GPGME_STATUS_IMPORT_PROBLEM = 38,
+ GPGME_STATUS_IMPORT_RES = 39,
+ GPGME_STATUS_FILE_START = 40,
+ GPGME_STATUS_FILE_DONE = 41,
+ GPGME_STATUS_FILE_ERROR = 42,
+
+ GPGME_STATUS_BEGIN_DECRYPTION = 43,
+ GPGME_STATUS_END_DECRYPTION = 44,
+ GPGME_STATUS_BEGIN_ENCRYPTION = 45,
+ GPGME_STATUS_END_ENCRYPTION = 46,
+
+ GPGME_STATUS_DELETE_PROBLEM = 47,
+ GPGME_STATUS_GET_BOOL = 48,
+ GPGME_STATUS_GET_LINE = 49,
+ GPGME_STATUS_GET_HIDDEN = 50,
+ GPGME_STATUS_GOT_IT = 51,
+ GPGME_STATUS_PROGRESS = 52,
+ GPGME_STATUS_SIG_CREATED = 53,
+ GPGME_STATUS_SESSION_KEY = 54,
+ GPGME_STATUS_NOTATION_NAME = 55,
+ GPGME_STATUS_NOTATION_DATA = 56,
+ GPGME_STATUS_POLICY_URL = 57,
+ GPGME_STATUS_BEGIN_STREAM = 58, /* (legacy) */
+ GPGME_STATUS_END_STREAM = 59, /* (legacy) */
+ GPGME_STATUS_KEY_CREATED = 60,
+ GPGME_STATUS_USERID_HINT = 61,
+ GPGME_STATUS_UNEXPECTED = 62,
+ GPGME_STATUS_INV_RECP = 63,
+ GPGME_STATUS_NO_RECP = 64,
+ GPGME_STATUS_ALREADY_SIGNED = 65,
+ GPGME_STATUS_SIGEXPIRED = 66, /* (legacy) */
+ GPGME_STATUS_EXPSIG = 67,
+ GPGME_STATUS_EXPKEYSIG = 68,
+ GPGME_STATUS_TRUNCATED = 69,
+ GPGME_STATUS_ERROR = 70,
+ GPGME_STATUS_NEWSIG = 71,
+ GPGME_STATUS_REVKEYSIG = 72,
+ GPGME_STATUS_SIG_SUBPACKET = 73,
+ GPGME_STATUS_NEED_PASSPHRASE_PIN = 74,
+ GPGME_STATUS_SC_OP_FAILURE = 75,
+ GPGME_STATUS_SC_OP_SUCCESS = 76,
+ GPGME_STATUS_CARDCTRL = 77,
+ GPGME_STATUS_BACKUP_KEY_CREATED = 78,
+ GPGME_STATUS_PKA_TRUST_BAD = 79,
+ GPGME_STATUS_PKA_TRUST_GOOD = 80,
+ GPGME_STATUS_PLAINTEXT = 81,
+ GPGME_STATUS_INV_SGNR = 82,
+ GPGME_STATUS_NO_SGNR = 83,
+ GPGME_STATUS_SUCCESS = 84,
+ GPGME_STATUS_DECRYPTION_INFO = 85,
+ GPGME_STATUS_PLAINTEXT_LENGTH = 86,
+ GPGME_STATUS_MOUNTPOINT = 87,
+ GPGME_STATUS_PINENTRY_LAUNCHED = 88,
+ GPGME_STATUS_ATTRIBUTE = 89,
+ GPGME_STATUS_BEGIN_SIGNING = 90,
+ GPGME_STATUS_KEY_NOT_CREATED = 91,
+ GPGME_STATUS_INQUIRE_MAXLEN = 92,
+ GPGME_STATUS_FAILURE = 93,
+ GPGME_STATUS_KEY_CONSIDERED = 94,
+ GPGME_STATUS_TOFU_USER = 95,
+ GPGME_STATUS_TOFU_STATS = 96,
+ GPGME_STATUS_TOFU_STATS_LONG = 97,
+ GPGME_STATUS_NOTATION_FLAGS = 98,
+ GPGME_STATUS_DECRYPTION_COMPLIANCE_MODE = 99,
+ GPGME_STATUS_VERIFICATION_COMPLIANCE_MODE = 100,
+ GPGME_STATUS_CANCELED_BY_USER = 101
+ }
+gpgme_status_code_t;
+
+/* The callback type used by the deprecated functions gpgme_op_edit
+ * and gpgme_op_card_edit. */
+typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
+ gpgme_status_code_t status,
+ const char *args, int fd);
+
+gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
+ gpgme_edit_cb_t fnc, void *fnc_value,
+ gpgme_data_t out) _GPGME_DEPRECATED(1,7);
+gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
+ gpgme_edit_cb_t fnc, void *fnc_value,
+ gpgme_data_t out) _GPGME_DEPRECATED(1,7);
+gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
+ gpgme_edit_cb_t fnc, void *fnc_value,
+ gpgme_data_t out)
+ _GPGME_DEPRECATED(1,7);
+gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
+ gpgme_edit_cb_t fnc, void *fnc_value,
+ gpgme_data_t out)
+ _GPGME_DEPRECATED(1,7);
+
+/* The possible signature stati. Deprecated, use error value in sig
+ * status. */
+typedef enum
+ {
+ GPGME_SIG_STAT_NONE = 0,
+ GPGME_SIG_STAT_GOOD = 1,
+ GPGME_SIG_STAT_BAD = 2,
+ GPGME_SIG_STAT_NOKEY = 3,
+ GPGME_SIG_STAT_NOSIG = 4,
+ GPGME_SIG_STAT_ERROR = 5,
+ GPGME_SIG_STAT_DIFF = 6,
+ GPGME_SIG_STAT_GOOD_EXP = 7,
+ GPGME_SIG_STAT_GOOD_EXPKEY = 8
+ }
+_gpgme_sig_stat_t;
+typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED(0,4);
+
+/* The available key and signature attributes. Deprecated, use the
+ * individual result structures instead. */
+typedef enum
+ {
+ GPGME_ATTR_KEYID = 1,
+ GPGME_ATTR_FPR = 2,
+ GPGME_ATTR_ALGO = 3,
+ GPGME_ATTR_LEN = 4,
+ GPGME_ATTR_CREATED = 5,
+ GPGME_ATTR_EXPIRE = 6,
+ GPGME_ATTR_OTRUST = 7,
+ GPGME_ATTR_USERID = 8,
+ GPGME_ATTR_NAME = 9,
+ GPGME_ATTR_EMAIL = 10,
+ GPGME_ATTR_COMMENT = 11,
+ GPGME_ATTR_VALIDITY = 12,
+ GPGME_ATTR_LEVEL = 13,
+ GPGME_ATTR_TYPE = 14,
+ GPGME_ATTR_IS_SECRET = 15,
+ GPGME_ATTR_KEY_REVOKED = 16,
+ GPGME_ATTR_KEY_INVALID = 17,
+ GPGME_ATTR_UID_REVOKED = 18,
+ GPGME_ATTR_UID_INVALID = 19,
+ GPGME_ATTR_KEY_CAPS = 20,
+ GPGME_ATTR_CAN_ENCRYPT = 21,
+ GPGME_ATTR_CAN_SIGN = 22,
+ GPGME_ATTR_CAN_CERTIFY = 23,
+ GPGME_ATTR_KEY_EXPIRED = 24,
+ GPGME_ATTR_KEY_DISABLED = 25,
+ GPGME_ATTR_SERIAL = 26,
+ GPGME_ATTR_ISSUER = 27,
+ GPGME_ATTR_CHAINID = 28,
+ GPGME_ATTR_SIG_STATUS = 29,
+ GPGME_ATTR_ERRTOK = 30,
+ GPGME_ATTR_SIG_SUMMARY = 31,
+ GPGME_ATTR_SIG_CLASS = 32
+ }
+_gpgme_attr_t;
+typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED(0,4);
+
+/* Retrieve the signature status of signature IDX in CTX after a
+ * successful verify operation in R_STAT (if non-null). The creation
+ * time stamp of the signature is returned in R_CREATED (if non-null).
+ * The function returns a string containing the fingerprint.
+ * Deprecated, use verify result directly. */
+const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
+ _gpgme_sig_stat_t *r_stat,
+ time_t *r_created) _GPGME_DEPRECATED(0,4);
+
+/* Retrieve certain attributes of a signature. IDX is the index
+ * number of the signature after a successful verify operation. WHAT
+ * is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
+ * one. WHATIDX is to be passed as 0 for most attributes . */
+unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
+ _gpgme_attr_t what, int whatidx)
+ _GPGME_DEPRECATED(0,4);
+const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
+ _gpgme_attr_t what, int whatidx)
+ _GPGME_DEPRECATED(0,4);
+
+
+/* Get the key used to create signature IDX in CTX and return it in
+ * R_KEY. */
+gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
+ _GPGME_DEPRECATED(0,4);
+
+/* Create a new data buffer which retrieves the data from the callback
+ * function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
+ * instead. */
+gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
+ int (*read_cb) (void*,char *,
+ size_t,size_t*),
+ void *read_cb_value)
+ _GPGME_DEPRECATED(0,4);
+
+/* Return the value of the attribute WHAT of KEY, which has to be
+ * representable by a string. IDX specifies the sub key or user ID
+ * for attributes related to sub keys or user IDs. Deprecated, use
+ * key structure directly instead. */
+const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+/* Return the value of the attribute WHAT of KEY, which has to be
+ * representable by an unsigned integer. IDX specifies the sub key or
+ * user ID for attributes related to sub keys or user IDs.
+ * Deprecated, use key structure directly instead. */
+unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+/* Return the value of the attribute WHAT of a signature on user ID
+ * UID_IDX in KEY, which has to be representable by a string. IDX
+ * specifies the signature. Deprecated, use key structure directly
+ * instead. */
+const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
+ _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+/* Return the value of the attribute WHAT of a signature on user ID
+ * UID_IDX in KEY, which has to be representable by an unsigned
+ * integer string. IDX specifies the signature. Deprecated, use key
+ * structure directly instead. */
+unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
+ _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+
+gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
+ int *nr) _GPGME_DEPRECATED(0,4);
+
+/* DO NOT USE. */
+void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED(0,4);
+
+/* DO NOT USE. */
+const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item,
+ _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+/* DO NOT USE. */
+int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what,
+ const void *reserved, int idx)
+ _GPGME_DEPRECATED(0,4);
+
+/* Compat.
+ * This structure shall be considered read-only and an application
+ * must not allocate such a structure on its own. */
+struct _gpgme_op_assuan_result
+{
+ /* Deprecated. Use the second value in a DONE event or the
+ synchronous variant gpgme_op_assuan_transact_ext. */
+ gpgme_error_t err _GPGME_DEPRECATED_OUTSIDE_GPGME(1,2);
+};
+typedef struct _gpgme_op_assuan_result *gpgme_assuan_result_t;
+
+
+/* Return the result of the last Assuan command. */
+gpgme_assuan_result_t gpgme_op_assuan_result (gpgme_ctx_t ctx)
+ _GPGME_DEPRECATED(1,2);
+
+gpgme_error_t
+gpgme_op_assuan_transact (gpgme_ctx_t ctx,
+ const char *command,
+ gpgme_assuan_data_cb_t data_cb,
+ void *data_cb_value,
+ gpgme_assuan_inquire_cb_t inq_cb,
+ void *inq_cb_value,
+ gpgme_assuan_status_cb_t status_cb,
+ void *status_cb_value) _GPGME_DEPRECATED(1,2);
+
+
+
+typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED(0,4);
+typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED(0,4);
+typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED(0,4);
+typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED(0,4);
+typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED(0,4);
+typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED(0,4);
+typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED(0,4);
+typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED(0,4);
+typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED(0,4);
+typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED(0,4);
+typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED(0,4);
+typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED(0,4);
+typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED(0,4);
+typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED(0,4);
+typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED(0,4);
+typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED(0,4);
+typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED(0,4);
+typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED(0,4);
+#define GpgmeIOCbs gpgme_io_cbs
+typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED(0,4);
+typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED(0,4);
+#define GpgmeDataCbs gpgme_data_cbs
+typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED(0,4);
+typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED(0,4);
+typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED(0,4);
+typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED(0,4);
+typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED(0,4);
+typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED(0,4);
+typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED(0,4);
+typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED(0,4);
+typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED(0,4);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* GPGME_H */
+/*
+Local Variables:
+buffer-read-only: t
+End:
+*/