1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* assuan-handler.c (assuan_set_okay_line): New.

(process_request): And use it here.
This commit is contained in:
Werner Koch 2002-01-10 19:46:04 +00:00
parent 6fd5b6d5ed
commit 489207db37
6 changed files with 56 additions and 5 deletions

View file

@ -382,7 +382,7 @@ process_request (ASSUAN_CONTEXT ctx)
/* Error handling */
if (!rc)
{
rc = assuan_write_line (ctx, "OK");
rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK");
}
else if (rc == -1)
{ /* No error checking because the peer may have already disconnect */
@ -405,6 +405,11 @@ process_request (ASSUAN_CONTEXT ctx)
rc = assuan_write_line (ctx, errline);
}
if (ctx->okay_line)
{
xfree (ctx->okay_line);
ctx->okay_line = NULL;
}
return rc;
}
@ -522,6 +527,35 @@ assuan_get_data_fp (ASSUAN_CONTEXT ctx)
}
/* Set the text used for the next OK reponse. This string is
automatically reset to NULL after the next command. */
AssuanError
assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line)
{
if (!ctx)
return ASSUAN_Invalid_Value;
if (!line)
{
xfree (ctx->okay_line);
ctx->okay_line = NULL;
}
else
{
/* FIXME: we need to use gcry_is_secure() to test whether
we should allocate the entire line in secure memory */
char *buf = xtrymalloc (3+strlen(line)+1);
if (!buf)
return ASSUAN_Out_Of_Core;
strcpy (buf, "OK ");
strcpy (buf+3, line);
xfree (ctx->okay_line);
ctx->okay_line = buf;
}
return 0;
}
void
assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text)
{