1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02: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

@ -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;
}