aboutsummaryrefslogtreecommitdiffstats
path: root/src/assuan-handler.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2009-09-21 01:08:08 +0000
committerMarcus Brinkmann <[email protected]>2009-09-21 01:08:08 +0000
commitcd87e56dac64c74d45f42838fc1049848f8aadcd (patch)
treeff70f9a6e8601305d06bebb55709350d3d8dbae4 /src/assuan-handler.c
parent2009-09-08 Marcus Brinkmann <[email protected]> (diff)
downloadlibassuan-cd87e56dac64c74d45f42838fc1049848f8aadcd.tar.gz
libassuan-cd87e56dac64c74d45f42838fc1049848f8aadcd.zip
2009-09-19 Marcus Brinkmann <[email protected]>
* tests/fdpassing.c: Update to new API. * configure.ac: Check for stdint.h and inttypes.h. Invoke AC_TYPE_UINTPTR_T. doc/ 2009-09-21 Marcus Brinkmann <[email protected]> * assuan.texi: Update to new API. src/ 2009-09-19 Marcus Brinkmann <[email protected]> * src/libassuan.vers, src/libassuan.def: Update to new API. * assuan.c, context.c, system.c, debug.c: New files. * Makefile.am (common_sources): Add assuan.c, context.c, system.c and debug.c. * assuan.h: Include <stdarg.h>. Fix inclusion of <gpg-error.h>. (_ASSUAN_EXT_SYM_PREFIX, _ASSUAN_PREFIX1, _ASSUAN_PREFIX2) (_ASSUAN_PREFIX): Remove support for renaming the whole library, now that we have a stable shared library interface that can evolve to cover all needs (particularly those of GPGME). (assuan_malloc_hooks, assuan_malloc_hooks_t, assuan_log_cb_t) (assuan_io_monitor_t): New types. (ASSUAN_LOG_INIT, ASSUAN_LOG_CTX, ASSUAN_LOG_ENGINE) (ASSUAN_LOG_DATA, ASSUAN_LOG_SYSIO, ASSUAN_IO_FROM_PEER) (ASSUAN_IO_TO_PEER, ASSUAN_IO_MONITOR_NOLOG) (ASSUAN_IO_MONITOR_IGNORE): New symbols. (assuan_set_gpg_err_source, assuan_get_gpg_err_source) (assuan_get_malloc_hooks, assuan_set_log_cb, assuan_get_log_cb) (assuan_new, assuan_new_ext, assuan_release): New function prototypes. (assuan_init_pipe_server, assuan_init_socket_server) (assuan_init_socket_server_ext, assuan_pipe_connect) (assuan_pipe_connect_ext, assuan_socket_connect) (assuan_socket_connect_ext): Take a context argument instead of pointer to context. (assuan_deinit_server, assuan_disconnect) (assuan_set_assuan_err_source): Remove function prototypes. * assuan-defs.h (ASSUAN_GCC_A_PURE): Moved here from XXX (_assuan_error): New macro. (struct assuan_context_s): New members err_source, w32_strerror, malloc_hooks, log_cb, log_cb_data: New members. Move confidential into flags. New member engine. (_assuan_log_handler, _assuan_error_default, _assuan_disconnect): New prototypes. (_assuan_new_context): Remove prototype. (_assuan_malloc, _assuan_calloc, _assuan_realloc, _assuan_free): Add context argument to prototype. * assuan-util.c (alloc_func, realloc_func, free_func): Remove global variables. (assuan_set_malloc_hooks, _assuan_malloc, _assuan_realloc) (_assuan_calloc, _assuan_free, assuan_set_pointer) (assuan_get_pointer, assuan_begin_confidential) (assuan_end_confidential, assuan_set_io_monitor, assuan_set_flag) (assuan_get_flag): Move functions to ... * assuan-client.c: Add ctx argument to all invocations of _assuan_error. * assuan-socket-server.c, assuan-socket-connect.c, assuan-connect.c: Likewise. * assuan-buffer.c: Likewise. Also update access to confidential flag. * assuan-uds.c: Add ctx argument to all invocations of _assuan_malloc, _assuan_realloc, _assuan_calloc, _assuan_free and _assuan_error. * assuan_listen.c, assuan-inquire.c, assuan-handler.c: Likewise. * assuan-error.c (err_source): Remove global variable. (assuan_set_assuan_err_source): Removed function. (_assuan_w32_strerror): Moved here from assuan-logging.c and made thread-safe. (_assuan_error): Removed function (is now macro). * assuan-handler.c: Update access to confidential flag. * assuan-socket-server.c (accept_connection_bottom): Update access to confidential flag in context. (assuan_init_socket_server, assuan_init_socket_server_ext): Take ctx argument instead of pointer to ctx. * assuan-inquire.c (init_membuf, put_membuf, get_membuf) (free_membuf): Take context argument and change all callers. * assuan-socket-server.c (assuan_socket_connect) (assuan_socket_connect_ext): Take ctx argument instead of pointer to ctx. * assuan-pipe-connect.c (initial_handshake, pipe_connect_unix) (socketpair_connect, assuan_pipe_connect) (assuan_pipe_connect_ext): Likewise. (socketpair_connect): Now that ctx is not a pointer argument anymore, return if we are server or client in the argv argument. * assuan-logging.c (_assuan_log_handler): New function. (_assuan_w32_strerror): Move to assuan-error.c * assuan-connect.c (assuan_disconnect): Renamed to ... (_assuan_disconnect): ... this. * assuan-pipe-server.c (_assuan_new_context): Removed function. (assuan_init_pipe_server): Take ctx argument instead of pointer to ctx. (_assuan_release_context): Removed function. (_assuan_deinit_server): Reimplement.
Diffstat (limited to 'src/assuan-handler.c')
-rw-r--r--src/assuan-handler.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 057d7e7..da5d4bf 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -27,7 +27,7 @@
#include <errno.h>
#include "assuan-defs.h"
-
+#include "debug.h"
#define spacep(p) (*(p) == ' ' || *(p) == '\t')
@@ -123,7 +123,7 @@ std_handler_bye (assuan_context_t ctx, char *line)
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
/* pretty simple :-) */
- return PROCESS_DONE (ctx, _assuan_error (GPG_ERR_EOF));
+ return PROCESS_DONE (ctx, _assuan_error (ctx, GPG_ERR_EOF));
}
static gpg_error_t
@@ -287,7 +287,7 @@ assuan_register_command (assuan_context_t ctx,
cmd_name = NULL;
if (!cmd_name)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
if (!handler)
{ /* find a default handler. */
@@ -308,18 +308,18 @@ assuan_register_command (assuan_context_t ctx,
if (!ctx->cmdtbl)
{
ctx->cmdtbl_size = 50;
- ctx->cmdtbl = _assuan_calloc (ctx->cmdtbl_size, sizeof *ctx->cmdtbl);
+ ctx->cmdtbl = _assuan_calloc (ctx, ctx->cmdtbl_size, sizeof *ctx->cmdtbl);
if (!ctx->cmdtbl)
- return _assuan_error (gpg_err_code_from_syserror ());
+ return _assuan_error (ctx, gpg_err_code_from_syserror ());
ctx->cmdtbl_used = 0;
}
else if (ctx->cmdtbl_used >= ctx->cmdtbl_size)
{
struct cmdtbl_s *x;
- x = _assuan_realloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x);
+ x = _assuan_realloc (ctx, ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x);
if (!x)
- return _assuan_error (gpg_err_code_from_syserror ());
+ return _assuan_error (ctx, gpg_err_code_from_syserror ());
ctx->cmdtbl = x;
ctx->cmdtbl_size += 50;
}
@@ -335,7 +335,7 @@ assuan_register_post_cmd_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, gpg_error_t))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->post_cmd_notify_fnc = fnc;
return 0;
}
@@ -345,7 +345,7 @@ assuan_register_bye_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->bye_notify_fnc = fnc;
return 0;
}
@@ -355,7 +355,7 @@ assuan_register_reset_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->reset_notify_fnc = fnc;
return 0;
}
@@ -365,7 +365,7 @@ assuan_register_cancel_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->cancel_notify_fnc = fnc;
return 0;
}
@@ -376,7 +376,7 @@ assuan_register_option_handler (assuan_context_t ctx,
const char*, const char*))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->option_handler_fnc = fnc;
return 0;
}
@@ -386,7 +386,7 @@ assuan_register_input_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->input_notify_fnc = fnc;
return 0;
}
@@ -396,7 +396,7 @@ assuan_register_output_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *))
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
ctx->output_notify_fnc = fnc;
return 0;
}
@@ -508,7 +508,7 @@ gpg_error_t
assuan_process_done (assuan_context_t ctx, gpg_error_t rc)
{
if (!ctx->in_command)
- return _assuan_error (GPG_ERR_ASS_GENERAL);
+ return _assuan_error (ctx, GPG_ERR_ASS_GENERAL);
ctx->in_command = 0;
@@ -557,10 +557,10 @@ assuan_process_done (assuan_context_t ctx, gpg_error_t rc)
if (ctx->post_cmd_notify_fnc)
ctx->post_cmd_notify_fnc (ctx, rc);
- ctx->confidential = 0;
+ ctx->flags.confidential = 0;
if (ctx->okay_line)
{
- _assuan_free (ctx->okay_line);
+ _assuan_free (ctx, ctx->okay_line);
ctx->okay_line = NULL;
}
@@ -613,7 +613,8 @@ process_next (assuan_context_t ctx)
/* Should not happen. The client is sending data while we are
in a command and not waiting for an inquire. We log an error
and discard it. */
- _assuan_log_printf ("unexpected client data\n");
+ TRACE0 (ctx, ASSUAN_LOG_DATA, "process_next", ctx,
+ "unexpected client data");
rc = 0;
}
@@ -649,7 +650,7 @@ process_request (assuan_context_t ctx)
gpg_error_t rc;
if (ctx->in_inquire)
- return _assuan_error (GPG_ERR_ASS_NESTED_COMMANDS);
+ return _assuan_error (ctx, GPG_ERR_ASS_NESTED_COMMANDS);
do
{
@@ -798,22 +799,22 @@ gpg_error_t
assuan_set_okay_line (assuan_context_t ctx, const char *line)
{
if (!ctx)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
if (!line)
{
- _assuan_free (ctx->okay_line);
+ _assuan_free (ctx, 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 = _assuan_malloc (3 + strlen(line) + 1);
+ char *buf = _assuan_malloc (ctx, 3 + strlen(line) + 1);
if (!buf)
- return _assuan_error (gpg_err_code_from_syserror ());
+ return _assuan_error (ctx, gpg_err_code_from_syserror ());
strcpy (buf, "OK ");
strcpy (buf+3, line);
- _assuan_free (ctx->okay_line);
+ _assuan_free (ctx, ctx->okay_line);
ctx->okay_line = buf;
}
return 0;
@@ -831,7 +832,7 @@ assuan_write_status (assuan_context_t ctx,
gpg_error_t ae;
if ( !ctx || !keyword)
- return _assuan_error (GPG_ERR_ASS_INV_VALUE);
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
if (!text)
text = "";
@@ -847,7 +848,7 @@ assuan_write_status (assuan_context_t ctx,
}
ae = assuan_write_line (ctx, buffer);
}
- else if ( (helpbuf = _assuan_malloc (n)) )
+ else if ( (helpbuf = _assuan_malloc (ctx, n)) )
{
strcpy (helpbuf, "S ");
strcat (helpbuf, keyword);
@@ -857,7 +858,7 @@ assuan_write_status (assuan_context_t ctx,
strcat (helpbuf, text);
}
ae = assuan_write_line (ctx, helpbuf);
- _assuan_free (helpbuf);
+ _assuan_free (ctx, helpbuf);
}
else
ae = 0;