aboutsummaryrefslogtreecommitdiffstats
path: root/assuan/assuan-handler.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2002-01-10 19:46:04 +0000
committerWerner Koch <[email protected]>2002-01-10 19:46:04 +0000
commit489207db377d9b3c192cbcf437b0ea0c68c41d61 (patch)
tree519b09873ed74dfad73eb4ac55b3300f4d9f1ec4 /assuan/assuan-handler.c
parent* genkey.c: Store the secret part and return the public part. (diff)
downloadgnupg-489207db377d9b3c192cbcf437b0ea0c68c41d61.tar.gz
gnupg-489207db377d9b3c192cbcf437b0ea0c68c41d61.zip
* assuan-handler.c (assuan_set_okay_line): New.
(process_request): And use it here.
Diffstat (limited to 'assuan/assuan-handler.c')
-rw-r--r--assuan/assuan-handler.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c
index a82bd5379..ce7476a6a 100644
--- a/assuan/assuan-handler.c
+++ b/assuan/assuan-handler.c
@@ -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)
{