mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
* assuan-handler.c (assuan_set_okay_line): New.
(process_request): And use it here.
This commit is contained in:
parent
6fd5b6d5ed
commit
489207db37
@ -1,3 +1,14 @@
|
||||
2002-01-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* assuan-handler.c (assuan_set_okay_line): New.
|
||||
(process_request): And use it here.
|
||||
|
||||
2002-01-02 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* assuan-inquire.c (init_membuf,put_membuf,get_membuf): Apply a
|
||||
hidden 0 behind the buffer so that the buffer can be used as a
|
||||
string in certain contexts.
|
||||
|
||||
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* assuan-connect.c (assuan_pipe_connect): New argument
|
||||
@ -90,7 +101,7 @@
|
||||
* You may find it source-copied in other packages. *
|
||||
***********************************************************
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software; as a special exception the author gives
|
||||
unlimited permission to copy and/or distribute it, with or without
|
||||
|
@ -39,6 +39,7 @@ struct assuan_context_s {
|
||||
int is_server; /* set if this is context belongs to a server */
|
||||
int in_inquire;
|
||||
char *hello_line;
|
||||
char *okay_line; /* see assan_set_okay_line() */
|
||||
|
||||
void *user_pointer; /* for assuan_[gs]et_pointer () */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* assuan-inquire.c - handle inquire stuff
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
@ -56,7 +56,8 @@ init_membuf (struct membuf *mb, int initiallen, size_t maxlen)
|
||||
mb->out_of_core = 0;
|
||||
mb->too_large = 0;
|
||||
mb->maxlen = maxlen;
|
||||
mb->buf = xtrymalloc (initiallen);
|
||||
/* we need to allocate one byte more for get_membuf */
|
||||
mb->buf = xtrymalloc (initiallen+1);
|
||||
if (!mb->buf)
|
||||
mb->out_of_core = 1;
|
||||
}
|
||||
@ -78,7 +79,8 @@ put_membuf (struct membuf *mb, const void *buf, size_t len)
|
||||
char *p;
|
||||
|
||||
mb->size += len + 1024;
|
||||
p = xtryrealloc (mb->buf, mb->size);
|
||||
/* we need to allocate one byte more for get_membuf */
|
||||
p = xtryrealloc (mb->buf, mb->size+1);
|
||||
if (!p)
|
||||
{
|
||||
mb->out_of_core = 1;
|
||||
@ -102,6 +104,7 @@ get_membuf (struct membuf *mb, size_t *len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mb->buf[mb->len] = 0; /* there is enough space for the hidden eos */
|
||||
p = mb->buf;
|
||||
*len = mb->len;
|
||||
mb->buf = NULL;
|
||||
|
@ -58,6 +58,7 @@ assuan_deinit_pipe_server (ASSUAN_CONTEXT ctx)
|
||||
if (ctx)
|
||||
{
|
||||
xfree (ctx->hello_line);
|
||||
xfree (ctx->okay_line);
|
||||
xfree (ctx);
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ int assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what,
|
||||
|
||||
|
||||
FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx);
|
||||
AssuanError assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line);
|
||||
void assuan_write_status (ASSUAN_CONTEXT ctx,
|
||||
const char *keyword, const char *text);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user