diff options
author | Werner Koch <[email protected]> | 2003-10-29 10:07:44 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2003-10-29 10:07:44 +0000 |
commit | fcc72f915bbafe2e1f1f68be7e79d7b45561da62 (patch) | |
tree | cabc573682cc56a710a40e251b33847d38ef1cb9 /util/miscutil.c | |
parent | * DETAILS: Add the 'a' value for field 12 and the new field 15. (diff) | |
download | gnupg-fcc72f915bbafe2e1f1f68be7e79d7b45561da62.tar.gz gnupg-fcc72f915bbafe2e1f1f68be7e79d7b45561da62.zip |
* cardglue.c (open_card): Ask for card insertion.
(check_card_serialno): New.
(agent_scd_pksign, agent_scd_pkdecrypt): Use it here.
* cardglue.c (open_card): Issue insertion status message.
* status.h, status.c (STATUS_CARDCTRL): New.
* status.c (cpr_get_answer_okay_cancel): New.
* miscutil.c (answer_is_okay_cancel): New.
Diffstat (limited to 'util/miscutil.c')
-rw-r--r-- | util/miscutil.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/util/miscutil.c b/util/miscutil.c index b266d27d4..e0ea0e7d2 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -359,3 +359,38 @@ answer_is_yes_no_quit( const char *s ) return -1; return 0; } + + +/* + Return 1 for okay, 0 for for cancel or DEF_ANSWER for default. + */ +int +answer_is_okay_cancel (const char *s, int def_answer) +{ + const char *long_okay = _("okay"); + const char *long_cancel = _("cancel"); + const char *short_okay = _("oO"); + const char *short_cancel = _("cC"); + + /* Note: We have to use the locale dependent strcasecmp */ + if ( !strcasecmp(s, long_okay ) ) + return 1; + if ( !strcasecmp(s, long_cancel ) ) + return 0; + if ( *s && strchr( short_okay, *s ) && !s[1] ) + return 1; + if ( *s && strchr( short_cancel, *s ) && !s[1] ) + return 0; + /* Always test for the English values (not locale here) */ + if ( !ascii_strcasecmp(s, "okay" ) ) + return 1; + if ( !ascii_strcasecmp(s, "ok" ) ) + return 1; + if ( !ascii_strcasecmp(s, "cancel" ) ) + return 0; + if ( *s && strchr( "oO", *s ) && !s[1] ) + return 1; + if ( *s && strchr( "cC", *s ) && !s[1] ) + return 0; + return def_answer; +} |