From 312ee41ff7b22f250ef12cfb97d287d2f62ec57c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 12 Jun 2002 14:35:41 +0000 Subject: [PATCH] * call-dirmngr.c (lookup_status_cb): New. (gpgsm_dirmngr_lookup): Use the status CB. Add new arg CTRL and changed caller to pass it. --- sm/ChangeLog | 4 ++++ sm/call-dirmngr.c | 25 +++++++++++++++++++++---- sm/gpgsm.h | 2 +- sm/keylist.c | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sm/ChangeLog b/sm/ChangeLog index bd3e6c34a..6cd7e7d83 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,5 +1,9 @@ 2002-06-12 Werner Koch + * call-dirmngr.c (lookup_status_cb): New. + (gpgsm_dirmngr_lookup): Use the status CB. Add new arg CTRL and + changed caller to pass it. + * gpgsm.c (open_fwrite): New. (main): Allow --output for --verify. diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c index 7e6a35912..312886692 100644 --- a/sm/call-dirmngr.c +++ b/sm/call-dirmngr.c @@ -51,6 +51,7 @@ struct inq_certificate_parm_s { }; struct lookup_parm_s { + CTRL ctrl; ASSUAN_CONTEXT ctx; void (*cb)(void *, KsbaCert); void *cb_value; @@ -415,12 +416,27 @@ pattern_from_strlist (STRLIST names) return pattern; } +static AssuanError +lookup_status_cb (void *opaque, const char *line) +{ + struct lookup_parm_s *parm = opaque; + int i; + + if (!strncmp (line, "TRUNCATED", 9) && (line[9]==' ' || !line[9])) + { + for (line +=9; *line == ' '; line++) + ; + gpgsm_status (parm->ctrl, STATUS_TRUNCATED, line); + } + return 0; +} + /* Run the Directroy Managers lookup command using the apptern compiled from the strings given in NAMES. The caller must provide the callback CB which will be passed cert by cert. */ int -gpgsm_dirmngr_lookup (STRLIST names, +gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names, void (*cb)(void*, KsbaCert), void *cb_value) { int rc; @@ -429,8 +445,6 @@ gpgsm_dirmngr_lookup (STRLIST names, struct lookup_parm_s parm; size_t len; - /* FIXME: Set an status handler so that we can get the TRUNCATED code */ - rc = start_dirmngr (); if (rc) return rc; @@ -442,6 +456,7 @@ gpgsm_dirmngr_lookup (STRLIST names, line[DIM(line)-1] = 0; xfree (pattern); + parm.ctrl = ctrl; parm.ctx = dirmngr_ctx; parm.cb = cb; parm.cb_value = cb_value; @@ -449,9 +464,11 @@ gpgsm_dirmngr_lookup (STRLIST names, init_membuf (&parm.data, 4096); rc = assuan_transact (dirmngr_ctx, line, lookup_cb, &parm, - NULL, NULL, NULL, NULL); + NULL, NULL, lookup_status_cb, &parm); xfree (get_membuf (&parm.data, &len)); if (rc) return map_assuan_err (rc); return parm.error; } + + diff --git a/sm/gpgsm.h b/sm/gpgsm.h index 2ecb3169e..43c154364 100644 --- a/sm/gpgsm.h +++ b/sm/gpgsm.h @@ -240,7 +240,7 @@ int gpgsm_agent_learn (void); /*-- call-dirmngr.c --*/ int gpgsm_dirmngr_isvalid (KsbaCert cert); -int gpgsm_dirmngr_lookup (STRLIST names, +int gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names, void (*cb)(void*, KsbaCert), void *cb_value); diff --git a/sm/keylist.c b/sm/keylist.c index d52790f2b..65171a1d4 100644 --- a/sm/keylist.c +++ b/sm/keylist.c @@ -586,7 +586,7 @@ list_external_keys (CTRL ctrl, STRLIST names, FILE *fp) parm.with_colons = ctrl->with_colons; parm.with_chain = ctrl->with_chain; - rc = gpgsm_dirmngr_lookup (names, list_external_cb, &parm); + rc = gpgsm_dirmngr_lookup (ctrl, names, list_external_cb, &parm); if (rc) log_error ("listing external keys failed: %s\n", gnupg_strerror (rc)); }