mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
common: Slight redefinition of nvc_get_boolean.
* common/name-value.c (nvc_get_boolean): Rewrite. -- The function may now return a positive or negative number instead of just 1 for true. All callers were already prepared for this. GnuPG-bug-id: 6212
This commit is contained in:
parent
eae28f1bd4
commit
f35e7dbf9e
@ -147,6 +147,7 @@ enum cmd_and_opt_values
|
|||||||
oS2KCalibration,
|
oS2KCalibration,
|
||||||
oAutoExpandSecmem,
|
oAutoExpandSecmem,
|
||||||
oListenBacklog,
|
oListenBacklog,
|
||||||
|
oInactivityTimeout,
|
||||||
|
|
||||||
oWriteEnvFile,
|
oWriteEnvFile,
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ static gpgrt_opt_t opts[] = {
|
|||||||
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
||||||
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
||||||
ARGPARSE_noconffile (oNoOptions, "no-options", "@"),
|
ARGPARSE_noconffile (oNoOptions, "no-options", "@"),
|
||||||
|
ARGPARSE_s_i (oInactivityTimeout, "inactivity-timeout", "@"),
|
||||||
|
|
||||||
ARGPARSE_header ("Monitor", N_("Options controlling the diagnostic output")),
|
ARGPARSE_header ("Monitor", N_("Options controlling the diagnostic output")),
|
||||||
|
|
||||||
|
@ -608,13 +608,14 @@ nvc_get_string (nvc_t nvc, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return true if NAME exists and its value is true; that is either
|
/* Return true (ie. a non-zero value) if NAME exists and its value is
|
||||||
* "yes", "true", or a decimal value unequal to 0. */
|
* true; that is either "yes", "true", or a decimal value unequal to 0. */
|
||||||
int
|
int
|
||||||
nvc_get_boolean (nvc_t nvc, const char *name)
|
nvc_get_boolean (nvc_t nvc, const char *name)
|
||||||
{
|
{
|
||||||
nve_t item;
|
nve_t item;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
int n;
|
||||||
|
|
||||||
if (!nvc)
|
if (!nvc)
|
||||||
return 0;
|
return 0;
|
||||||
@ -622,9 +623,12 @@ nvc_get_boolean (nvc_t nvc, const char *name)
|
|||||||
if (!item)
|
if (!item)
|
||||||
return 0;
|
return 0;
|
||||||
s = nve_value (item);
|
s = nve_value (item);
|
||||||
if (s && (atoi (s)
|
if (!s)
|
||||||
|| !ascii_strcasecmp (s, "yes")
|
return 0;
|
||||||
|| !ascii_strcasecmp (s, "true")))
|
n = atoi (s);
|
||||||
|
if (n)
|
||||||
|
return n;
|
||||||
|
if (!ascii_strcasecmp (s, "yes") || !ascii_strcasecmp (s, "true"))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ 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. */
|
/* Return a boolean value (zero or non-zero) for the first entry in
|
||||||
|
* NVC with NAME. */
|
||||||
int nvc_get_boolean (nvc_t nvc, const char *name);
|
int nvc_get_boolean (nvc_t nvc, const char *name);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user