2001-11-24 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (gpgsm_status_handler): Don't break if bsearch fails. Deal with assuan read line returning more than one line (for now).
This commit is contained in:
parent
46bb2a4470
commit
a22eef99a2
@ -1,3 +1,8 @@
|
|||||||
|
2001-11-24 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (gpgsm_status_handler): Don't break if bsearch fails.
|
||||||
|
Deal with assuan read line returning more than one line (for now).
|
||||||
|
|
||||||
2001-11-23 Marcus Brinkmann <marcus@g10code.de>
|
2001-11-23 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement it according to
|
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement it according to
|
||||||
|
@ -467,21 +467,33 @@ gpgsm_status_handler (void *opaque, int pid, int fd)
|
|||||||
int err;
|
int err;
|
||||||
GpgsmObject gpgsm = opaque;
|
GpgsmObject gpgsm = opaque;
|
||||||
ASSUAN_CONTEXT actx = gpgsm->assuan_ctx;
|
ASSUAN_CONTEXT actx = gpgsm->assuan_ctx;
|
||||||
|
char *line;
|
||||||
|
int linelen;
|
||||||
|
char *next_line;
|
||||||
|
|
||||||
assert (fd == gpgsm->assuan_ctx->inbound.fd);
|
assert (fd == gpgsm->assuan_ctx->inbound.fd);
|
||||||
|
|
||||||
err = _assuan_read_line (gpgsm->assuan_ctx);
|
err = _assuan_read_line (gpgsm->assuan_ctx);
|
||||||
|
|
||||||
if (actx->inbound.line[0] == '#' || !actx->inbound.linelen)
|
/* Assuan can currently return more than one line at once. */
|
||||||
|
line = actx->inbound.line;
|
||||||
|
|
||||||
|
while (line)
|
||||||
|
{
|
||||||
|
next_line = strchr (line, '\n');
|
||||||
|
if (next_line)
|
||||||
|
*next_line++ = 0;
|
||||||
|
linelen = strlen (line);
|
||||||
|
|
||||||
|
if (line[0] == '#' || !linelen)
|
||||||
return 0; /* FIXME */
|
return 0; /* FIXME */
|
||||||
|
|
||||||
if ((actx->inbound.linelen >= 2
|
if ((linelen >= 2
|
||||||
&& actx->inbound.line[0] == 'O' && actx->inbound.line[1] == 'K'
|
&& line[0] == 'O' && line[1] == 'K'
|
||||||
&& (actx->inbound.line[2] == '\0' || actx->inbound.line[2] == ' '))
|
&& (line[2] == '\0' || line[2] == ' '))
|
||||||
|| (actx->inbound.linelen >= 3
|
|| (linelen >= 3
|
||||||
&& actx->inbound.line[0] == 'E' && actx->inbound.line[1] == 'R'
|
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
|
||||||
&& actx->inbound.line[2] == 'R'
|
&& (line[3] == '\0' || line[3] == ' ')))
|
||||||
&& (actx->inbound.line[3] == '\0' || actx->inbound.line[3] == ' ')))
|
|
||||||
{
|
{
|
||||||
/* FIXME Save error somewhere. */
|
/* FIXME Save error somewhere. */
|
||||||
if (gpgsm->status.fnc)
|
if (gpgsm->status.fnc)
|
||||||
@ -490,27 +502,33 @@ gpgsm_status_handler (void *opaque, int pid, int fd)
|
|||||||
}
|
}
|
||||||
/* FIXME: Parse the status and call the handler. */
|
/* FIXME: Parse the status and call the handler. */
|
||||||
|
|
||||||
if (actx->inbound.linelen > 2
|
if (linelen > 2
|
||||||
&& actx->inbound.line[0] == 'S' && actx->inbound.line[1] == ' ')
|
&& line[0] == 'S' && line[1] == ' ')
|
||||||
{
|
{
|
||||||
struct status_table_s t, *r;
|
struct status_table_s t, *r;
|
||||||
char *rest;
|
char *rest;
|
||||||
|
|
||||||
rest = strchr (actx->inbound.line + 2, ' ');
|
rest = strchr (line + 2, ' ');
|
||||||
if (!rest)
|
if (!rest)
|
||||||
rest = actx->inbound.line + actx->inbound.linelen; /* set to an empty string */
|
rest = line + linelen; /* set to an empty string */
|
||||||
else
|
else
|
||||||
*rest++ = 0;
|
*rest++ = 0;
|
||||||
|
|
||||||
t.name = actx->inbound.line + 2;
|
t.name = line + 2;
|
||||||
r = bsearch (&t, status_table, DIM(status_table) - 1,
|
r = bsearch (&t, status_table, DIM(status_table) - 1,
|
||||||
sizeof t, status_cmp);
|
sizeof t, status_cmp);
|
||||||
|
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
if (gpgsm->status.fnc)
|
if (gpgsm->status.fnc)
|
||||||
gpgsm->status.fnc (gpgsm->status.fnc_value, r->code, rest);
|
gpgsm->status.fnc (gpgsm->status.fnc_value, r->code, rest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, "[UNCAUGHT STATUS]%s", actx->inbound.line);
|
fprintf (stderr, "[UNKNOWN STATUS]%s %s", t.name, rest);
|
||||||
|
}
|
||||||
|
line = next_line;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user