From 95f307d9b5511ba70fa92838b2b13f6b42776205 Mon Sep 17 00:00:00 2001 From: Neal Walfield Date: Tue, 18 Feb 2003 02:41:58 +0000 Subject: 2003-02-17 Neal H. Walfield * 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. --- src/assuan-buffer.c | 65 ++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) (limited to 'src/assuan-buffer.c') 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 #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++; -- cgit v1.2.3