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: 2015-11-05 17:14:26 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_CREATED", GPGME_STATUS_KEY_CREATED },
      88             :   { "KEY_NOT_CREATED",   GPGME_STATUS_KEY_NOT_CREATED  },
      89             :   { "KEYEXPIRED", GPGME_STATUS_KEYEXPIRED },
      90             :   { "KEYREVOKED", GPGME_STATUS_KEYREVOKED },
      91             :   { "LEAVE", GPGME_STATUS_LEAVE },
      92             :   { "MISSING_PASSPHRASE", GPGME_STATUS_MISSING_PASSPHRASE },
      93             :   { "MOUNTPOINT",        GPGME_STATUS_MOUNTPOINT       },
      94             :   { "NEED_PASSPHRASE", GPGME_STATUS_NEED_PASSPHRASE },
      95             :   { "NEED_PASSPHRASE_PIN", GPGME_STATUS_NEED_PASSPHRASE_PIN },
      96             :   { "NEED_PASSPHRASE_SYM", GPGME_STATUS_NEED_PASSPHRASE_SYM },
      97             :   { "NEWSIG", GPGME_STATUS_NEWSIG },
      98             :   { "NO_PUBKEY", GPGME_STATUS_NO_PUBKEY },
      99             :   { "NO_RECP", GPGME_STATUS_NO_RECP },
     100             :   { "NO_SECKEY", GPGME_STATUS_NO_SECKEY },
     101             :   { "NO_SGNR", GPGME_STATUS_NO_SGNR },
     102             :   { "NODATA", GPGME_STATUS_NODATA },
     103             :   { "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA },
     104             :   { "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME },
     105             :   { "PINENTRY_LAUNCHED", GPGME_STATUS_PINENTRY_LAUNCHED},
     106             :   { "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD },
     107             :   { "PKA_TRUST_GOOD", GPGME_STATUS_PKA_TRUST_GOOD },
     108             :   { "PLAINTEXT", GPGME_STATUS_PLAINTEXT },
     109             :   { "PLAINTEXT_LENGTH",  GPGME_STATUS_PLAINTEXT_LENGTH },
     110             :   { "POLICY_URL", GPGME_STATUS_POLICY_URL },
     111             :   { "PROGRESS", GPGME_STATUS_PROGRESS },
     112             :   { "REVKEYSIG", GPGME_STATUS_REVKEYSIG },
     113             :   { "RSA_OR_IDEA", GPGME_STATUS_RSA_OR_IDEA },
     114             :   { "SC_OP_FAILURE", GPGME_STATUS_SC_OP_FAILURE },
     115             :   { "SC_OP_SUCCESS", GPGME_STATUS_SC_OP_SUCCESS },
     116             :   { "SESSION_KEY", GPGME_STATUS_SESSION_KEY },
     117             :   { "SHM_GET", GPGME_STATUS_SHM_GET },
     118             :   { "SHM_GET_BOOL", GPGME_STATUS_SHM_GET_BOOL },
     119             :   { "SHM_GET_HIDDEN", GPGME_STATUS_SHM_GET_HIDDEN },
     120             :   { "SHM_INFO", GPGME_STATUS_SHM_INFO },
     121             :   { "SIG_CREATED", GPGME_STATUS_SIG_CREATED },
     122             :   { "SIG_ID", GPGME_STATUS_SIG_ID },
     123             :   { "SIG_SUBPACKET", GPGME_STATUS_SIG_SUBPACKET },
     124             :   { "SIGEXPIRED", GPGME_STATUS_SIGEXPIRED },
     125             :   { "SUCCESS", GPGME_STATUS_SUCCESS },
     126             :   { "TRUNCATED", GPGME_STATUS_TRUNCATED },
     127             :   { "TRUST_FULLY", GPGME_STATUS_TRUST_FULLY },
     128             :   { "TRUST_MARGINAL", GPGME_STATUS_TRUST_MARGINAL },
     129             :   { "TRUST_NEVER", GPGME_STATUS_TRUST_NEVER },
     130             :   { "TRUST_ULTIMATE", GPGME_STATUS_TRUST_ULTIMATE },
     131             :   { "TRUST_UNDEFINED", GPGME_STATUS_TRUST_UNDEFINED },
     132             :   { "UNEXPECTED", GPGME_STATUS_UNEXPECTED },
     133             :   { "USERID_HINT", GPGME_STATUS_USERID_HINT },
     134             :   { "VALIDSIG", GPGME_STATUS_VALIDSIG },
     135             :   {NULL, 0}
     136             : };
     137             : 
     138             : 
     139             : static int
     140       11592 : status_cmp (const void *ap, const void *bp)
     141             : {
     142       11592 :   const struct status_table_s *a = ap;
     143       11592 :   const struct status_table_s *b = bp;
     144             : 
     145       11592 :   return strcmp (a->name, b->name);
     146             : }
     147             : 
     148             : 
     149             : void
     150          29 : _gpgme_status_init (void)
     151             : {
     152          29 :   qsort (status_table,
     153             :          DIM(status_table) - 1, sizeof (status_table[0]),
     154             :          status_cmp);
     155          29 : }
     156             : 
     157             : 
     158             : gpgme_status_code_t
     159         482 : _gpgme_parse_status (const char *name)
     160             : {
     161             :   struct status_table_s t, *r;
     162         482 :   t.name = name;
     163         482 :   r = bsearch (&t, status_table, DIM(status_table) - 1,
     164             :                sizeof t, status_cmp);
     165         482 :   return r ? r->code : -1;
     166             : }

Generated by: LCOV version 1.11