mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-19 09:02:22 +02:00
common: New function nvc_get_boolean.
* common/name-value.c (nvc_get_boolean): New.
This commit is contained in:
parent
2cbb5760d7
commit
40f0fcfaa4
@ -597,6 +597,28 @@ nvc_get_string (nvc_t nvc, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return true if NAME exists and its value is true; that is either
|
||||||
|
* "yes", "true", or a decimal value unequal to 0. */
|
||||||
|
int
|
||||||
|
nvc_get_boolean (nvc_t nvc, const char *name)
|
||||||
|
{
|
||||||
|
nve_t item;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if (!nvc)
|
||||||
|
return 0;
|
||||||
|
item = nvc_lookup (nvc, name);
|
||||||
|
if (!item)
|
||||||
|
return 0;
|
||||||
|
s = nve_value (item);
|
||||||
|
if (s && (atoi (s)
|
||||||
|
|| !ascii_strcasecmp (s, "yes")
|
||||||
|
|| !ascii_strcasecmp (s, "true")))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Private key handling. */
|
/* Private key handling. */
|
||||||
|
@ -75,6 +75,9 @@ nve_t nve_next_value (nve_t entry, const char *name);
|
|||||||
/* Return the string for the first entry in NVC with NAME or NULL. */
|
/* Return the string for the first entry in NVC with NAME or NULL. */
|
||||||
const char *nvc_get_string (nvc_t nvc, const char *name);
|
const char *nvc_get_string (nvc_t nvc, const char *name);
|
||||||
|
|
||||||
|
/* Return a boolean value for the first entry in NVC with NAME. */
|
||||||
|
int nvc_get_boolean (nvc_t nvc, const char *name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Adding and modifying values. */
|
/* Adding and modifying values. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user