From ff87f4e578f412332ae59fdab016f0a5304baaf9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 1 Apr 2021 10:31:52 +0200 Subject: scd: New flag --reread for LEARN * scd/command.c (cmd_learn): Add flag --reread. * scd/app-common.h (struct app_ctx_s): New field need_reset. * scd/app.c (write_learn_status_core): Set need_reset if we notice an error after returning from a reread. Change all callers of card functions to return GPG_ERR_CARD_RESET so that that app is not anymore used. Signed-off-by: Werner Koch --- scd/command.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'scd/command.c') diff --git a/scd/command.c b/scd/command.c index 2be00bb40..fc1bb0145 100644 --- a/scd/command.c +++ b/scd/command.c @@ -420,7 +420,7 @@ cmd_switchapp (assuan_context_t ctx, char *line) static const char hlp_learn[] = - "LEARN [--force] [--keypairinfo] [--multi]\n" + "LEARN [--force] [--keypairinfo] [--reread] [--multi]\n" "\n" "Learn all useful information of the currently inserted card. When\n" "used without the force options, the command might do an INQUIRE\n" @@ -433,7 +433,8 @@ static const char hlp_learn[] = "error message.\n" "\n" "With the option --keypairinfo only KEYPAIRINFO status lines are\n" - "returned.\n" + "returned. With the option --reread information from the card are\n" + "read again without the need for a reset (sone some cards).\n" "\n" "The response of this command is a list of status lines formatted as\n" "this:\n" @@ -498,6 +499,8 @@ cmd_learn (assuan_context_t ctx, char *line) int rc = 0; int only_keypairinfo = has_option (line, "--keypairinfo"); int opt_multi = has_option (line, "--multi"); + int opt_reread = has_option (line, "--reread"); + unsigned int flags; if ((rc = open_card (ctrl))) return rc; @@ -559,11 +562,16 @@ cmd_learn (assuan_context_t ctx, char *line) /* Let the application print out its collection of useful status information. */ + flags = 0; + if (only_keypairinfo) + flags |= APP_LEARN_FLAG_KEYPAIRINFO; + if (opt_multi) + flags |= APP_LEARN_FLAG_MULTI; + if (opt_reread) + flags |= APP_LEARN_FLAG_REREAD; + if (!rc) - rc = app_write_learn_status - (ctrl->card_ctx, ctrl, - ( (only_keypairinfo? APP_LEARN_FLAG_KEYPAIRINFO : 0) - | (opt_multi? APP_LEARN_FLAG_MULTI : 0)) ); + rc = app_write_learn_status (ctrl->card_ctx, ctrl, flags); return rc; } -- cgit v1.2.3