1 /* agent-opt.c - Helper for certain agent options
2 * Copyright (C) 2013 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of either
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.
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.
19 * or both in parallel, as here.
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.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses/>.
34 #include "shareddefs.h"
37 /* Parse VALUE and return an integer representing a pinentry_mode_t.
38 (-1) is returned for an invalid VALUE. */
40 parse_pinentry_mode (const char *value)
44 if (!strcmp (value, "ask") || !strcmp (value, "default"))
45 result = PINENTRY_MODE_ASK;
46 else if (!strcmp (value, "cancel"))
47 result = PINENTRY_MODE_CANCEL;
48 else if (!strcmp (value, "error"))
49 result = PINENTRY_MODE_ERROR;
50 else if (!strcmp (value, "loopback"))
51 result = PINENTRY_MODE_LOOPBACK;
58 /* Return the string representation for the pinentry MODE. Returns
59 "?" for an invalid mode. */
61 str_pinentry_mode (pinentry_mode_t mode)
65 case PINENTRY_MODE_ASK: return "ask";
66 case PINENTRY_MODE_CANCEL: return "cancel";
67 case PINENTRY_MODE_ERROR: return "error";
68 case PINENTRY_MODE_LOOPBACK: return "loopback";