aboutsummaryrefslogtreecommitdiffstats
path: root/assuan/assuan-buffer.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2002-04-24 01:55:58 +0000
committerMarcus Brinkmann <[email protected]>2002-04-24 01:55:58 +0000
commita559c32a55e3077ee42f82d8794e6383adbb1e41 (patch)
tree0ca7955cbbf3bbf5e60e9b588b93499ab163f0b9 /assuan/assuan-buffer.c
parent* key.c (gpgme_key_get_ulong_attr): Swapped use of can_encrypt and (diff)
downloadgpgme-a559c32a55e3077ee42f82d8794e6383adbb1e41.tar.gz
gpgme-a559c32a55e3077ee42f82d8794e6383adbb1e41.zip
Update assuan and jnlib to 20020424 from newpg.
Diffstat (limited to 'assuan/assuan-buffer.c')
-rw-r--r--assuan/assuan-buffer.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/assuan/assuan-buffer.c b/assuan/assuan-buffer.c
index bd088174..29f94794 100644
--- a/assuan/assuan-buffer.c
+++ b/assuan/assuan-buffer.c
@@ -25,16 +25,37 @@
#include <errno.h>
#include <unistd.h>
#include <assert.h>
-
+#ifdef USE_GNU_PTH
+# include <pth.h>
+#endif
#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 ( int fd, const char *buffer, size_t length )
{
while (length)
{
+#ifdef USE_GNU_PTH
+ int nwritten = pth_write (fd, buffer, length);
+#else
int nwritten = write (fd, buffer, length);
+#endif
if (nwritten < 0)
{
@@ -59,7 +80,11 @@ readline (int fd, char *buf, size_t buflen, int *r_nread, int *eof)
*r_nread = 0;
while (nleft > 0)
{
+#ifdef USE_GNU_PTH
+ int n = pth_read (fd, buf, nleft);
+#else
int n = read (fd, buf, nleft);
+#endif
if (n < 0)
{
if (errno == EINTR)
@@ -122,15 +147,15 @@ _assuan_read_line (ASSUAN_CONTEXT ctx)
if (rc)
{
if (ctx->log_fp)
- fprintf (ctx->log_fp, "%p <- [Error: %s]\n",
- ctx, strerror (errno));
+ fprintf (ctx->log_fp, "%s[%p] <- [Error: %s]\n",
+ my_log_prefix (), ctx, strerror (errno));
return ASSUAN_Read_Error;
}
if (!nread)
{
assert (ctx->inbound.eof);
if (ctx->log_fp)
- fprintf (ctx->log_fp, "%p <- [EOF]\n", ctx);
+ fprintf (ctx->log_fp, "%s[%p] <- [EOF]\n", my_log_prefix (),ctx);
return -1;
}
@@ -163,7 +188,7 @@ _assuan_read_line (ASSUAN_CONTEXT ctx)
ctx->inbound.linelen = n;
if (ctx->log_fp)
{
- fprintf (ctx->log_fp, "%p <- ", ctx);
+ fprintf (ctx->log_fp, "%s[%p] <- ", my_log_prefix (), ctx);
if (ctx->confidential)
fputs ("[Confidential data not shown]", ctx->log_fp);
else
@@ -177,7 +202,7 @@ _assuan_read_line (ASSUAN_CONTEXT ctx)
}
if (ctx->log_fp)
- fprintf (ctx->log_fp, "%p <- [Invalid line]\n", ctx);
+ fprintf (ctx->log_fp, "%s[%p] <- [Invalid line]\n", my_log_prefix (), ctx);
*line = 0;
ctx->inbound.linelen = 0;
return ctx->inbound.eof? ASSUAN_Line_Not_Terminated : ASSUAN_Line_Too_Long;
@@ -229,7 +254,7 @@ 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, "%p -> ", ctx);
+ fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx);
if (ctx->confidential)
fputs ("[Confidential data not shown]", ctx->log_fp);
else
@@ -300,7 +325,7 @@ _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size)
{
if (ctx->log_fp)
{
- fprintf (ctx->log_fp, "%p -> ", ctx);
+ fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx);
if (ctx->confidential)
fputs ("[Confidential data not shown]", ctx->log_fp);
else
@@ -345,7 +370,7 @@ _assuan_cookie_write_flush (void *cookie)
{
if (ctx->log_fp)
{
- fprintf (ctx->log_fp, "%p -> ", ctx);
+ fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx);
if (ctx->confidential)
fputs ("[Confidential data not shown]", ctx->log_fp);
else