1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

* call-dirmngr.c (lookup_status_cb): New.

(gpgsm_dirmngr_lookup): Use the status CB.  Add new arg CTRL and
changed caller to pass it.
This commit is contained in:
Werner Koch 2002-06-12 14:35:41 +00:00
parent 7ca4df0a9a
commit 312ee41ff7
4 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,9 @@
2002-06-12 Werner Koch <wk@gnupg.org> 2002-06-12 Werner Koch <wk@gnupg.org>
* 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. * gpgsm.c (open_fwrite): New.
(main): Allow --output for --verify. (main): Allow --output for --verify.

View File

@ -51,6 +51,7 @@ struct inq_certificate_parm_s {
}; };
struct lookup_parm_s { struct lookup_parm_s {
CTRL ctrl;
ASSUAN_CONTEXT ctx; ASSUAN_CONTEXT ctx;
void (*cb)(void *, KsbaCert); void (*cb)(void *, KsbaCert);
void *cb_value; void *cb_value;
@ -415,12 +416,27 @@ pattern_from_strlist (STRLIST names)
return pattern; 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 /* Run the Directroy Managers lookup command using the apptern
compiled from the strings given in NAMES. The caller must provide compiled from the strings given in NAMES. The caller must provide
the callback CB which will be passed cert by cert. */ the callback CB which will be passed cert by cert. */
int int
gpgsm_dirmngr_lookup (STRLIST names, gpgsm_dirmngr_lookup (CTRL ctrl, STRLIST names,
void (*cb)(void*, KsbaCert), void *cb_value) void (*cb)(void*, KsbaCert), void *cb_value)
{ {
int rc; int rc;
@ -429,8 +445,6 @@ gpgsm_dirmngr_lookup (STRLIST names,
struct lookup_parm_s parm; struct lookup_parm_s parm;
size_t len; size_t len;
/* FIXME: Set an status handler so that we can get the TRUNCATED code */
rc = start_dirmngr (); rc = start_dirmngr ();
if (rc) if (rc)
return rc; return rc;
@ -442,6 +456,7 @@ gpgsm_dirmngr_lookup (STRLIST names,
line[DIM(line)-1] = 0; line[DIM(line)-1] = 0;
xfree (pattern); xfree (pattern);
parm.ctrl = ctrl;
parm.ctx = dirmngr_ctx; parm.ctx = dirmngr_ctx;
parm.cb = cb; parm.cb = cb;
parm.cb_value = cb_value; parm.cb_value = cb_value;
@ -449,9 +464,11 @@ gpgsm_dirmngr_lookup (STRLIST names,
init_membuf (&parm.data, 4096); init_membuf (&parm.data, 4096);
rc = assuan_transact (dirmngr_ctx, line, lookup_cb, &parm, 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)); xfree (get_membuf (&parm.data, &len));
if (rc) if (rc)
return map_assuan_err (rc); return map_assuan_err (rc);
return parm.error; return parm.error;
} }

View File

@ -240,7 +240,7 @@ int gpgsm_agent_learn (void);
/*-- call-dirmngr.c --*/ /*-- call-dirmngr.c --*/
int gpgsm_dirmngr_isvalid (KsbaCert cert); 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); void (*cb)(void*, KsbaCert), void *cb_value);

View File

@ -586,7 +586,7 @@ list_external_keys (CTRL ctrl, STRLIST names, FILE *fp)
parm.with_colons = ctrl->with_colons; parm.with_colons = ctrl->with_colons;
parm.with_chain = ctrl->with_chain; 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) if (rc)
log_error ("listing external keys failed: %s\n", gnupg_strerror (rc)); log_error ("listing external keys failed: %s\n", gnupg_strerror (rc));
} }