diff options
-rw-r--r-- | g10/call-agent.c | 7 | ||||
-rw-r--r-- | g10/call-agent.h | 1 | ||||
-rw-r--r-- | g10/card-util.c | 32 |
3 files changed, 38 insertions, 2 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c index 8f4e44b32..7c21a9a84 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -539,6 +539,13 @@ learn_status_cb (void *opaque, const char *line) xfree (parm->apptype); parm->apptype = unescape_status_string (line); } + else if (keywordlen == 10 && !memcmp (keyword, "APPVERSION", keywordlen)) + { + unsigned int val = 0; + + sscanf (line, "%x", &val); + parm->appversion = val; + } else if (keywordlen == 9 && !memcmp (keyword, "DISP-NAME", keywordlen)) { xfree (parm->disp_name); diff --git a/g10/call-agent.h b/g10/call-agent.h index efea7ec4a..a4cbc3162 100644 --- a/g10/call-agent.h +++ b/g10/call-agent.h @@ -32,6 +32,7 @@ struct agent_card_info_s int error; /* private. */ char *reader; /* Reader information. */ char *apptype; /* Malloced application type string. */ + unsigned int appversion; /* Version of the application. */ unsigned int manufacturer_id; char *manufacturer_name; /* malloced. */ char *serialno; /* malloced hex string. */ diff --git a/g10/card-util.c b/g10/card-util.c index f3ede6d46..a5f1f7bb7 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -348,6 +348,26 @@ fpr_is_ff (const char *fpr, unsigned int fprlen) } +static void +print_a_version (estream_t fp, const char *prefix, unsigned int value) +{ + unsigned int a, b, c, d; + a = ((value >> 24) & 0xff); + b = ((value >> 16) & 0xff); + c = ((value >> 8) & 0xff); + d = ((value ) & 0xff); + + if (a) + tty_fprintf (fp, "%s %u.%u.%u.%u\n", prefix, a, b, c, d); + else if (b) + tty_fprintf (fp, "%s %u.%u.%u\n", prefix, b, c, d); + else if (c) + tty_fprintf (fp, "%s %u.%u\n", prefix, c, d); + else + tty_fprintf (fp, "%s %u\n", prefix, d); +} + + /* Print all available information about the current card. */ static void current_card_status (ctrl_t ctrl, estream_t fp, @@ -448,7 +468,12 @@ current_card_status (ctrl_t ctrl, estream_t fp, if (opt.with_colons) { - es_fprintf (fp, "version:%.4s:\n", info.serialno+12); + if (info.appversion) + es_fprintf (fp, "version:%02u%02u:\n", + (info.appversion >> 8) & 0xff, + info.appversion & 0xff); + else + es_fprintf (fp, "version:%.4s:\n", info.serialno+12); uval = xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18); pesc = (info.manufacturer_name ? percent_escape (info.manufacturer_name, NULL) : NULL); @@ -548,7 +573,10 @@ current_card_status (ctrl_t ctrl, estream_t fp, } else { - tty_fprintf (fp, "Version ..........: %.1s%c.%.1s%c\n", + if (info.appversion) + print_a_version (fp, "Version ..........:", info.appversion); + else + tty_fprintf (fp, "Version ..........: %.1s%c.%.1s%c\n", info.serialno[12] == '0'?"":info.serialno+12, info.serialno[13], info.serialno[14] == '0'?"":info.serialno+14, |