diff options
author | Neal Walfield <[email protected]> | 2003-02-18 02:41:58 +0000 |
---|---|---|
committer | Neal Walfield <[email protected]> | 2003-02-18 02:41:58 +0000 |
commit | 95f307d9b5511ba70fa92838b2b13f6b42776205 (patch) | |
tree | 6d86f49fe8af12df2bc00a22e6bce8cbd3d0fd66 /src/assuan-buffer.c | |
parent | 2002-11-24 Neal H. Walfield <[email protected]> (diff) | |
download | libassuan-95f307d9b5511ba70fa92838b2b13f6b42776205.tar.gz libassuan-95f307d9b5511ba70fa92838b2b13f6b42776205.zip |
2003-02-17 Neal H. Walfield <[email protected]>
* Makefile.am (lib_LIBRARIES): Use this instead of . . .
(noinst_LIBRARIES): . . . this.
(include_HEADERS): New variable.
(libassuan_a_SOURCES): Remove assuan.h, add assuan-logging.c.
* assuan.h (assuan_set_assuan_log_stream): New prototype.
(assuan_get_assuan_log_stream): Likewise.
(assuan_get_assuan_log_prefix): Likewise.
* assuan-logging.c: New file.
* assuan-buffer.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(my_log_prefix): Remove function.
(_assuan_read_line): Use assuan_get_assuan_log_prefix in lieu of
my_log_prefix.
(assuan_write_line): Likewise.
(_assuan_cookie_write_data): Likewise.
(_assuan_cookie_write_flush): Likewise.
* assuan-domain-connect.c (LOGERROR, LOGERROR1, LOGERROR2,
LOGERRORX): Remove.
(LOG): New macro.
(domain_reader): Use it.
(domain_writer): Likewise.
(domain_sendfd): Likewise.
(domain_receivefd): Likewise.
(_assuan_domain_init): Likewise.
(assuan_domain_connect): Likewise.
* assuan-pipe-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_pipe_connect): Use it.
* assuan-socket-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_socket_connect): Use it.
(socket_reader): Remove dead code.
(socket_writer): Likewise.
* assuan-util.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(_assuan_log_sanitized_string): Use assuan_get_assuan_log_stream,
not jnlib.
Diffstat (limited to '')
-rw-r--r-- | src/assuan-buffer.c | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c index bbe3990..59518f2 100644 --- a/src/assuan-buffer.c +++ b/src/assuan-buffer.c @@ -1,5 +1,5 @@ /* assuan-buffer.c - read and send data - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -27,22 +27,6 @@ #include <assert.h> #include "assuan-defs.h" -#ifdef HAVE_JNLIB_LOGGING -#include "../jnlib/logging.h" -#endif - - -static const char * -my_log_prefix (void) -{ -#ifdef HAVE_JNLIB_LOGGING - return log_get_prefix (NULL); -#else - return ""; -#endif -} - - static int writen (ASSUAN_CONTEXT ctx, const char *buffer, size_t length) { @@ -141,16 +125,17 @@ _assuan_read_line (ASSUAN_CONTEXT ctx) if (rc) { if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%p] <- [Error: %s]\n", - my_log_prefix (), ctx, strerror (errno)); + fprintf (ctx->log_fp, "%s[%p] <- [Error: %s]\n", + assuan_get_assuan_log_prefix (), ctx, strerror (errno)); return ASSUAN_Read_Error; } if (!nread) { assert (ctx->inbound.eof); if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%p] <- [EOF]\n", my_log_prefix (),ctx); - return -1; + fprintf (ctx->log_fp, "%s[%p] <- [EOF]\n", + assuan_get_assuan_log_prefix (), ctx); + return -1; } ctx->inbound.attic.pending = 0; @@ -180,11 +165,12 @@ _assuan_read_line (ASSUAN_CONTEXT ctx) ctx->inbound.linelen = endp - line; if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%p] <- ", my_log_prefix (), ctx); + fprintf (ctx->log_fp, "%s[%p] <- ", + assuan_get_assuan_log_prefix (), ctx); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else - _assuan_log_print_buffer (ctx->log_fp, + _assuan_log_print_buffer (ctx->log_fp, ctx->inbound.line, ctx->inbound.linelen); putc ('\n', ctx->log_fp); @@ -195,7 +181,7 @@ _assuan_read_line (ASSUAN_CONTEXT ctx) { if (ctx->log_fp) fprintf (ctx->log_fp, "%s[%p] <- [Invalid line]\n", - my_log_prefix (), ctx); + assuan_get_assuan_log_prefix (), ctx); *line = 0; ctx->inbound.linelen = 0; return ctx->inbound.eof ? ASSUAN_Line_Not_Terminated @@ -255,13 +241,14 @@ assuan_write_line (ASSUAN_CONTEXT ctx, const char *line) /* fixme: we should do some kind of line buffering. */ if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx); + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); if (s) - fputs ("[supplied line contained a LF]", ctx->log_fp); + fputs ("[supplied line contained a LF]", ctx->log_fp); if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); + fputs ("[Confidential data not shown]", ctx->log_fp); else - _assuan_log_print_buffer (ctx->log_fp, line, len); + _assuan_log_print_buffer (ctx->log_fp, line, len); putc ('\n', ctx->log_fp); } @@ -327,7 +314,9 @@ _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size) { if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx); + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); + if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -371,15 +360,15 @@ _assuan_cookie_write_flush (void *cookie) if (linelen) { if (ctx->log_fp) - { - fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx); - if (ctx->confidential) - fputs ("[Confidential data not shown]", ctx->log_fp); - else - _assuan_log_print_buffer (ctx->log_fp, - ctx->outbound.data.line, - linelen); - putc ('\n', ctx->log_fp); + { + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); + if (ctx->confidential) + fputs ("[Confidential data not shown]", ctx->log_fp); + else + _assuan_log_print_buffer (ctx->log_fp, + ctx->outbound.data.line, linelen); + putc ('\n', ctx->log_fp); } *line++ = '\n'; linelen++; |