LCOV - code coverage report
Current view: top level - common - agent-opt.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 18 0.0 %
Date: 2016-09-12 12:29:17 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* agent-opt.c - Helper for certain agent options
       2             :  * Copyright (C) 2013 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is part of GnuPG.
       5             :  *
       6             :  * This file is free software; you can redistribute it and/or modify
       7             :  * it under the terms of either
       8             :  *
       9             :  *   - the GNU Lesser General Public License as published by the Free
      10             :  *     Software Foundation; either version 3 of the License, or (at
      11             :  *     your option) any later version.
      12             :  *
      13             :  * or
      14             :  *
      15             :  *   - the GNU General Public License as published by the Free
      16             :  *     Software Foundation; either version 2 of the License, or (at
      17             :  *     your option) any later version.
      18             :  *
      19             :  * or both in parallel, as here.
      20             :  *
      21             :  * This file is distributed in the hope that it will be useful,
      22             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      24             :  * GNU General Public License for more details.
      25             :  *
      26             :  * You should have received a copy of the GNU General Public License
      27             :  * along with this program; if not, see <http://www.gnu.org/licenses/>.
      28             :  */
      29             : 
      30             : #include <config.h>
      31             : #include <stdlib.h>
      32             : #include <string.h>
      33             : 
      34             : #include "shareddefs.h"
      35             : 
      36             : 
      37             : /* Parse VALUE and return an integer representing a pinentry_mode_t.
      38             :    (-1) is returned for an invalid VALUE.  */
      39             : int
      40           0 : parse_pinentry_mode (const char *value)
      41             : {
      42             :   int result;
      43             : 
      44           0 :   if (!strcmp (value, "ask") || !strcmp (value, "default"))
      45           0 :     result = PINENTRY_MODE_ASK;
      46           0 :   else if (!strcmp (value, "cancel"))
      47           0 :     result = PINENTRY_MODE_CANCEL;
      48           0 :   else if (!strcmp (value, "error"))
      49           0 :     result = PINENTRY_MODE_ERROR;
      50           0 :   else if (!strcmp (value, "loopback"))
      51           0 :     result = PINENTRY_MODE_LOOPBACK;
      52             :   else
      53           0 :     result = -1;
      54             : 
      55           0 :   return result;
      56             : }
      57             : 
      58             : /* Return the string representation for the pinentry MODE.  Returns
      59             :    "?" for an invalid mode.  */
      60             : const char *
      61           0 : str_pinentry_mode (pinentry_mode_t mode)
      62             : {
      63           0 :   switch (mode)
      64             :     {
      65           0 :     case PINENTRY_MODE_ASK:      return "ask";
      66           0 :     case PINENTRY_MODE_CANCEL:   return "cancel";
      67           0 :     case PINENTRY_MODE_ERROR:    return "error";
      68           0 :     case PINENTRY_MODE_LOOPBACK: return "loopback";
      69             :     }
      70           0 :  return "?";
      71             : }

Generated by: LCOV version 1.11