LCOV - code coverage report
Current view: top level - src - status-table.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2016-09-12 13:07:23 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* gpgme.c - GnuPG Made Easy.
       2             :    Copyright (C) 2000 Werner Koch (dd9jn)
       3             :    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2012 g10 Code GmbH
       4             : 
       5             :    This file is part of GPGME.
       6             : 
       7             :    GPGME is free software; you can redistribute it and/or modify it
       8             :    under the terms of the GNU Lesser General Public License as
       9             :    published by the Free Software Foundation; either version 2.1 of
      10             :    the License, or (at your option) any later version.
      11             : 
      12             :    GPGME is distributed in the hope that it will be useful, but
      13             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :    Lesser General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU Lesser General Public
      18             :    License along with this program; if not, write to the Free Software
      19             :    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      20             :    02111-1307, USA.  */
      21             : 
      22             : #if HAVE_CONFIG_H
      23             : #include <config.h>
      24             : #endif
      25             : 
      26             : #include <stdlib.h>
      27             : #include <string.h>
      28             : 
      29             : #include "util.h"
      30             : 
      31             : struct status_table_s {
      32             :     const char *name;
      33             :     gpgme_status_code_t code;
      34             : };
      35             : 
      36             : 
      37             : /* Lexicographically sorted ('_' comes after any letter).  You can use
      38             :    the Emacs command M-x sort-lines.  But don't sweat it, the table is
      39             :    sorted at start up, too.  */
      40             : static struct status_table_s status_table[] =
      41             : {
      42             :   { "ABORT", GPGME_STATUS_ABORT },
      43             :   { "ALREADY_SIGNED", GPGME_STATUS_ALREADY_SIGNED },
      44             :   { "ATTRIBUTE",         GPGME_STATUS_ATTRIBUTE        },
      45             :   { "BACKUP_KEY_CREATED", GPGME_STATUS_BACKUP_KEY_CREATED },
      46             :   { "BAD_PASSPHRASE", GPGME_STATUS_BAD_PASSPHRASE },
      47             :   { "BADARMOR", GPGME_STATUS_BADARMOR },
      48             :   { "BADMDC", GPGME_STATUS_BADMDC },
      49             :   { "BADSIG", GPGME_STATUS_BADSIG },
      50             :   { "BEGIN_DECRYPTION", GPGME_STATUS_BEGIN_DECRYPTION },
      51             :   { "BEGIN_ENCRYPTION", GPGME_STATUS_BEGIN_ENCRYPTION },
      52             :   { "BEGIN_SIGNING",     GPGME_STATUS_BEGIN_SIGNING    },
      53             :   { "BEGIN_STREAM", GPGME_STATUS_BEGIN_STREAM },
      54             :   { "CARDCTRL", GPGME_STATUS_CARDCTRL },
      55             :   { "DECRYPTION_FAILED", GPGME_STATUS_DECRYPTION_FAILED },
      56             :   { "DECRYPTION_INFO",   GPGME_STATUS_DECRYPTION_INFO  },
      57             :   { "DECRYPTION_OKAY", GPGME_STATUS_DECRYPTION_OKAY },
      58             :   { "DELETE_PROBLEM", GPGME_STATUS_DELETE_PROBLEM },
      59             :   { "ENC_TO", GPGME_STATUS_ENC_TO },
      60             :   { "END_DECRYPTION", GPGME_STATUS_END_DECRYPTION },
      61             :   { "END_ENCRYPTION", GPGME_STATUS_END_ENCRYPTION },
      62             :   { "END_STREAM", GPGME_STATUS_END_STREAM },
      63             :   { "ENTER", GPGME_STATUS_ENTER },
      64             :   { "ERRMDC", GPGME_STATUS_ERRMDC },
      65             :   { "ERROR", GPGME_STATUS_ERROR },
      66             :   { "ERRSIG", GPGME_STATUS_ERRSIG },
      67             :   { "EXPKEYSIG", GPGME_STATUS_EXPKEYSIG },
      68             :   { "EXPSIG", GPGME_STATUS_EXPSIG },
      69             :   { "FAILURE", GPGME_STATUS_FAILURE },
      70             :   { "FILE_DONE", GPGME_STATUS_FILE_DONE },
      71             :   { "FILE_ERROR", GPGME_STATUS_FILE_ERROR },
      72             :   { "FILE_START", GPGME_STATUS_FILE_START },
      73             :   { "GET_BOOL", GPGME_STATUS_GET_BOOL },
      74             :   { "GET_HIDDEN", GPGME_STATUS_GET_HIDDEN },
      75             :   { "GET_LINE", GPGME_STATUS_GET_LINE },
      76             :   { "GOOD_PASSPHRASE", GPGME_STATUS_GOOD_PASSPHRASE },
      77             :   { "GOODMDC", GPGME_STATUS_GOODMDC },
      78             :   { "GOODSIG", GPGME_STATUS_GOODSIG },
      79             :   { "GOT_IT", GPGME_STATUS_GOT_IT },
      80             :   { "IMPORT_OK", GPGME_STATUS_IMPORT_OK },
      81             :   { "IMPORT_PROBLEM", GPGME_STATUS_IMPORT_PROBLEM },
      82             :   { "IMPORT_RES", GPGME_STATUS_IMPORT_RES },
      83             :   { "IMPORTED", GPGME_STATUS_IMPORTED },
      84             :   { "INQUIRE_MAXLEN", GPGME_STATUS_INQUIRE_MAXLEN },
      85             :   { "INV_RECP", GPGME_STATUS_INV_RECP },
      86             :   { "INV_SGNR", GPGME_STATUS_INV_SGNR },
      87             :   { "KEY_CONSIDERED", GPGME_STATUS_KEY_CONSIDERED },
      88             :   { "KEY_CREATED", GPGME_STATUS_KEY_CREATED },
      89             :   { "KEY_NOT_CREATED",   GPGME_STATUS_KEY_NOT_CREATED  },
      90             :   { "KEYEXPIRED", GPGME_STATUS_KEYEXPIRED },
      91             :   { "KEYREVOKED", GPGME_STATUS_KEYREVOKED },
      92             :   { "LEAVE", GPGME_STATUS_LEAVE },
      93             :   { "MISSING_PASSPHRASE", GPGME_STATUS_MISSING_PASSPHRASE },
      94             :   { "MOUNTPOINT",        GPGME_STATUS_MOUNTPOINT       },
      95             :   { "NEED_PASSPHRASE", GPGME_STATUS_NEED_PASSPHRASE },
      96             :   { "NEED_PASSPHRASE_PIN", GPGME_STATUS_NEED_PASSPHRASE_PIN },
      97             :   { "NEED_PASSPHRASE_SYM", GPGME_STATUS_NEED_PASSPHRASE_SYM },
      98             :   { "NEWSIG", GPGME_STATUS_NEWSIG },
      99             :   { "NO_PUBKEY", GPGME_STATUS_NO_PUBKEY },
     100             :   { "NO_RECP", GPGME_STATUS_NO_RECP },
     101             :   { "NO_SECKEY", GPGME_STATUS_NO_SECKEY },
     102             :   { "NO_SGNR", GPGME_STATUS_NO_SGNR },
     103             :   { "NODATA", GPGME_STATUS_NODATA },
     104             :   { "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA },
     105             :   { "NOTATION_FLAGS", GPGME_STATUS_NOTATION_FLAGS },
     106             :   { "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME },
     107             :   { "PINENTRY_LAUNCHED", GPGME_STATUS_PINENTRY_LAUNCHED},
     108             :   { "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD },
     109             :   { "PKA_TRUST_GOOD", GPGME_STATUS_PKA_TRUST_GOOD },
     110             :   { "PLAINTEXT", GPGME_STATUS_PLAINTEXT },
     111             :   { "PLAINTEXT_LENGTH",  GPGME_STATUS_PLAINTEXT_LENGTH },
     112             :   { "POLICY_URL", GPGME_STATUS_POLICY_URL },
     113             :   { "PROGRESS", GPGME_STATUS_PROGRESS },
     114             :   { "REVKEYSIG", GPGME_STATUS_REVKEYSIG },
     115             :   { "RSA_OR_IDEA", GPGME_STATUS_RSA_OR_IDEA },
     116             :   { "SC_OP_FAILURE", GPGME_STATUS_SC_OP_FAILURE },
     117             :   { "SC_OP_SUCCESS", GPGME_STATUS_SC_OP_SUCCESS },
     118             :   { "SESSION_KEY", GPGME_STATUS_SESSION_KEY },
     119             :   { "SHM_GET", GPGME_STATUS_SHM_GET },
     120             :   { "SHM_GET_BOOL", GPGME_STATUS_SHM_GET_BOOL },
     121             :   { "SHM_GET_HIDDEN", GPGME_STATUS_SHM_GET_HIDDEN },
     122             :   { "SHM_INFO", GPGME_STATUS_SHM_INFO },
     123             :   { "SIG_CREATED", GPGME_STATUS_SIG_CREATED },
     124             :   { "SIG_ID", GPGME_STATUS_SIG_ID },
     125             :   { "SIG_SUBPACKET", GPGME_STATUS_SIG_SUBPACKET },
     126             :   { "SIGEXPIRED", GPGME_STATUS_SIGEXPIRED },
     127             :   { "SUCCESS", GPGME_STATUS_SUCCESS },
     128             :   { "TOFU_STATS", GPGME_STATUS_TOFU_STATS },
     129             :   { "TOFU_STATS_LONG", GPGME_STATUS_TOFU_STATS_LONG },
     130             :   { "TOFU_USER", GPGME_STATUS_TOFU_USER },
     131             :   { "TRUNCATED", GPGME_STATUS_TRUNCATED },
     132             :   { "TRUST_FULLY", GPGME_STATUS_TRUST_FULLY },
     133             :   { "TRUST_MARGINAL", GPGME_STATUS_TRUST_MARGINAL },
     134             :   { "TRUST_NEVER", GPGME_STATUS_TRUST_NEVER },
     135             :   { "TRUST_ULTIMATE", GPGME_STATUS_TRUST_ULTIMATE },
     136             :   { "TRUST_UNDEFINED", GPGME_STATUS_TRUST_UNDEFINED },
     137             :   { "UNEXPECTED", GPGME_STATUS_UNEXPECTED },
     138             :   { "USERID_HINT", GPGME_STATUS_USERID_HINT },
     139             :   { "VALIDSIG", GPGME_STATUS_VALIDSIG },
     140             :   {NULL, 0}
     141             : };
     142             : 
     143             : 
     144             : static int
     145       29212 : status_cmp (const void *ap, const void *bp)
     146             : {
     147       29212 :   const struct status_table_s *a = ap;
     148       29212 :   const struct status_table_s *b = bp;
     149             : 
     150       29212 :   return strcmp (a->name, b->name);
     151             : }
     152             : 
     153             : 
     154             : void
     155          59 : _gpgme_status_init (void)
     156             : {
     157          59 :   qsort (status_table,
     158             :          DIM(status_table) - 1, sizeof (status_table[0]),
     159             :          status_cmp);
     160          59 : }
     161             : 
     162             : 
     163             : gpgme_status_code_t
     164        1725 : _gpgme_parse_status (const char *name)
     165             : {
     166             :   struct status_table_s t, *r;
     167        1725 :   t.name = name;
     168        1725 :   r = bsearch (&t, status_table, DIM(status_table) - 1,
     169             :                sizeof t, status_cmp);
     170        1725 :   return r ? r->code : -1;
     171             : }

Generated by: LCOV version 1.11