2007-07-17 Marcus Brinkmann <marcus@g10code.de>

* debug.c:;5B Include <errno.h> and "debug.h".
	(_gpgme_debug): Save and restore ERRNO.
	(TOHEX): New macro.
	(_gpgme_debug_buffer): New function.
	* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
	gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
	w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants.  In
	most of these files, add many more tracepoints.
This commit is contained in:
Marcus Brinkmann 2007-07-17 12:36:04 +00:00
parent d1e40ac15f
commit d61bf6c13c
18 changed files with 1859 additions and 1236 deletions

View File

@ -1,3 +1,14 @@
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-16 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (status_handler): Do not send BYE here.

View File

@ -1,6 +1,6 @@
/* conversion.c - String conversion helper functions.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
This file is part of GPGME.
@ -30,7 +30,7 @@
#include "gpgme.h"
#include "util.h"
#include "debug.h"
#define atoi_1(p) (*(p) - '0' )
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
@ -392,23 +392,27 @@ static struct
gpgme_error_t
_gpgme_map_gnupg_error (char *err)
_gpgme_map_gnupg_error (char *errstr)
{
unsigned int i;
gpgme_error_t err = gpg_err_make (GPG_ERR_SOURCE_GPG, GPG_ERR_GENERAL);
/* Future version of GnuPG might return the error code directly, so
we first test for a a numerical value and use that verbatim.
Note that this numerical value might be followed by an
underschore and the textual representation of the error code. */
if (*err >= '0' && *err <= '9')
return strtoul (err, NULL, 10);
if (*errstr >= '0' && *errstr <= '9')
return strtoul (errstr, NULL, 10);
/* Well, this is a token, use the mapping table to get the error.
The drawback is that we won't receive an error source and have to
use GPG as source. */
for (i = 0; i < DIM (gnupg_errors); i++)
if (!strcmp (gnupg_errors[i].name, err))
return gpg_err_make (GPG_ERR_SOURCE_GPG, gnupg_errors[i].err);
if (!strcmp (gnupg_errors[i].name, errstr))
err = gpg_err_make (GPG_ERR_SOURCE_GPG, gnupg_errors[i].err);
return gpg_err_make (GPG_ERR_SOURCE_GPG, GPG_ERR_GENERAL);
TRACE3 (DEBUG_CTX, "_gpgme_map_gnupg_error", 0,
"mapped %s to %s <%s>", errstr, gpgme_strerror (err),
gpgme_strsource (err));
return err;
}

View File

@ -1,5 +1,5 @@
/* data-compat.c - Compatibility interfaces for data objects.
Copyright (C) 2002, 2003, 2004 g10 Code GmbH
Copyright (C) 2002, 2003, 2004, 2007 g10 Code GmbH
This file is part of GPGME.
@ -29,26 +29,31 @@
#include "data.h"
#include "util.h"
#include "debug.h"
/* Create a new data buffer filled with LENGTH bytes starting from
OFFSET within the file FNAME or stream STREAM (exactly one must be
non-zero). */
gpgme_error_t
gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
gpgme_data_new_from_filepart (gpgme_data_t *r_dh, const char *fname,
FILE *stream, off_t offset, size_t length)
{
gpgme_error_t err;
char *buf = NULL;
int res;
TRACE_BEG4 (DEBUG_DATA, "gpgme_data_new_from_filepart", r_dh,
"file_name=%s, stream=%p, offset=%lli, length=%u",
fname, stream, offset, length);
if (stream && fname)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (fname)
stream = fopen (fname, "rb");
if (!stream)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
#ifdef HAVE_FSEEKO
res = fseeko (stream, offset, SEEK_SET);
@ -62,7 +67,7 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
int saved_errno = errno;
if (fname)
fclose (stream);
return gpg_error_from_errno (saved_errno);
return TRACE_ERR (gpg_error_from_errno (saved_errno));
}
buf = malloc (length);
@ -71,7 +76,7 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
int saved_errno = errno;
if (fname)
fclose (stream);
return gpg_error_from_errno (saved_errno);
return TRACE_ERR (gpg_error_from_errno (saved_errno));
}
while (fread (buf, length, 1, stream) < 1
@ -83,13 +88,13 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
free (buf);
if (fname)
fclose (stream);
return gpg_error_from_errno (saved_errno);
return TRACE_ERR (gpg_error_from_errno (saved_errno));
}
if (fname)
fclose (stream);
err = gpgme_data_new (dh);
err = gpgme_data_new (r_dh);
if (err)
{
if (buf)
@ -97,68 +102,80 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
return err;
}
(*dh)->data.mem.buffer = buf;
(*dh)->data.mem.size = length;
(*dh)->data.mem.length = length;
return 0;
(*r_dh)->data.mem.buffer = buf;
(*r_dh)->data.mem.size = length;
(*r_dh)->data.mem.length = length;
return TRACE_SUC1 ("r_dh=%p", *r_dh);
}
/* Create a new data buffer filled with the content of file FNAME.
COPY must be non-zero (delayed reads are not supported yet). */
gpgme_error_t
gpgme_data_new_from_file (gpgme_data_t *dh, const char *fname, int copy)
gpgme_data_new_from_file (gpgme_data_t *r_dh, const char *fname, int copy)
{
gpgme_error_t err;
struct stat statbuf;
TRACE_BEG3 (DEBUG_DATA, "gpgme_data_new_from_filepart", r_dh,
"file_name=%s, copy=%i (%s)", fname, copy, copy ? "yes" : "no");
if (!fname || !copy)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (stat (fname, &statbuf) < 0)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
return gpgme_data_new_from_filepart (dh, fname, NULL, 0, statbuf.st_size);
err = gpgme_data_new_from_filepart (r_dh, fname, NULL, 0, statbuf.st_size);
return TRACE_ERR (err);
}
static int
gpgme_error_to_errno (gpgme_error_t err)
{
int no = gpg_err_code_to_errno (err);
int res = gpg_err_code_to_errno (err);
if (no)
if (!err)
{
errno = no;
return -1;
}
switch (gpg_err_code (err))
{
case GPG_ERR_EOF:
return 0;
res = 0;
break;
case GPG_ERR_INV_VALUE:
errno = EINVAL;
return -1;
res = EINVAL;
break;
case GPG_ERR_NOT_SUPPORTED:
errno = ENOSYS;
return -1;
res = ENOSYS;
break;
default:
/* FIXME: Yeah, well. */
errno = EINVAL;
return -1;
res = EINVAL;
break;
}
}
TRACE3 (DEBUG_DATA, "gpgme:gpgme_error_to_errno", 0,
"mapping %s <%s> to: %s", gpgme_strerror (err),
gpgme_strsource (err), strerror (res));
errno = res;
return res ? -1 : 0;
}
static ssize_t
old_user_read (gpgme_data_t dh, void *buffer, size_t size)
{
gpgme_error_t err;
size_t amt;
gpgme_error_t err = (*dh->data.old_user.cb) (dh->data.old_user.handle,
TRACE_BEG2 (DEBUG_DATA, "gpgme:old_user_read", dh,
"buffer=%p, size=%u", buffer, size);
err = (*dh->data.old_user.cb) (dh->data.old_user.handle,
buffer, size, &amt);
if (err)
return gpgme_error_to_errno (err);
return amt;
return TRACE_SYSRES (gpgme_error_to_errno (err));
return TRACE_SYSRES (amt);
}
@ -166,15 +183,18 @@ static off_t
old_user_seek (gpgme_data_t dh, off_t offset, int whence)
{
gpgme_error_t err;
TRACE_BEG2 (DEBUG_DATA, "gpgme:old_user_seek", dh,
"offset=%llu, whence=%i", offset, whence);
if (whence != SEEK_SET || offset)
{
errno = EINVAL;
return -1;
return TRACE_SYSRES (-1);
}
err = (*dh->data.old_user.cb) (dh->data.old_user.handle, NULL, 0, NULL);
if (err)
return gpgme_error_to_errno (err);
return 0;
return TRACE_SYSRES (gpgme_error_to_errno (err));
return TRACE_SYSRES (0);
}
@ -190,23 +210,33 @@ static struct _gpgme_data_cbs old_user_cbs =
/* Create a new data buffer which retrieves the data from the callback
function READ_CB. */
gpgme_error_t
gpgme_data_new_with_read_cb (gpgme_data_t *dh,
gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
int (*read_cb) (void *, char *, size_t, size_t *),
void *read_cb_value)
{
gpgme_error_t err = _gpgme_data_new (dh, &old_user_cbs);
if (err)
return err;
gpgme_error_t err;
TRACE_BEG2 (DEBUG_DATA, "gpgme_data_new_with_read_cb", r_dh,
"read_cb=%p/%p", read_cb, read_cb_value);
(*dh)->data.old_user.cb = read_cb;
(*dh)->data.old_user.handle = read_cb_value;
return 0;
err = _gpgme_data_new (r_dh, &old_user_cbs);
if (err)
return TRACE_ERR (err);
(*r_dh)->data.old_user.cb = read_cb;
(*r_dh)->data.old_user.handle = read_cb_value;
return TRACE_ERR (0);
}
gpgme_error_t
gpgme_data_rewind (gpgme_data_t dh)
{
return (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
gpgme_error_t err;
TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh);
err = (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
? gpg_error_from_errno (errno) : 0;
return TRACE_ERR (err);
}

View File

@ -1,5 +1,5 @@
/* data-mem.c - A memory based data object.
Copyright (C) 2002, 2003, 2004 g10 Code GmbH
Copyright (C) 2002, 2003, 2004, 2007 g10 Code GmbH
This file is part of GPGME.
@ -30,6 +30,7 @@
#include "data.h"
#include "util.h"
#include "debug.h"
static ssize_t
@ -164,13 +165,17 @@ static struct _gpgme_data_cbs mem_cbs =
/* Create a new data buffer and return it in R_DH. */
gpgme_error_t
gpgme_data_new (gpgme_data_t *dh)
gpgme_data_new (gpgme_data_t *r_dh)
{
gpgme_error_t err = _gpgme_data_new (dh, &mem_cbs);
if (err)
return err;
gpgme_error_t err;
TRACE_BEG (DEBUG_DATA, "gpgme_data_new", r_dh);
return 0;
err = _gpgme_data_new (r_dh, &mem_cbs);
if (err)
return TRACE_ERR (err);
return TRACE_SUC1 ("r_dh=%p", *r_dh);
}
@ -178,27 +183,36 @@ gpgme_data_new (gpgme_data_t *dh)
BUFFER. If COPY is zero, copying is delayed until necessary, and
the data is taken from the original location when needed. */
gpgme_error_t
gpgme_data_new_from_mem (gpgme_data_t *dh, const char *buffer,
gpgme_data_new_from_mem (gpgme_data_t *r_dh, const char *buffer,
size_t size, int copy)
{
gpgme_error_t err = _gpgme_data_new (dh, &mem_cbs);
gpgme_error_t err;
TRACE_BEG4 (DEBUG_DATA, "gpgme_data_new_from_mem", r_dh,
"buffer=%p, size=%u, copy=%i (%s)", buffer, size,
copy, copy ? "yes" : "no");
err = _gpgme_data_new (r_dh, &mem_cbs);
if (err)
return err;
return TRACE_ERR (err);
if (copy)
{
char *bufcpy = malloc (size);
if (!bufcpy)
_gpgme_data_release (*dh);
{
int saved_errno = errno;
_gpgme_data_release (*r_dh);
return TRACE_ERR (gpg_error_from_errno (saved_errno));
}
memcpy (bufcpy, buffer, size);
(*dh)->data.mem.buffer = bufcpy;
(*r_dh)->data.mem.buffer = bufcpy;
}
else
(*dh)->data.mem.orig_buffer = buffer;
(*r_dh)->data.mem.orig_buffer = buffer;
(*dh)->data.mem.size = size;
(*dh)->data.mem.length = size;
return 0;
(*r_dh)->data.mem.size = size;
(*r_dh)->data.mem.length = size;
return TRACE_SUC1 ("dh=%p", *r_dh);
}
@ -210,9 +224,13 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
{
char *str = NULL;
TRACE_BEG1 (DEBUG_DATA, "gpgme_data_release_and_get_mem", dh,
"r_len=%p", r_len);
if (!dh || dh->cbs != &mem_cbs)
{
gpgme_data_release (dh);
TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
return NULL;
}
@ -222,7 +240,9 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
str = malloc (dh->data.mem.length);
if (!str)
{
int saved_errno = errno;
gpgme_data_release (dh);
TRACE_ERR (gpg_error_from_errno (saved_errno));
return NULL;
}
memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length);
@ -237,6 +257,7 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
gpgme_data_release (dh);
TRACE_SUC2 ("buffer=%p, len=%u", str, *r_len);
return str;
}
@ -245,7 +266,8 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
void
gpgme_free (void *buffer)
{
TRACE (DEBUG_DATA, "gpgme_free", buffer);
if (buffer)
free (buffer);
}

View File

@ -1,5 +1,5 @@
/* data.c - An abstraction for data objects.
Copyright (C) 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -32,6 +32,7 @@
#include "util.h"
#include "ops.h"
#include "priv-io.h"
#include "debug.h"
gpgme_error_t
@ -72,17 +73,22 @@ _gpgme_data_release (gpgme_data_t dh)
ssize_t
gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size)
{
ssize_t res;
TRACE_BEG2 (DEBUG_DATA, "gpgme_data_read", dh,
"buffer=%p, size=%u", buffer, size);
if (!dh)
{
errno = EINVAL;
return -1;
return TRACE_SYSRES (-1);
}
if (!dh->cbs->read)
{
errno = ENOSYS;
return -1;
return TRACE_SYSRES (-1);
}
return (*dh->cbs->read) (dh, buffer, size);
res = (*dh->cbs->read) (dh, buffer, size);
return TRACE_SYSRES (res);
}
@ -92,17 +98,22 @@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size)
ssize_t
gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size)
{
ssize_t res;
TRACE_BEG2 (DEBUG_DATA, "gpgme_data_write", dh,
"buffer=%p, size=%u", buffer, size);
if (!dh)
{
errno = EINVAL;
return -1;
return TRACE_SYSRES (-1);
}
if (!dh->cbs->write)
{
errno = ENOSYS;
return -1;
return TRACE_SYSRES (-1);
}
return (*dh->cbs->write) (dh, buffer, size);
res = (*dh->cbs->write) (dh, buffer, size);
return TRACE_SYSRES (res);
}
@ -112,15 +123,18 @@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size)
off_t
gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence)
{
TRACE_BEG2 (DEBUG_DATA, "gpgme_data_seek", dh,
"offset=%lli, whence=%i", offset, whence);
if (!dh)
{
errno = EINVAL;
return -1;
return TRACE_SYSRES (-1);
}
if (!dh->cbs->seek)
{
errno = ENOSYS;
return -1;
return TRACE_SYSRES (-1);
}
/* For relative movement, we must take into account the actual
@ -132,7 +146,7 @@ gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence)
if (offset >= 0)
dh->pending_len = 0;
return offset;
return TRACE_SYSRES (offset);
}
@ -140,6 +154,8 @@ gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence)
void
gpgme_data_release (gpgme_data_t dh)
{
TRACE (DEBUG_DATA, "gpgme_data_release", dh);
if (!dh)
return;
@ -154,6 +170,8 @@ gpgme_data_release (gpgme_data_t dh)
gpgme_data_encoding_t
gpgme_data_get_encoding (gpgme_data_t dh)
{
TRACE1 (DEBUG_DATA, "gpgme_data_get_encoding", dh,
"dh->encoding=%i", dh ? dh->encoding : GPGME_DATA_ENCODING_NONE);
return dh ? dh->encoding : GPGME_DATA_ENCODING_NONE;
}
@ -163,12 +181,14 @@ gpgme_data_get_encoding (gpgme_data_t dh)
gpgme_error_t
gpgme_data_set_encoding (gpgme_data_t dh, gpgme_data_encoding_t enc)
{
TRACE_BEG1 (DEBUG_DATA, "gpgme_data_set_encoding", dh,
"encoding=%i", enc);
if (!dh)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
dh->encoding = enc;
return 0;
return TRACE_ERR (0);
}
@ -177,8 +197,11 @@ gpgme_data_set_encoding (gpgme_data_t dh, gpgme_data_encoding_t enc)
gpgme_error_t
gpgme_data_set_file_name (gpgme_data_t dh, const char *file_name)
{
TRACE_BEG1 (DEBUG_DATA, "gpgme_data_set_file_name", dh,
"file_name=%s", file_name);
if (!dh)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (dh->file_name)
free (dh->file_name);
@ -187,22 +210,28 @@ gpgme_data_set_file_name (gpgme_data_t dh, const char *file_name)
{
dh->file_name = strdup (file_name);
if (!dh->file_name)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
}
else
dh->file_name = 0;
return 0;
return TRACE_ERR (0);
}
/* Get the file name associated with the data object with handle DH,
or NULL if there is none. */
char *
gpgme_data_get_file_name (gpgme_data_t dh)
{
if (!dh)
{
TRACE (DEBUG_DATA, "gpgme_data_get_file_name", dh);
return NULL;
}
TRACE1 (DEBUG_DATA, "gpgme_data_get_file_name", dh,
"dh->file_name=%s", dh->file_name);
return dh->file_name;
}
@ -216,6 +245,8 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
char buffer[BUFFER_SIZE];
char *bufp = buffer;
ssize_t buflen;
TRACE_BEG1 (DEBUG_CTX, "_gpgme_data_inbound_handler", dh,
"fd=0x%x", fd);
buflen = _gpgme_io_read (fd, buffer, BUFFER_SIZE);
if (buflen < 0)
@ -223,19 +254,19 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
if (buflen == 0)
{
_gpgme_io_close (fd);
return 0;
return TRACE_ERR (0);
}
do
{
ssize_t amt = gpgme_data_write (dh, bufp, buflen);
if (amt == 0 || (amt < 0 && errno != EINTR))
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
bufp += amt;
buflen -= amt;
}
while (buflen > 0);
return 0;
return TRACE_ERR (0);
}
@ -244,23 +275,25 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
{
gpgme_data_t dh = (gpgme_data_t) opaque;
ssize_t nwritten;
TRACE_BEG1 (DEBUG_CTX, "_gpgme_data_outbound_handler", dh,
"fd=0x%x", fd);
if (!dh->pending_len)
{
ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE);
if (amt < 0)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
if (amt == 0)
{
_gpgme_io_close (fd);
return 0;
return TRACE_ERR (0);
}
dh->pending_len = amt;
}
nwritten = _gpgme_io_write (fd, dh->pending, dh->pending_len);
if (nwritten == -1 && errno == EAGAIN)
return 0;
return TRACE_ERR (0);
if (nwritten == -1 && errno == EPIPE)
{
@ -269,16 +302,16 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
end is going to tell us what happened on some other channel.
Silently close our end. */
_gpgme_io_close (fd);
return 0;
return TRACE_ERR (0);
}
if (nwritten <= 0)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
if (nwritten < dh->pending_len)
memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten);
dh->pending_len -= nwritten;
return 0;
return TRACE_ERR (0);
}

View File

@ -1,6 +1,6 @@
/* debug.c - helpful output in desperate situations
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -28,6 +28,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#ifndef HAVE_DOSISH_SYSTEM
#include <sys/types.h>
#include <sys/stat.h>
@ -37,6 +38,7 @@
#include "util.h"
#include "sema.h"
#include "debug.h"
/* Lock to serialize initialization of the debug output subsystem and
@ -147,6 +149,9 @@ void
_gpgme_debug (int level, const char *format, ...)
{
va_list arg_ptr;
int saved_errno;
saved_errno = errno;
debug_init ();
if (debug_level < level)
@ -160,6 +165,8 @@ _gpgme_debug (int level, const char *format, ...)
putc ('\n', errfp);
UNLOCK (debug_lock);
fflush (errfp);
errno = saved_errno;
}
@ -219,3 +226,48 @@ _gpgme_debug_end (void **line)
free (*line);
*line = NULL;
}
#define TOHEX(val) (((val) < 10) ? ((val) + '0') : ((val) - 10 + 'a'))
void
_gpgme_debug_buffer (int lvl, const char *const fmt,
const char *const func, const char *const tagname,
void *tag, const char *const buffer, size_t len)
{
int idx = 0;
int j;
if (!_gpgme_debug_trace ())
return;
while (idx < len)
{
char str[51];
char *strp = str;
char *strp2 = &str[34];
for (j = 0; j < 16; j++)
{
unsigned char val;
if (idx < len)
{
val = buffer[idx++];
*(strp++) = TOHEX (val >> 4);
*(strp++) = TOHEX (val % 16);
*(strp2++) = isprint (val) ? val : '.';
}
else
{
*(strp++) = ' ';
*(strp++) = ' ';
}
if (j == 7)
*(strp++) = ' ';
}
*(strp++) = ' ';
*(strp2) = '\0';
_gpgme_debug (lvl, fmt, func, tagname, tag, str);
}
}

View File

@ -1,5 +1,5 @@
/* debug.h - interface to debugging functions
Copyright (C) 2002, 2004, 2005 g10 Code GmbH
Copyright (C) 2002, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -23,6 +23,21 @@
#include <string.h>
/* Indirect stringification, requires __STDC__ to work. */
#define STRINGIFY(v) #v
#define XSTRINGIFY(v) STRINGIFY(v)
/* The debug levels. */
#define DEBUG_INIT 1
#define DEBUG_CTX 2
#define DEBUG_ENGINE 3
#define DEBUG_DATA 4
#define DEBUG_ASSUAN 5
#define DEBUG_SYSIO 6
/* Remove path components from filenames (i.e. __FILE__) for cleaner
logs. */
static inline const char *_gpgme_debug_srcname (const char *file)
@ -49,80 +64,160 @@ void _gpgme_debug_add (void **helper, const char *format, ...);
stream. */
void _gpgme_debug_end (void **helper);
/* Indirect stringification, requires __STDC__ to work. */
#define STRINGIFY(v) #v
#define XSTRINGIFY(v) STRINGIFY(v)
void _gpgme_debug_buffer (int lvl, const char *const fmt,
const char *const func, const char *const tagname,
void *tag, const char *const buffer, size_t len);
#if 0
/* Only works in GNU. */
#define DEBUG(fmt, arg...) \
_gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__) , ##arg)
#define DEBUG_BEGIN(hlp, lvl, fmt, arg...) \
_gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
XSTRINGIFY (__LINE__) , ##arg)
#define DEBUG_ADD(hlp, fmt, arg...) \
_gpgme_debug_add (&(hlp), fmt , ##arg)
#define DEBUG_END(hlp, fmt, arg...) \
_gpgme_debug_add (&(hlp), fmt , ##arg); \
_gpgme_debug_end (&(hlp))
#elif 0
/* Only works in C99. */
#define DEBUG0(fmt) \
_gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__))
#define DEBUG(fmt, ...) \
_gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), __VA_ARGS__)
#define DEBUG_BEGIN(hlp, lvl, fmt) \
_gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
XSTRINGIFY (__LINE__))
#define DEBUG_BEGINX(hlp, lvl, fmt, ...) \
_gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
XSTRINGIFY (__LINE__), __VA_ARGS__)
#define DEBUG_ADD0(hlp, fmt) \
/* Trace support. */
/* FIXME: For now. */
#define _gpgme_debug_trace() 1
#define _TRACE(lvl, name, tag) \
int _gpgme_trace_level = lvl; \
const char *const _gpgme_trace_func = name; \
const char *const _gpgme_trace_tagname = STRINGIFY (tag); \
void *_gpgme_trace_tag = (void *) tag
#define TRACE_BEG(lvl, name, tag) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag), 0
#define TRACE_BEG0(lvl, name, tag, fmt) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag), 0
#define TRACE_BEG1(lvl, name, tag, fmt, arg1) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1), 0
#define TRACE_BEG2(lvl, name, tag, fmt, arg1, arg2) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2), 0
#define TRACE_BEG3(lvl, name, tag, fmt, arg1, arg2, arg3) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3), 0
#define TRACE_BEG4(lvl, name, tag, fmt, arg1, arg2, arg3, arg4) \
_TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4), 0
#define TRACE(lvl, name, tag) \
_gpgme_debug (lvl, "%s (%s=0x%x): call\n", \
name, STRINGIFY (tag), (void *) tag), 0
#define TRACE0(lvl, name, tag, fmt) \
_gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \
name, STRINGIFY (tag), (void *) tag), 0
#define TRACE1(lvl, name, tag, fmt, arg1) \
_gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \
name, STRINGIFY (tag), (void *) tag, arg1), 0
#define TRACE2(lvl, name, tag, fmt, arg1, arg2) \
_gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \
name, STRINGIFY (tag), (void *) tag, arg1, arg2), 0
#define TRACE3(lvl, name, tag, fmt, arg1, arg2, arg3) \
_gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \
name, STRINGIFY (tag), (void *) tag, arg1, arg2, \
arg3), 0
#define TRACE6(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
_gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \
name, STRINGIFY (tag), (void *) tag, arg1, arg2, arg3, \
arg4, arg5, arg6), 0
#define TRACE_ERR(err) \
err == 0 ? (TRACE_SUC ()) : \
(_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s <%s>\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, gpgme_strerror (err), \
gpgme_strsource (err)), (err))
/* The cast to void suppresses GCC warnings. */
#define TRACE_SYSRES(res) \
res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \
(_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, strerror (errno)), (res))
#define TRACE_SYSERR(res) \
res == 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \
(_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, strerror (res)), (res))
#define TRACE_SUC() \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag), 0
#define TRACE_SUC0(fmt) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag), 0
#define TRACE_SUC1(fmt, arg1) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1), 0
#define TRACE_SUC2(fmt, arg1, arg2) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2), 0
#define TRACE_SUC5(fmt, arg1, arg2, arg3, arg4, arg5) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0
#define TRACE_LOG(fmt) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag), 0
#define TRACE_LOG1(fmt, arg1) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1), 0
#define TRACE_LOG2(fmt, arg1, arg2) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2), 0
#define TRACE_LOG3(fmt, arg1, arg2, arg3) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3), 0
#define TRACE_LOG4(fmt, arg1, arg2, arg3, arg4) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4), 0
#define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \
arg6), 0
#define TRACE_LOGBUF(buf, len) \
_gpgme_debug_buffer (_gpgme_trace_level, "%s (%s=0x%x): check: %s", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, buf, len)
#define TRACE_SEQ(hlp,fmt) \
_gpgme_debug_begin (&(hlp), _gpgme_trace_level, \
"%s (%s=0x%x): check: " fmt, \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag)
#define TRACE_ADD0(hlp,fmt) \
_gpgme_debug_add (&(hlp), fmt)
#define DEBUG_ADD(hlp, fmt, ...) \
_gpgme_debug_add (&(hlp), fmt, __VA_ARGS__)
#define DEBUG_END(hlp, fmt) \
_gpgme_debug_add (&(hlp), fmt); \
_gpgme_debug_end (&(hlp))
#define DEBUG_ENDX(hlp, fmt, ...) \
_gpgme_debug_add (&(hlp), fmt, __VA_ARGS__); \
_gpgme_debug_end (&(hlp))
#else
/* This finally works everywhere, horror. */
#define DEBUG0(fmt) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__))
#define DEBUG1(fmt,a) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__), (a))
#define DEBUG2(fmt,a,b) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__), (a), (b))
#define DEBUG3(fmt,a,b,c) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__), (a), (b), (c))
#define DEBUG4(fmt,a,b,c,d) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__), (a), (b), (c), (d))
#define DEBUG5(fmt,a,b,c,d,e) \
_gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \
XSTRINGIFY (__LINE__), (a), (b), (c), (d), (e))
#define DEBUG_BEGIN(hlp,lvl,fmt) \
_gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, \
_gpgme_debug_srcname (__FILE__), XSTRINGIFY (__LINE__))
#define DEBUG_ADD0(hlp,fmt) \
_gpgme_debug_add (&(hlp), fmt)
#define DEBUG_ADD1(hlp,fmt,a) \
#define TRACE_ADD1(hlp,fmt,a) \
_gpgme_debug_add (&(hlp), fmt, (a))
#define DEBUG_ADD2(hlp,fmt,a,b) \
#define TRACE_ADD2(hlp,fmt,a,b) \
_gpgme_debug_add (&(hlp), fmt, (a), (b))
#define DEBUG_ADD3(hlp,fmt,a,b,c) \
#define TRACE_ADD3(hlp,fmt,a,b,c) \
_gpgme_debug_add (&(hlp), fmt, (a), (b), (c))
#define DEBUG_END(hlp,fmt) \
#define TRACE_END(hlp,fmt) \
_gpgme_debug_add (&(hlp), fmt); \
_gpgme_debug_end (&(hlp))
#endif
#define DEBUG_ENABLED(hlp) (!!(hlp))
#define TRACE_ENABLED(hlp) (!!(hlp))
#endif /* DEBUG_H */

View File

@ -1,6 +1,6 @@
/* engine-gpgsm.c - GpgSM engine.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -807,12 +807,11 @@ status_handler (void *opaque, int fd)
assuan_err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen);
if (assuan_err)
{
#if 0
/* Try our best to terminate the connection friendly. */
assuan_write_line (gpgsm->assuan_ctx, "BYE");
#endif
/* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */
err = map_assuan_error (assuan_err);
DEBUG3 ("fd %d: error from assuan (%d) getting status line : %s \n",
TRACE3 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: error from assuan (%d) getting status line : %s",
fd, assuan_err, gpg_strerror (err));
}
else if (linelen >= 3
@ -823,12 +822,11 @@ status_handler (void *opaque, int fd)
err = map_assuan_error (atoi (&line[4]));
else
err = gpg_error (GPG_ERR_GENERAL);
DEBUG2 ("fd %d: ERR line - mapped to: %s\n",
TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: ERR line - mapped to: %s",
fd, err ? gpg_strerror (err) : "ok");
#if 0
/* Try our best to terminate the connection friendly. */
assuan_write_line (gpgsm->assuan_ctx, "BYE");
#endif
// assuan_write_line (gpgsm->assuan_ctx, "BYE");
}
else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K'
@ -849,7 +847,8 @@ status_handler (void *opaque, int fd)
err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL);
}
_gpgme_io_close (gpgsm->status_cb.fd);
DEBUG2 ("fd %d: OK line - final status: %s\n",
TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: OK line - final status: %s",
fd, err ? gpg_strerror (err) : "ok");
return err;
}
@ -923,7 +922,8 @@ status_handler (void *opaque, int fd)
dst++;
}
}
DEBUG2 ("fd %d: D line; final status: %s\n",
TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: D line; final status: %s",
fd, err? gpg_strerror (err):"ok");
}
else if (linelen > 2
@ -947,7 +947,8 @@ status_handler (void *opaque, int fd)
}
else
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest);
DEBUG3 ("fd %d: S line (%s) - final status: %s\n",
TRACE3 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
"fd 0x%x: S line (%s) - final status: %s",
fd, line+2, err? gpg_strerror (err):"ok");
}
}

View File

@ -1,6 +1,6 @@
/* gpgme.c - GnuPG Made Easy.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -33,6 +33,7 @@
#include "context.h"
#include "ops.h"
#include "wait.h"
#include "debug.h"
/* The default locale. */
@ -47,16 +48,17 @@ gpgme_error_t
gpgme_new (gpgme_ctx_t *r_ctx)
{
gpgme_ctx_t ctx;
TRACE_BEG (DEBUG_CTX, "gpgme_new", r_ctx);
ctx = calloc (1, sizeof *ctx);
if (!ctx)
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
_gpgme_engine_info_copy (&ctx->engine_info);
if (!ctx->engine_info)
{
free (ctx);
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
}
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
@ -73,7 +75,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
UNLOCK (def_lc_lock);
_gpgme_engine_info_release (ctx->engine_info);
free (ctx);
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
}
}
else
@ -89,7 +91,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
free (ctx->lc_ctype);
_gpgme_engine_info_release (ctx->engine_info);
free (ctx);
return gpg_error_from_errno (errno);
return TRACE_ERR (gpg_error_from_errno (errno));
}
}
else
@ -97,7 +99,8 @@ gpgme_new (gpgme_ctx_t *r_ctx)
UNLOCK (def_lc_lock);
*r_ctx = ctx;
return 0;
return TRACE_SUC1 ("ctx=%p", ctx);
}
@ -106,21 +109,24 @@ gpgme_error_t
gpgme_cancel (gpgme_ctx_t ctx)
{
gpgme_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_cancel", ctx);
err = _gpgme_engine_cancel (ctx->engine);
if (err)
return err;
return TRACE_ERR (err);
err = gpg_error (GPG_ERR_CANCELED);
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
return 0;
return TRACE_ERR (0);
}
/* Release all resources associated with the given context. */
void
gpgme_release (gpgme_ctx_t ctx)
{
TRACE (DEBUG_CTX, "gpgme_release", ctx);
_gpgme_engine_release (ctx->engine);
_gpgme_fd_table_deinit (&ctx->fdt);
_gpgme_release_result (ctx);
@ -156,27 +162,36 @@ _gpgme_release_result (gpgme_ctx_t ctx)
gpgme_error_t
gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
{
TRACE_BEG2 (DEBUG_CTX, "gpgme_set_protocol", ctx, "protocol=%i (%s)",
protocol, gpgme_get_protocol_name (protocol)
? gpgme_get_protocol_name (protocol) : "unknown");
if (protocol != GPGME_PROTOCOL_OpenPGP && protocol != GPGME_PROTOCOL_CMS)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (ctx->protocol != protocol)
{
/* Shut down the engine when switching protocols. */
if (ctx->engine)
{
TRACE_LOG1 ("releasing ctx->engine=%p", ctx->engine);
_gpgme_engine_release (ctx->engine);
ctx->engine = NULL;
}
ctx->protocol = protocol;
}
return 0;
return TRACE_ERR (0);
}
gpgme_protocol_t
gpgme_get_protocol (gpgme_ctx_t ctx)
{
TRACE2 (DEBUG_CTX, "gpgme_get_protocol", ctx,
"ctx->protocol=%i (%s)", ctx->protocol,
gpgme_get_protocol_name (ctx->protocol)
? gpgme_get_protocol_name (ctx->protocol) : "unknown");
return ctx->protocol;
}
@ -199,9 +214,11 @@ gpgme_get_protocol_name (gpgme_protocol_t protocol)
/* Enable or disable the use of an ascii armor for all output. */
void
gpgme_set_armor (gpgme_ctx_t ctx, int yes)
gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
{
ctx->use_armor = yes;
TRACE2 (DEBUG_CTX, "gpgme_set_armor", ctx, "use_armor=%i (%s)",
use_armor, use_armor ? "yes" : "no");
ctx->use_armor = use_armor;
}
@ -209,6 +226,8 @@ gpgme_set_armor (gpgme_ctx_t ctx, int yes)
int
gpgme_get_armor (gpgme_ctx_t ctx)
{
TRACE2 (DEBUG_CTX, "gpgme_get_armor", ctx, "ctx->use_armor=%i (%s)",
ctx->use_armor, ctx->use_armor ? "yes" : "no");
return ctx->use_armor;
}
@ -218,15 +237,19 @@ gpgme_get_armor (gpgme_ctx_t ctx)
3156 mandates that the MUA does some preparations so that textmode
is not needed anymore. */
void
gpgme_set_textmode (gpgme_ctx_t ctx, int yes)
gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode)
{
ctx->use_textmode = yes;
TRACE2 (DEBUG_CTX, "gpgme_set_textmode", ctx, "use_textmode=%i (%s)",
use_textmode, use_textmode ? "yes" : "no");
ctx->use_textmode = use_textmode;
}
/* Return the state of the textmode flag. */
int
gpgme_get_textmode (gpgme_ctx_t ctx)
{
TRACE2 (DEBUG_CTX, "gpgme_get_textmode", ctx, "ctx->use_textmode=%i (%s)",
ctx->use_textmode, ctx->use_textmode ? "yes" : "no");
return ctx->use_textmode;
}
@ -243,6 +266,9 @@ gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
ctx->include_certs = -2;
else
ctx->include_certs = nr_of_certs;
TRACE2 (DEBUG_CTX, "gpgme_set_include_certs", ctx, "nr_of_certs=%i%s",
nr_of_certs, nr_of_certs == ctx->include_certs ? "" : " (-2)");
}
@ -251,6 +277,8 @@ gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
int
gpgme_get_include_certs (gpgme_ctx_t ctx)
{
TRACE1 (DEBUG_CTX, "gpgme_get_include_certs", ctx, "ctx->include_certs=%i",
ctx->include_certs);
return ctx->include_certs;
}
@ -261,6 +289,9 @@ gpgme_get_include_certs (gpgme_ctx_t ctx)
gpgme_error_t
gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
{
TRACE1 (DEBUG_CTX, "gpgme_set_keylist_mode", ctx, "keylist_mode=0x%x",
mode);
ctx->keylist_mode = mode;
return 0;
}
@ -270,6 +301,8 @@ gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
gpgme_keylist_mode_t
gpgme_get_keylist_mode (gpgme_ctx_t ctx)
{
TRACE1 (DEBUG_CTX, "gpgme_get_keylist_mode", ctx,
"ctx->keylist_mode=0x%x", ctx->keylist_mode);
return ctx->keylist_mode;
}
@ -280,6 +313,8 @@ void
gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb,
void *cb_value)
{
TRACE2 (DEBUG_CTX, "gpgme_set_passphrase_cb", ctx,
"passphrase_cb=%p/%p", cb, cb_value);
ctx->passphrase_cb = cb;
ctx->passphrase_cb_value = cb_value;
}
@ -291,6 +326,9 @@ void
gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
void **r_cb_value)
{
TRACE2 (DEBUG_CTX, "gpgme_get_passphrase_cb", ctx,
"ctx->passphrase_cb=%p/%p",
ctx->passphrase_cb, ctx->passphrase_cb_value);
if (r_cb)
*r_cb = ctx->passphrase_cb;
if (r_cb_value)
@ -303,6 +341,8 @@ gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
void
gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value)
{
TRACE2 (DEBUG_CTX, "gpgme_set_progress_cb", ctx, "progress_cb=%p/%p",
cb, cb_value);
ctx->progress_cb = cb;
ctx->progress_cb_value = cb_value;
}
@ -314,6 +354,8 @@ void
gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
void **r_cb_value)
{
TRACE2 (DEBUG_CTX, "gpgme_get_progress_cb", ctx, "ctx->progress_cb=%p/%p",
ctx->progress_cb, ctx->progress_cb_value);
if (r_cb)
*r_cb = ctx->progress_cb;
if (r_cb_value)
@ -326,9 +368,17 @@ void
gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
{
if (io_cbs)
{
TRACE6 (DEBUG_CTX, "gpgme_set_io_cbs", ctx,
"io_cbs=%p (add=%p/%p, remove=%p, event=%p/%p",
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
io_cbs->event, io_cbs->event_priv);
ctx->io_cbs = *io_cbs;
}
else
{
TRACE1 (DEBUG_CTX, "gpgme_set_io_cbs", ctx,
"io_cbs=%p (default)", io_cbs);
ctx->io_cbs.add = NULL;
ctx->io_cbs.add_priv = NULL;
ctx->io_cbs.remove = NULL;
@ -342,6 +392,11 @@ gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
void
gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
{
TRACE6 (DEBUG_CTX, "gpgme_get_io_cbs", ctx,
"io_cbs=%p, ctx->io_cbs.add=%p/%p, .remove=%p, .event=%p/%p",
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
io_cbs->event, io_cbs->event_priv);
*io_cbs = ctx->io_cbs;
}
@ -355,6 +410,9 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
char *new_lc_ctype = NULL;
char *new_lc_messages = NULL;
TRACE_BEG2 (DEBUG_CTX, "gpgme_set_locale", ctx,
"category=%i, value=%s", category, value ? value : "(null)");
#define PREPARE_ONE_LOCALE(lcat, ucat) \
if (!failed && value \
&& (category == LC_ALL || category == LC_ ## ucat)) \
@ -378,7 +436,7 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
if (new_lc_messages)
free (new_lc_messages);
return gpg_error_from_errno (saved_errno);
return TRACE_ERR (gpg_error_from_errno (saved_errno));
}
#define SET_ONE_LOCALE(lcat, ucat) \
@ -407,7 +465,7 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
if (!ctx)
UNLOCK (def_lc_lock);
return 0;
return TRACE_ERR (0);
}
@ -417,6 +475,8 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
gpgme_engine_info_t
gpgme_ctx_get_engine_info (gpgme_ctx_t ctx)
{
TRACE1 (DEBUG_CTX, "gpgme_ctx_get_engine_info", ctx,
"ctx->engine_info=%p", ctx->engine_info);
return ctx->engine_info;
}
@ -427,14 +487,24 @@ gpgme_error_t
gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, gpgme_protocol_t proto,
const char *file_name, const char *home_dir)
{
gpgme_error_t err;
TRACE_BEG4 (DEBUG_CTX, "gpgme_ctx_set_engine_info", ctx,
"protocol=%i (%s), file_name=%s, home_dir=%s",
proto, gpgme_get_protocol_name (proto)
? gpgme_get_protocol_name (proto) : "unknown",
file_name ? file_name : "(default)",
home_dir ? home_dir : "(default)");
/* Shut down the engine when changing engine info. */
if (ctx->engine)
{
TRACE_LOG1 ("releasing ctx->engine=%p", ctx->engine);
_gpgme_engine_release (ctx->engine);
ctx->engine = NULL;
}
return _gpgme_set_engine_info (ctx->engine_info, proto,
err = _gpgme_set_engine_info (ctx->engine_info, proto,
file_name, home_dir);
return TRACE_ERR (err);
}
@ -443,6 +513,7 @@ void
gpgme_sig_notation_clear (gpgme_ctx_t ctx)
{
gpgme_sig_notation_t notation;
TRACE (DEBUG_CTX, "gpgme_sig_notation_clear", ctx);
if (!ctx)
return;
@ -470,8 +541,13 @@ gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
gpgme_sig_notation_t notation;
gpgme_sig_notation_t *lastp;
TRACE_BEG3 (DEBUG_CTX, "gpgme_sig_notation_add", ctx,
"name=%s, value=%s, flags=0x%x",
name ? name : "(null)", value ? value : "(null)",
flags);
if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE);
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (name)
flags |= GPGME_SIG_NOTATION_HUMAN_READABLE;
@ -481,14 +557,14 @@ gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
err = _gpgme_sig_notation_create (&notation, name, name ? strlen (name) : 0,
value, value ? strlen (value) : 0, flags);
if (err)
return err;
return TRACE_ERR (err);
lastp = &ctx->sig_notations;
while (*lastp)
lastp = &(*lastp)->next;
*lastp = notation;
return 0;
return TRACE_ERR (0);
}
@ -497,7 +573,12 @@ gpgme_sig_notation_t
gpgme_sig_notation_get (gpgme_ctx_t ctx)
{
if (!ctx)
{
TRACE (DEBUG_CTX, "gpgme_sig_notation_get", ctx);
return NULL;
}
TRACE1 (DEBUG_CTX, "gpgme_sig_notation_get", ctx,
"ctx->sig_notations=%p", ctx->sig_notations);
return ctx->sig_notations;
}

View File

@ -1,6 +1,6 @@
/* keylist.c - Listing keys.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2006 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 g10 Code GmbH
This file is part of GPGME.
@ -393,8 +393,8 @@ keylist_colon_handler (void *priv, char *line)
key = opd->tmp_key;
DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n",
ctx, key, line ? line : "(null)");
TRACE2 (DEBUG_CTX, "gpgme:keylist_colon_handler", ctx,
"key = %p, line = %s", key, line ? line : "(null)");
if (!line)
{

View File

@ -1,6 +1,6 @@
/* posix-io.c - Posix I/O functions
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -33,6 +33,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h>
#include "util.h"
#include "priv-io.h"
@ -73,44 +74,40 @@ static struct
void *value;
} notify_table[256];
int
_gpgme_io_read (int fd, void *buffer, size_t count)
{
int nread;
int saved_errno;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
"buffer=%p, count=%u", buffer, count);
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count);
do
{
nread = _gpgme_ath_read (fd, buffer, count);
}
while (nread == -1 && errno == EINTR);
saved_errno = errno;
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
if (nread > 0)
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer);
errno = saved_errno;
return nread;
TRACE_LOGBUF (buffer, nread);
return TRACE_SYSRES (nread);
}
int
_gpgme_io_write (int fd, const void *buffer, size_t count)
{
int saved_errno;
int nwritten;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
"buffer=%p, count=%u", buffer, count);
TRACE_LOGBUF (buffer, count);
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count);
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer);
do
{
nwritten = _gpgme_ath_write (fd, buffer, count);
}
while (nwritten == -1 && errno == EINTR);
saved_errno = errno;
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
errno = saved_errno;
return nwritten;
return TRACE_SYSRES (nwritten);
}
@ -119,10 +116,14 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
{
int saved_errno;
int err;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes,
"inherit_idx=%i (GPGME uses it for %s)",
inherit_idx, inherit_idx ? "writing" : "reading");
err = pipe (filedes);
if (err < 0)
return err;
return TRACE_SYSRES (err);
/* FIXME: Should get the old flags first. */
err = fcntl (filedes[1 - inherit_idx], F_SETFD, FD_CLOEXEC);
saved_errno = errno;
@ -132,28 +133,41 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
close (filedes[1]);
}
errno = saved_errno;
return err;
if (err)
return TRACE_SYSRES (err);
return TRACE_SUC2 ("read=0x%x, write=0x%x", filedes[0], filedes[1]);
}
int
_gpgme_io_close (int fd)
{
int res;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
if (fd == -1)
return -1;
{
errno = EINVAL;
return TRACE_SYSRES (-1);
}
/* First call the notify handler. */
DEBUG1 ("closing fd %d", fd);
if (fd >= 0 && fd < (int) DIM (notify_table))
{
if (notify_table[fd].handler)
{
TRACE_LOG2 ("invoking close handler %p/%p",
notify_table[fd].handler, notify_table[fd].value);
notify_table[fd].handler (fd, notify_table[fd].value);
notify_table[fd].handler = NULL;
notify_table[fd].value = NULL;
}
}
/* Then do the close. */
return close (fd);
res = close (fd);
return TRACE_SYSRES (res);
}
@ -161,14 +175,19 @@ int
_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
void *value)
{
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
"close_handler=%p/%p", handler, value);
assert (fd != -1);
if (fd < 0 || fd >= (int) DIM (notify_table))
return -1;
DEBUG1 ("set notification for fd %d", fd);
{
errno = EINVAL;
return TRACE_SYSRES (-1);
}
notify_table[fd].handler = handler;
notify_table[fd].value = value;
return 0;
return TRACE_SYSRES (0);
}
@ -176,12 +195,15 @@ int
_gpgme_io_set_nonblocking (int fd)
{
int flags;
int res;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
flags = fcntl (fd, F_GETFL, 0);
if (flags == -1)
return -1;
return TRACE_SYSRES (-1);
flags |= O_NONBLOCK;
return fcntl (fd, F_SETFL, flags);
res = fcntl (fd, F_SETFL, flags);
return TRACE_SYSRES (res);
}
@ -217,11 +239,20 @@ _gpgme_io_spawn (const char *path, char **argv,
{
pid_t pid;
int i;
int status, signo;
int status;
int signo;
TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
"path=%s", path);
i = 0;
while (argv[i])
{
TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
i++;
}
pid = fork ();
if (pid == -1)
return -1;
return TRACE_SYSRES (-1);
if (!pid)
{
@ -245,7 +276,12 @@ _gpgme_io_spawn (const char *path, char **argv,
if (dup2 (fd_child_list[i].fd,
fd_child_list[i].dup_to) == -1)
{
DEBUG1 ("dup2 failed in child: %s\n", strerror (errno));
#if 0
/* FIXME: The debug file descriptor is not
dup'ed anyway, so we can't see this. */
TRACE_LOG1 ("dup2 failed in child: %s\n",
strerror (errno));
#endif
_exit (8);
}
if (fd_child_list[i].dup_to == 0)
@ -261,7 +297,12 @@ _gpgme_io_spawn (const char *path, char **argv,
int fd = open ("/dev/null", O_RDWR);
if (fd == -1)
{
DEBUG1 ("can't open `/dev/null': %s\n", strerror (errno));
#if 0
/* FIXME: The debug file descriptor is not dup'ed
anyway, so we can't see this. */
TRACE_LOG1 ("can't open `/dev/null': %s\n",
strerror (errno));
#endif
_exit (8);
}
/* Make sure that the process has a connected stdin. */
@ -269,16 +310,24 @@ _gpgme_io_spawn (const char *path, char **argv,
{
if (dup2 (fd, 0) == -1)
{
DEBUG1("dup2(/dev/null, 0) failed: %s\n",
#if 0
/* FIXME: The debug file descriptor is not dup'ed
anyway, so we can't see this. */
TRACE_LOG1 ("dup2(/dev/null, 0) failed: %s\n",
strerror (errno));
#endif
_exit (8);
}
}
if (!duped_stderr)
if (dup2 (fd, 2) == -1)
{
DEBUG1 ("dup2(dev/null, 2) failed: %s\n",
#if 0
/* FIXME: The debug file descriptor is not dup'ed
anyway, so we can't see this. */
TRACE_LOG1 ("dup2(dev/null, 2) failed: %s\n",
strerror (errno));
#endif
_exit (8);
}
close (fd);
@ -287,7 +336,11 @@ _gpgme_io_spawn (const char *path, char **argv,
execv ( path, argv );
/* Hmm: in that case we could write a special status code to the
status-pipe. */
DEBUG1 ("exec of `%s' failed\n", path);
#if 0
/* FIXME: The debug file descriptor is not dup'ed anyway, so
we can't see this. */
TRACE_LOG1 ("exec of `%s' failed\n", path);
#endif
_exit (8);
} /* End child. */
if (pid == -1)
@ -296,33 +349,36 @@ _gpgme_io_spawn (const char *path, char **argv,
_exit (0);
}
TRACE_LOG1 ("waiting for child process pid=%i", pid);
_gpgme_io_waitpid (pid, 1, &status, &signo);
if (status)
return -1;
return TRACE_SYSRES (-1);
/* .dup_to is not used in the parent list. */
for (i = 0; fd_parent_list[i].fd != -1; i++)
_gpgme_io_close (fd_parent_list[i].fd);
return 0;
return TRACE_SYSRES (0);
}
/*
* Select on the list of fds.
* Returns: -1 = error
* 0 = timeout or nothing to select
* >0 = number of signaled fds
*/
/* Select on the list of fds. Returns: -1 = error, 0 = timeout or
nothing to select, > 0 = number of signaled fds. */
int
_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
{
fd_set readfds;
fd_set writefds;
unsigned int i;
int any, max_fd, n, count;
struct timeval timeout = { 1, 0 }; /* Use a 1s timeout. */
int any;
int max_fd;
int n;
int count;
/* Use a 1s timeout. */
struct timeval timeout = { 1, 0 };
void *dbg_help = NULL;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
"nfds=%u, nonblock=%u", nfds, nonblock);
FD_ZERO (&readfds);
FD_ZERO (&writefds);
@ -330,21 +386,22 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
if (nonblock)
timeout.tv_sec = 0;
DEBUG_BEGIN (dbg_help, 3, "gpgme:select on [ ");
TRACE_SEQ (dbg_help, "select on [ ");
any = 0;
for (i = 0; i < nfds; i++)
{
if (fds[i].fd == -1)
continue;
if (fds[i].frozen)
DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd);
TRACE_ADD1 (dbg_help, "f0x%x ", fds[i].fd);
else if (fds[i].for_read)
{
assert (!FD_ISSET (fds[i].fd, &readfds));
FD_SET (fds[i].fd, &readfds);
if (fds[i].fd > max_fd)
max_fd = fds[i].fd;
DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd);
TRACE_ADD1 (dbg_help, "r0x%x ", fds[i].fd);
any = 1;
}
else if (fds[i].for_write)
@ -353,14 +410,14 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
FD_SET (fds[i].fd, &writefds);
if (fds[i].fd > max_fd)
max_fd = fds[i].fd;
DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd);
TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
any = 1;
}
fds[i].signaled = 0;
}
DEBUG_END (dbg_help, "]");
TRACE_END (dbg_help, "]");
if (!any)
return 0;
return TRACE_SYSRES (0);
do
{
@ -369,27 +426,22 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
}
while (count < 0 && errno == EINTR);
if (count < 0)
{
int saved_errno = errno;
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
errno = saved_errno;
return -1; /* error */
}
return TRACE_SYSRES (-1);
DEBUG_BEGIN (dbg_help, 3, "select OK [ ");
if (DEBUG_ENABLED (dbg_help))
TRACE_SEQ (dbg_help, "select OK [ ");
if (TRACE_ENABLED (dbg_help))
{
for (i = 0; i <= max_fd; i++)
{
if (FD_ISSET (i, &readfds))
DEBUG_ADD1 (dbg_help, "r%d ", i);
TRACE_ADD1 (dbg_help, "r0x%x ", i);
if (FD_ISSET (i, &writefds))
DEBUG_ADD1 (dbg_help, "w%d ", i);
TRACE_ADD1 (dbg_help, "w0x%x ", i);
}
DEBUG_END (dbg_help, "]");
TRACE_END (dbg_help, "]");
}
/* n is used to optimize it a little bit. */
/* The variable N is used to optimize it a little bit. */
for (n = count, i = 0; i < nfds && n; i++)
{
if (fds[i].fd == -1)
@ -411,7 +463,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
}
}
}
return count;
return TRACE_SYSRES (count);
}
@ -421,6 +473,8 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags)
int nread;
int saved_errno;
struct iovec *iov;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_recvmsg", fd,
"msg=%p, flags=%i", msg, flags);
nread = 0;
iov = msg->msg_iov;
@ -430,15 +484,14 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags)
iov++;
}
DEBUG2 ("fd %d: about to receive %d bytes\n",
fd, (int) nread);
TRACE_LOG1 ("about to receive %d bytes", nread);
do
{
nread = _gpgme_ath_recvmsg (fd, msg, flags);
}
while (nread == -1 && errno == EINTR);
saved_errno = errno;
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
if (nread > 0)
{
int nr = nread;
@ -447,23 +500,23 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags)
while (nr > 0)
{
int len = nr > iov->iov_len ? iov->iov_len : nr;
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, len,
msg->msg_iov->iov_base);
TRACE_LOGBUF (msg->msg_iov->iov_base, len);
iov++;
nr -= len;
}
}
errno = saved_errno;
return nread;
return TRACE_SYSRES (nread);
}
int
_gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
{
int saved_errno;
int nwritten;
struct iovec *iov;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_sendmsg", fd,
"msg=%p, flags=%i", msg, flags);
nwritten = 0;
iov = msg->msg_iov;
@ -473,13 +526,12 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
iov++;
}
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) nwritten);
TRACE_LOG1 ("about to receive %d bytes", nwritten);
iov = msg->msg_iov;
while (nwritten > 0)
{
int len = nwritten > iov->iov_len ? iov->iov_len : nwritten;
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, len,
msg->msg_iov->iov_base);
TRACE_LOGBUF (msg->msg_iov->iov_base, len);
iov++;
nwritten -= len;
}
@ -489,10 +541,7 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
nwritten = _gpgme_ath_sendmsg (fd, msg, flags);
}
while (nwritten == -1 && errno == EINTR);
saved_errno = errno;
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
errno = saved_errno;
return nwritten;
return TRACE_SYSRES (nwritten);
}

View File

@ -1,6 +1,6 @@
/* rungpg.c - Gpg Engine.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH
This file is part of GPGME.
@ -1002,7 +1002,8 @@ read_status (engine_gpg_t gpg)
received and the next thing will be that
the command handler does its action. */
if (nread > 1)
DEBUG0 ("ERROR, unexpected data in read_status");
TRACE0 (DEBUG_CTX, "gpgme:read_status", 0,
"error: unexpected data");
add_io_cb (gpg, gpg->cmd.fd, 0,
command_handler, gpg,

View File

@ -1,6 +1,6 @@
/* sign.c - Signing function.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
This file is part of GPGME.
@ -30,6 +30,7 @@
#include "context.h"
#include "ops.h"
#include "util.h"
#include "debug.h"
typedef struct
@ -79,11 +80,56 @@ gpgme_op_sign_result (gpgme_ctx_t ctx)
op_data_t opd;
gpgme_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_op_sign_result", ctx);
err = _gpgme_op_data_lookup (ctx, OPDATA_SIGN, &hook, -1, NULL);
opd = hook;
if (err || !opd)
{
TRACE_SUC0 ("result=(null)");
return NULL;
}
if (_gpgme_debug_trace ())
{
gpgme_invalid_key_t inv_key = opd->result.invalid_signers;
gpgme_new_signature_t sig = opd->result.signatures;
int inv_signers = 0;
int signatures = 0;
while (inv_key)
{
inv_signers++;
inv_key = inv_key->next;
}
while (sig)
{
signatures++;
sig = sig->next;
}
TRACE_LOG2 ("result: invalid signers: %i, signatures: %i",
inv_signers, signatures);
inv_key = opd->result.invalid_signers;
while (inv_key)
{
TRACE_LOG3 ("result: invalid signer: fpr=%s, reason=%s <%s>",
inv_key->fpr, gpgme_strerror (inv_key->reason),
gpgme_strsource (inv_key->reason));
inv_key = inv_key->next;
}
sig = opd->result.signatures;
while (sig)
{
TRACE_LOG6 ("result: signature: type=%i, pubkey_algo=%i, "
"hash_algo=%i, timestamp=%li, fpr=%s, sig_class=%i",
sig->type, sig->pubkey_algo, sig->hash_algo,
sig->timestamp, sig->fpr, sig->sig_class);
sig = sig->next;
}
}
TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
@ -312,7 +358,9 @@ gpgme_error_t
gpgme_op_sign_start (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig,
gpgme_sig_mode_t mode)
{
return sign_start (ctx, 0, plain, sig, mode);
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx,
"plain=%p, sig=%p, mode=%i", plain, sig, mode);
return TRACE_ERR (sign_start (ctx, 0, plain, sig, mode));
}
@ -321,8 +369,12 @@ gpgme_error_t
gpgme_op_sign (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig,
gpgme_sig_mode_t mode)
{
gpgme_error_t err = sign_start (ctx, 1, plain, sig, mode);
gpgme_error_t err;
TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx,
"plain=%p, sig=%p, mode=%i", plain, sig, mode);
err = sign_start (ctx, 1, plain, sig, mode);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
return TRACE_ERR (err);
}

View File

@ -1,6 +1,6 @@
/* version.c - Version check routines.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -31,6 +31,7 @@
#include "gpgme.h"
#include "priv-io.h"
#include "debug.h"
/* For _gpgme_sema_subsystem_init (). */
#include "sema.h"
@ -169,6 +170,9 @@ _gpgme_compare_versions (const char *my_version,
const char *
gpgme_check_version (const char *req_version)
{
TRACE2 (DEBUG_INIT, "gpgme_check_version: ", 0,
"req_version=%s, VERSION=%s", req_version, VERSION);
do_subsystem_inits ();
return _gpgme_compare_versions (VERSION, req_version) ? VERSION : NULL;
}

View File

@ -135,17 +135,17 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
gsize nread;
GIOChannel *chan;
GIOStatus status;
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count);
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
"buffer=%p, count=%u", buffer, count);
chan = find_channel (fd, 0);
if (!chan)
{
DEBUG1 ("fd %d: no channel registered\n", fd);
TRACE_LOG ("no channel registered");
errno = EINVAL;
return -1;
return TRACE_SYSRES (-1);
}
DEBUG2 ("fd %d: channel %p\n", fd, chan);
TRACE_LOG1 ("channel %p", chan);
{
GError *err = NULL;
@ -153,7 +153,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
count, &nread, &err);
if (err)
{
DEBUG3 ("fd %d: status %i, err %s\n", fd, status, err->message);
TRACE_LOG2 ("status %i, err %s", status, err->message);
g_error_free (err);
}
}
@ -162,17 +162,15 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
nread = 0;
else if (status != G_IO_STATUS_NORMAL)
{
DEBUG2 ("fd %d: status %d\n", fd, status);
TRACE_LOG1 ("status %d", status);
nread = -1;
saved_errno = EIO;
}
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
if (nread > 0)
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer);
TRACE_LOGBUF (buffer, nread);
errno = saved_errno;
return nread;
return TRACE_SYSRES (nread);
}
@ -183,14 +181,14 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
gsize nwritten;
GIOChannel *chan;
GIOStatus status;
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count);
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer);
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
"buffer=%p, count=%u", buffer, count);
TRACE_LOGBUF (buffer, count);
chan = find_channel (fd, 0);
if (!chan)
{
DEBUG1 ("fd %d: no channel registered\n", fd);
TRACE_LOG ("fd %d: no channel registered");
errno = EINVAL;
return -1;
}
@ -202,9 +200,9 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
nwritten = -1;
saved_errno = EIO;
}
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
errno = saved_errno;
return nwritten;
return TRACE_SYSRES (nwritten);
}
@ -212,10 +210,13 @@ int
_gpgme_io_pipe (int filedes[2], int inherit_idx)
{
GIOChannel *chan;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes,
"inherit_idx=%i (GPGME uses it for %s)",
inherit_idx, inherit_idx ? "writing" : "reading");
#define PIPEBUF_SIZE 4096
if (_pipe (filedes, PIPEBUF_SIZE, O_NOINHERIT | O_BINARY) == -1)
return -1;
return TRACE_SYSRES (-1);
/* Make one end inheritable. */
if (inherit_idx == 0)
@ -229,7 +230,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
if (new_read < 0)
{
_close (filedes[1]);
return -1;
return TRACE_SYSRES (-1);
}
}
else if (inherit_idx == 1)
@ -243,7 +244,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
if (new_write < 0)
{
_close (filedes[0]);
return -1;
return TRACE_SYSRES (-1);
}
}
@ -252,18 +253,17 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
chan = find_channel (filedes[1 - inherit_idx], 1);
if (!chan)
{
DEBUG2 ("channel creation for %d failed: ec=%d\n",
filedes[1 - inherit_idx], errno);
int saved_errno = errno;
_close (filedes[0]);
_close (filedes[1]);
return -1;
errno = saved_errno;
return TRACE_SYSRES (-1);
}
DEBUG5 ("CreatePipe %d (%p) %d (%p) inherit=%p\n",
return TRACE_SUC5 ("read=0x%x/%p, write=0x%x/%p, channel=%p",
filedes[0], (HANDLE) _get_osfhandle (filedes[0]),
filedes[1], (HANDLE) _get_osfhandle (filedes[1]),
chan);
return 0;
}
@ -271,15 +271,15 @@ int
_gpgme_io_close (int fd)
{
GIOChannel *chan;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
if (fd < 0 || fd >= MAX_SLAFD)
{
errno = EBADF;
return -1;
return TRACE_SYSRES (-1);
}
/* First call the notify handler. */
DEBUG1 ("closing fd %d", fd);
if (notify_table[fd].handler)
{
notify_table[fd].handler (fd, notify_table[fd].value);
@ -306,14 +306,19 @@ int
_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
void *value)
{
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
"close_handler=%p/%p", handler, value);
assert (fd != -1);
if (fd < 0 || fd >= (int) DIM (notify_table))
return -1;
DEBUG1 ("set notification for fd %d", fd);
{
errno = EINVAL;
return TRACE_SYSRES (-1);
}
notify_table[fd].handler = handler;
notify_table[fd].value = value;
return 0;
return TRACE_SYSRES (0);
}
@ -323,12 +328,13 @@ _gpgme_io_set_nonblocking (int fd)
GIOChannel *chan;
GIOStatus status;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
chan = find_channel (fd, 0);
if (!chan)
{
DEBUG1 ("set nonblocking for fd %d failed: channel not found", fd);
errno = EIO;
return -1;
return TRACE_SYSRES (-1);
}
status = g_io_channel_set_flags (chan,
@ -336,14 +342,18 @@ _gpgme_io_set_nonblocking (int fd)
G_IO_FLAG_NONBLOCK, NULL);
if (status != G_IO_STATUS_NORMAL)
{
/* glib 1.9.2 does not implement set_flags and returns an error. */
DEBUG2 ("set nonblocking for fd %d failed: status=%d - ignored",
fd, status);
/* errno = EIO; */
/* return -1; */
#if 0
/* glib 1.9.2 does not implement set_flags and returns an
error. */
errno = EIO;
return TRACE_SYSRES (-1);
#else
TRACE_LOG1 ("g_io_channel_set_flags failed: status=%d (ignored)",
status);
#endif
}
return 0;
return TRACE_SYSRES (0);
}
@ -351,7 +361,6 @@ static char *
build_commandline (char **argv)
{
int i;
int j;
int n = 0;
char *buf;
char *p;
@ -409,7 +418,8 @@ _gpgme_io_spawn ( const char *path, char **argv,
struct spawn_fd_item_s *fd_parent_list)
{
SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi = {
PROCESS_INFORMATION pi =
{
NULL, /* returns process handle */
0, /* returns primary thread handle */
0, /* returns pid */
@ -426,6 +436,14 @@ _gpgme_io_spawn ( const char *path, char **argv,
HANDLE hnul = INVALID_HANDLE_VALUE;
/* FIXME. */
int debug_me = 0;
TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
"path=%s", path);
i = 0;
while (argv[i])
{
TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
i++;
}
memset (&sec_attr, 0, sizeof sec_attr);
sec_attr.nLength = sizeof sec_attr;
@ -433,7 +451,7 @@ _gpgme_io_spawn ( const char *path, char **argv,
arg_string = build_commandline (argv);
if (!arg_string)
return -1;
return TRACE_SYSRES (-1);
memset (&si, 0, sizeof si);
si.cb = sizeof (si);
@ -443,27 +461,32 @@ _gpgme_io_spawn ( const char *path, char **argv,
si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle (STD_ERROR_HANDLE);
for (i=0; fd_child_list[i].fd != -1; i++ ) {
if (fd_child_list[i].dup_to == 0 ) {
for (i = 0; fd_child_list[i].fd != -1; i++)
{
if (fd_child_list[i].dup_to == 0)
{
si.hStdInput = (HANDLE) _get_osfhandle (fd_child_list[i].fd);
DEBUG2 ("using %d (%p) for stdin", fd_child_list[i].fd,
TRACE_LOG2 ("using 0x%x/%p for stdin", fd_child_list[i].fd,
_get_osfhandle (fd_child_list[i].fd));
duped_stdin = 1;
}
else if (fd_child_list[i].dup_to == 1 ) {
else if (fd_child_list[i].dup_to == 1)
{
si.hStdOutput = (HANDLE) _get_osfhandle (fd_child_list[i].fd);
DEBUG2 ("using %d (%p) for stdout", fd_child_list[i].fd,
TRACE_LOG2 ("using 0x%x/%p for stdout", fd_child_list[i].fd,
_get_osfhandle (fd_child_list[i].fd));
}
else if (fd_child_list[i].dup_to == 2 ) {
else if (fd_child_list[i].dup_to == 2)
{
si.hStdError = (HANDLE) _get_osfhandle (fd_child_list[i].fd);
DEBUG2 ("using %d (%p) for stderr", fd_child_list[i].fd,
TRACE_LOG2 ("using 0x%x/%p for stderr", fd_child_list[i].fd,
_get_osfhandle (fd_child_list[i].fd));
duped_stderr = 1;
}
}
if( !duped_stdin || !duped_stderr ) {
if (!duped_stdin || !duped_stderr)
{
SECURITY_ATTRIBUTES sa;
memset (&sa, 0, sizeof sa);
@ -476,24 +499,29 @@ _gpgme_io_spawn ( const char *path, char **argv,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( hnul == INVALID_HANDLE_VALUE ) {
DEBUG1 ("can't open `nul': ec=%d\n", (int)GetLastError ());
if (hnul == INVALID_HANDLE_VALUE)
{
TRACE_LOG1 ("CreateFile (\"nul\") failed: ec=%d",
(int) GetLastError ());
free (arg_string);
return -1;
/* FIXME: Should translate the error code. */
errno = EIO;
return TRACE_SYSRES (-1);
}
/* Make sure that the process has a connected stdin */
if ( !duped_stdin ) {
/* Make sure that the process has a connected stdin. */
if (!duped_stdin)
{
si.hStdInput = hnul;
DEBUG1 ("using %d for dummy stdin", (int)hnul );
TRACE_LOG1 ("using 0x%x for dummy stdin", (int) hnul);
}
/* We normally don't want all the normal output */
if ( !duped_stderr ) {
/* We normally don't want all the normal output. */
if (!duped_stderr)
{
si.hStdError = hnul;
DEBUG1 ("using %d for dummy stderr", (int)hnul );
TRACE_LOG1 ("using %d for dummy stderr", (int)hnul);
}
}
DEBUG2 ("CreateProcess, path=`%s' args=`%s'", path, arg_string);
cr_flags |= CREATE_SUSPENDED;
if (!CreateProcessA (path,
arg_string,
@ -504,58 +532,62 @@ _gpgme_io_spawn ( const char *path, char **argv,
envblock, /* environment */
NULL, /* use current drive/directory */
&si, /* startup information */
&pi /* returns process information */
) ) {
DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ());
&pi)) /* returns process information */
{
TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ());
free (arg_string);
return -1;
/* FIXME: Should translate the error code. */
errno = EIO;
return TRACE_SYSRES (-1);
}
/* Close the /dev/nul handle if used. */
if (hnul != INVALID_HANDLE_VALUE ) {
if (hnul != INVALID_HANDLE_VALUE)
{
if (!CloseHandle (hnul))
DEBUG1 ("CloseHandle(hnul) failed: ec=%d\n", (int)GetLastError());
TRACE_LOG1 ("CloseHandle (hnul) failed: ec=%d (ignored)",
(int) GetLastError ());
}
/* Close the other ends of the pipes. */
for (i = 0; fd_parent_list[i].fd != -1; i++)
_gpgme_io_close (fd_parent_list[i].fd);
DEBUG4 ("CreateProcess ready\n"
"- hProcess=%p hThread=%p\n"
"- dwProcessID=%d dwThreadId=%d\n",
TRACE_LOG4 ("CreateProcess ready: hProcess=%p, hThread=%p, "
"dwProcessID=%d, dwThreadId=%d",
pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId);
if ( ResumeThread ( pi.hThread ) < 0 ) {
DEBUG1 ("ResumeThread failed: ec=%d\n", (int)GetLastError ());
}
if (ResumeThread (pi.hThread) < 0)
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
if ( !CloseHandle (pi.hThread) ) {
DEBUG1 ("CloseHandle of thread failed: ec=%d\n",
if (!CloseHandle (pi.hThread))
TRACE_LOG1 ("CloseHandle of thread failed: ec=%d",
(int) GetLastError ());
}
TRACE_SUC1 ("process=%p", pi.hProcess);
return 0;
}
/*
* Select on the list of fds.
* Returns: -1 = error
* 0 = timeout or nothing to select
* >0 = number of signaled fds
*/
/* Select on the list of fds. Returns: -1 = error, 0 = timeout or
nothing to select, > 0 = number of signaled fds. */
int
_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
{
int npollfds;
GPollFD *pollfds;
int *pollfds_map;
int i, j;
int any, n, count;
int timeout = 1000; /* Use a 1s timeout. */
int i;
int j;
int any;
int n;
int count;
/* Use a 1s timeout. */
int timeout = 1000;
void *dbg_help = NULL;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
"nfds=%u, nonblock=%u", nfds, nonblock);
if (nonblock)
timeout = 0;
@ -571,21 +603,21 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
}
npollfds = 0;
DEBUG_BEGIN (dbg_help, 3, "gpgme:select on [ ");
TRACE_SEQ (dbg_help, "select on [ ");
any = 0;
for (i = 0; i < nfds; i++)
{
if (fds[i].fd == -1)
continue;
if (fds[i].frozen)
DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd);
TRACE_ADD1 (dbg_help, "f0x%x ", fds[i].fd);
else if (fds[i].for_read )
{
GIOChannel *chan = find_channel (fds[i].fd, 0);
assert (chan);
g_io_channel_win32_make_pollfd (chan, G_IO_IN, pollfds + npollfds);
pollfds_map[npollfds] = i;
DEBUG_ADD2 (dbg_help, "r%d<%d> ", fds[i].fd, pollfds[npollfds].fd);
TRACE_ADD2 (dbg_help, "r0x%x<%d> ", fds[i].fd, pollfds[npollfds].fd);
npollfds++;
any = 1;
}
@ -595,13 +627,13 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
assert (chan);
g_io_channel_win32_make_pollfd (chan, G_IO_OUT, pollfds + npollfds);
pollfds_map[npollfds] = i;
DEBUG_ADD2 (dbg_help, "w%d<%d> ", fds[i].fd, pollfds[npollfds].fd);
TRACE_ADD2 (dbg_help, "w0x%x<%d> ", fds[i].fd, pollfds[npollfds].fd);
npollfds++;
any = 1;
}
fds[i].signaled = 0;
}
DEBUG_END (dbg_help, "]");
TRACE_END (dbg_help, "]");
if (!any)
{
count = 0;
@ -613,22 +645,21 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
if (count < 0)
{
int saved_errno = errno;
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
errno = saved_errno;
goto leave;
}
DEBUG_BEGIN (dbg_help, 3, "select OK [ ");
if (DEBUG_ENABLED (dbg_help))
TRACE_SEQ (dbg_help, "select OK [ ");
if (TRACE_ENABLED (dbg_help))
{
for (i = 0; i < npollfds; i++)
{
if ((pollfds[i].revents & G_IO_IN))
DEBUG_ADD1 (dbg_help, "r%d ", fds[pollfds_map[i]].fd);
TRACE_ADD1 (dbg_help, "r0x%x ", fds[pollfds_map[i]].fd);
if ((pollfds[i].revents & G_IO_OUT))
DEBUG_ADD1 (dbg_help, "w%d ", fds[pollfds_map[i]].fd);
TRACE_ADD1 (dbg_help, "w0x%x ", fds[pollfds_map[i]].fd);
}
DEBUG_END (dbg_help, "]");
TRACE_END (dbg_help, "]");
}
/* COUNT is used to stop the lop as soon as possible. */
@ -659,7 +690,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
leave:
free (pollfds);
free (pollfds_map);
return count;
return TRACE_SYSRES (count);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* w32-util.c - Utility functions for the W32 API
Copyright (C) 1999 Free Software Foundation, Inc
Copyright (C) 2001 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
This file is part of GPGME.
@ -232,7 +232,8 @@ find_program_in_registry (const char *name)
{
int i;
DEBUG2 ("found %s in registry: `%s'", name, program);
TRACE2 (DEBUG_CTX, "gpgme:find_program_in_registry", 0,
"found %s in registry: `%s'", name, program);
for (i = 0; program[i]; i++)
{
if (program[i] == '/')

View File

@ -1,6 +1,6 @@
/* wait.c
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH
This file is part of GPGME.
@ -156,8 +156,10 @@ _gpgme_remove_io_cb (void *data)
assert (fdt);
idx = tag->idx;
DEBUG2 ("setting fd %d (item=%p) done", fdt->fds[idx].fd,
TRACE2 (DEBUG_CTX, "_gpgme_remove_io_cb", data,
"setting fd 0x%x (item=%p) done", fdt->fds[idx].fd,
fdt->fds[idx].opaque);
free (fdt->fds[idx].opaque);
free (tag);