2018-11-16 12:27:33 +00:00
|
|
|
/* status-table.c - Status codes from gnupg.
|
|
|
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2012 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
|
|
|
|
*/
|
2012-02-14 12:03:46 +00:00
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2012-04-12 17:51:49 +00:00
|
|
|
#include <string.h>
|
2012-02-14 12:03:46 +00:00
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
struct status_table_s {
|
|
|
|
const char *name;
|
|
|
|
gpgme_status_code_t code;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Lexicographically sorted ('_' comes after any letter). You can use
|
|
|
|
the Emacs command M-x sort-lines. But don't sweat it, the table is
|
|
|
|
sorted at start up, too. */
|
|
|
|
static struct status_table_s status_table[] =
|
|
|
|
{
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "ABORT", GPGME_STATUS_ABORT },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "ALREADY_SIGNED", GPGME_STATUS_ALREADY_SIGNED },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "ATTRIBUTE", GPGME_STATUS_ATTRIBUTE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "BACKUP_KEY_CREATED", GPGME_STATUS_BACKUP_KEY_CREATED },
|
|
|
|
{ "BADARMOR", GPGME_STATUS_BADARMOR },
|
|
|
|
{ "BADMDC", GPGME_STATUS_BADMDC },
|
|
|
|
{ "BADSIG", GPGME_STATUS_BADSIG },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "BAD_PASSPHRASE", GPGME_STATUS_BAD_PASSPHRASE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "BEGIN_DECRYPTION", GPGME_STATUS_BEGIN_DECRYPTION },
|
|
|
|
{ "BEGIN_ENCRYPTION", GPGME_STATUS_BEGIN_ENCRYPTION },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "BEGIN_SIGNING", GPGME_STATUS_BEGIN_SIGNING },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "BEGIN_STREAM", GPGME_STATUS_BEGIN_STREAM },
|
|
|
|
{ "CARDCTRL", GPGME_STATUS_CARDCTRL },
|
|
|
|
{ "DECRYPTION_FAILED", GPGME_STATUS_DECRYPTION_FAILED },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "DECRYPTION_INFO", GPGME_STATUS_DECRYPTION_INFO },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "DECRYPTION_OKAY", GPGME_STATUS_DECRYPTION_OKAY },
|
|
|
|
{ "DELETE_PROBLEM", GPGME_STATUS_DELETE_PROBLEM },
|
2017-05-30 12:35:57 +00:00
|
|
|
{ "DECRYPTION_COMPLIANCE_MODE", GPGME_STATUS_DECRYPTION_COMPLIANCE_MODE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "ENC_TO", GPGME_STATUS_ENC_TO },
|
|
|
|
{ "END_DECRYPTION", GPGME_STATUS_END_DECRYPTION },
|
|
|
|
{ "END_ENCRYPTION", GPGME_STATUS_END_ENCRYPTION },
|
|
|
|
{ "END_STREAM", GPGME_STATUS_END_STREAM },
|
|
|
|
{ "ENTER", GPGME_STATUS_ENTER },
|
|
|
|
{ "ERRMDC", GPGME_STATUS_ERRMDC },
|
|
|
|
{ "ERROR", GPGME_STATUS_ERROR },
|
|
|
|
{ "ERRSIG", GPGME_STATUS_ERRSIG },
|
|
|
|
{ "EXPKEYSIG", GPGME_STATUS_EXPKEYSIG },
|
|
|
|
{ "EXPSIG", GPGME_STATUS_EXPSIG },
|
2015-08-25 11:22:43 +00:00
|
|
|
{ "FAILURE", GPGME_STATUS_FAILURE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "FILE_DONE", GPGME_STATUS_FILE_DONE },
|
|
|
|
{ "FILE_ERROR", GPGME_STATUS_FILE_ERROR },
|
|
|
|
{ "FILE_START", GPGME_STATUS_FILE_START },
|
|
|
|
{ "GET_BOOL", GPGME_STATUS_GET_BOOL },
|
|
|
|
{ "GET_HIDDEN", GPGME_STATUS_GET_HIDDEN },
|
|
|
|
{ "GET_LINE", GPGME_STATUS_GET_LINE },
|
|
|
|
{ "GOODMDC", GPGME_STATUS_GOODMDC },
|
|
|
|
{ "GOODSIG", GPGME_STATUS_GOODSIG },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "GOOD_PASSPHRASE", GPGME_STATUS_GOOD_PASSPHRASE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "GOT_IT", GPGME_STATUS_GOT_IT },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "IMPORTED", GPGME_STATUS_IMPORTED },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "IMPORT_OK", GPGME_STATUS_IMPORT_OK },
|
|
|
|
{ "IMPORT_PROBLEM", GPGME_STATUS_IMPORT_PROBLEM },
|
|
|
|
{ "IMPORT_RES", GPGME_STATUS_IMPORT_RES },
|
2015-04-17 01:05:01 +00:00
|
|
|
{ "INQUIRE_MAXLEN", GPGME_STATUS_INQUIRE_MAXLEN },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "INV_RECP", GPGME_STATUS_INV_RECP },
|
|
|
|
{ "INV_SGNR", GPGME_STATUS_INV_SGNR },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "KEYEXPIRED", GPGME_STATUS_KEYEXPIRED },
|
|
|
|
{ "KEYREVOKED", GPGME_STATUS_KEYREVOKED },
|
2016-05-17 18:21:01 +00:00
|
|
|
{ "KEY_CONSIDERED", GPGME_STATUS_KEY_CONSIDERED },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "KEY_CREATED", GPGME_STATUS_KEY_CREATED },
|
|
|
|
{ "KEY_NOT_CREATED", GPGME_STATUS_KEY_NOT_CREATED },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "LEAVE", GPGME_STATUS_LEAVE },
|
|
|
|
{ "MISSING_PASSPHRASE", GPGME_STATUS_MISSING_PASSPHRASE },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "MOUNTPOINT", GPGME_STATUS_MOUNTPOINT },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "NEED_PASSPHRASE", GPGME_STATUS_NEED_PASSPHRASE },
|
|
|
|
{ "NEED_PASSPHRASE_PIN", GPGME_STATUS_NEED_PASSPHRASE_PIN },
|
|
|
|
{ "NEED_PASSPHRASE_SYM", GPGME_STATUS_NEED_PASSPHRASE_SYM },
|
|
|
|
{ "NEWSIG", GPGME_STATUS_NEWSIG },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "NODATA", GPGME_STATUS_NODATA },
|
|
|
|
{ "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA },
|
2016-06-01 09:10:30 +00:00
|
|
|
{ "NOTATION_FLAGS", GPGME_STATUS_NOTATION_FLAGS },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "NO_PUBKEY", GPGME_STATUS_NO_PUBKEY },
|
|
|
|
{ "NO_RECP", GPGME_STATUS_NO_RECP },
|
|
|
|
{ "NO_SECKEY", GPGME_STATUS_NO_SECKEY },
|
|
|
|
{ "NO_SGNR", GPGME_STATUS_NO_SGNR },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "PINENTRY_LAUNCHED", GPGME_STATUS_PINENTRY_LAUNCHED},
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD },
|
|
|
|
{ "PKA_TRUST_GOOD", GPGME_STATUS_PKA_TRUST_GOOD },
|
|
|
|
{ "PLAINTEXT", GPGME_STATUS_PLAINTEXT },
|
2014-05-13 13:44:52 +00:00
|
|
|
{ "PLAINTEXT_LENGTH", GPGME_STATUS_PLAINTEXT_LENGTH },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "POLICY_URL", GPGME_STATUS_POLICY_URL },
|
|
|
|
{ "PROGRESS", GPGME_STATUS_PROGRESS },
|
|
|
|
{ "REVKEYSIG", GPGME_STATUS_REVKEYSIG },
|
|
|
|
{ "RSA_OR_IDEA", GPGME_STATUS_RSA_OR_IDEA },
|
|
|
|
{ "SC_OP_FAILURE", GPGME_STATUS_SC_OP_FAILURE },
|
|
|
|
{ "SC_OP_SUCCESS", GPGME_STATUS_SC_OP_SUCCESS },
|
|
|
|
{ "SESSION_KEY", GPGME_STATUS_SESSION_KEY },
|
|
|
|
{ "SHM_GET", GPGME_STATUS_SHM_GET },
|
|
|
|
{ "SHM_GET_BOOL", GPGME_STATUS_SHM_GET_BOOL },
|
|
|
|
{ "SHM_GET_HIDDEN", GPGME_STATUS_SHM_GET_HIDDEN },
|
|
|
|
{ "SHM_INFO", GPGME_STATUS_SHM_INFO },
|
2017-05-30 10:09:23 +00:00
|
|
|
{ "SIGEXPIRED", GPGME_STATUS_SIGEXPIRED },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "SIG_CREATED", GPGME_STATUS_SIG_CREATED },
|
|
|
|
{ "SIG_ID", GPGME_STATUS_SIG_ID },
|
|
|
|
{ "SIG_SUBPACKET", GPGME_STATUS_SIG_SUBPACKET },
|
|
|
|
{ "SUCCESS", GPGME_STATUS_SUCCESS },
|
2016-05-21 08:29:49 +00:00
|
|
|
{ "TOFU_STATS", GPGME_STATUS_TOFU_STATS },
|
|
|
|
{ "TOFU_STATS_LONG", GPGME_STATUS_TOFU_STATS_LONG },
|
|
|
|
{ "TOFU_USER", GPGME_STATUS_TOFU_USER },
|
2012-02-14 12:03:46 +00:00
|
|
|
{ "TRUNCATED", GPGME_STATUS_TRUNCATED },
|
|
|
|
{ "TRUST_FULLY", GPGME_STATUS_TRUST_FULLY },
|
|
|
|
{ "TRUST_MARGINAL", GPGME_STATUS_TRUST_MARGINAL },
|
|
|
|
{ "TRUST_NEVER", GPGME_STATUS_TRUST_NEVER },
|
|
|
|
{ "TRUST_ULTIMATE", GPGME_STATUS_TRUST_ULTIMATE },
|
|
|
|
{ "TRUST_UNDEFINED", GPGME_STATUS_TRUST_UNDEFINED },
|
|
|
|
{ "UNEXPECTED", GPGME_STATUS_UNEXPECTED },
|
|
|
|
{ "USERID_HINT", GPGME_STATUS_USERID_HINT },
|
|
|
|
{ "VALIDSIG", GPGME_STATUS_VALIDSIG },
|
2017-05-30 12:35:57 +00:00
|
|
|
{ "VERIFICATION_COMPLIANCE_MODE", GPGME_STATUS_VERIFICATION_COMPLIANCE_MODE },
|
2012-02-14 12:03:46 +00:00
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
status_cmp (const void *ap, const void *bp)
|
|
|
|
{
|
|
|
|
const struct status_table_s *a = ap;
|
|
|
|
const struct status_table_s *b = bp;
|
|
|
|
|
|
|
|
return strcmp (a->name, b->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_gpgme_status_init (void)
|
|
|
|
{
|
|
|
|
qsort (status_table,
|
|
|
|
DIM(status_table) - 1, sizeof (status_table[0]),
|
|
|
|
status_cmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gpgme_status_code_t
|
|
|
|
_gpgme_parse_status (const char *name)
|
|
|
|
{
|
|
|
|
struct status_table_s t, *r;
|
|
|
|
t.name = name;
|
|
|
|
r = bsearch (&t, status_table, DIM(status_table) - 1,
|
|
|
|
sizeof t, status_cmp);
|
|
|
|
return r ? r->code : -1;
|
|
|
|
}
|
2016-09-15 08:45:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_gpgme_status_to_string (gpgme_status_code_t code)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i < DIM(status_table); i++)
|
|
|
|
if (status_table[i].code == code)
|
2016-09-16 13:06:26 +00:00
|
|
|
return status_table[i].name? status_table[i].name : "";
|
2016-09-15 08:45:04 +00:00
|
|
|
return "status_code_lost";
|
|
|
|
}
|