From fcc72f915bbafe2e1f1f68be7e79d7b45561da62 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 29 Oct 2003 10:07:44 +0000 Subject: * 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. --- util/miscutil.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'util/miscutil.c') 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; +} -- cgit