From 543436c6877d064d47c1d6c3b3176f9dd3eaad2f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 5 Jan 2006 08:58:50 +0000 Subject: [PATCH] Minor glib fix. Pretty up debug output. --- trunk/ChangeLog | 5 +++++ trunk/configure.ac | 10 ++++++++++ trunk/gpgme/ChangeLog | 7 +++++++ trunk/gpgme/debug.c | 2 +- trunk/gpgme/debug.h | 40 ++++++++++++++++++++++++++++----------- trunk/gpgme/gpgme.h | 2 +- trunk/gpgme/w32-glib-io.c | 13 +++++++++---- 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/trunk/ChangeLog b/trunk/ChangeLog index 82fa65a..3f2b4ba 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,8 @@ +2006-01-05 Werner Koch + + * configure.ac: Test for inline feature. + (AH_BOTTOM): New to define the pure attribute. + 2006-01-03 Werner Koch * configure.ac: Append SVN revision to the version. diff --git a/trunk/configure.ac b/trunk/configure.ac index 635dc8c..b85f049 100644 --- a/trunk/configure.ac +++ b/trunk/configure.ac @@ -180,6 +180,7 @@ AC_CHECK_HEADERS(sys/select.h) # Type checks. +AC_C_INLINE AC_CHECK_SIZEOF(unsigned int) AC_SYS_LARGEFILE AC_TYPE_OFF_T @@ -507,6 +508,15 @@ AH_VERBATIM([SEPCONSTANTS], #endif ]) +AH_BOTTOM([ +/* Definition of GCC specific attributes. */ +#if __GNUC__ > 2 +# define GPGME_GCC_A_PURE __attribute__ ((__pure__)) +#else +# define GPGME_GCC_A_PURE +#endif +]) + # Substitution used for gpgme-config GPGME_CONFIG_LIBS="-lgpgme" diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index ed7377d..6996bd7 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2006-01-04 Werner Koch + + * debug.h (_gpgme_debug_srcname): New. Use it with the debug macros. + + * w32-glib-io.c (_gpgme_io_set_nonblocking): Add debug + statements. Disable error return for failed nonblocking call. + 2006-01-03 Marcus Brinkmann * w32-glib-io.c (_gpgme_io_close): Only close fd if there is no diff --git a/trunk/gpgme/debug.c b/trunk/gpgme/debug.c index c51f05a..870976c 100644 --- a/trunk/gpgme/debug.c +++ b/trunk/gpgme/debug.c @@ -1,6 +1,6 @@ /* debug.c - helpful output in desperate situations Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH This file is part of GPGME. diff --git a/trunk/gpgme/debug.h b/trunk/gpgme/debug.h index b05e167..ef5a400 100644 --- a/trunk/gpgme/debug.h +++ b/trunk/gpgme/debug.h @@ -1,5 +1,5 @@ /* debug.h - interface to debugging functions - Copyright (C) 2002, 2004 g10 Code GmbH + Copyright (C) 2002, 2004, 2005 g10 Code GmbH This file is part of GPGME. @@ -21,6 +21,20 @@ #ifndef DEBUG_H #define DEBUG_H +#include + +/* Remove path components from filenames (i.e. __FILE__) for cleaner + logs. */ +static inline const char *_gpgme_debug_srcname (const char *file) + GPGME_GCC_A_PURE; + +static inline const char * +_gpgme_debug_srcname (const char *file) +{ + const char *s = strrchr (file, '/'); + return s? s+1:file; +} + /* Log the formatted string FORMAT at debug level LEVEL or higher. */ void _gpgme_debug (int level, const char *format, ...); @@ -76,22 +90,26 @@ void _gpgme_debug_end (void **helper); #else /* This finally works everywhere, horror. */ #define DEBUG0(fmt) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__)) #define DEBUG1(fmt,a) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (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, __FILE__, XSTRINGIFY (__LINE__), (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, __FILE__, XSTRINGIFY (__LINE__), (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, __FILE__, XSTRINGIFY (__LINE__), (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, __FILE__, XSTRINGIFY (__LINE__), (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, __FILE__, XSTRINGIFY (__LINE__)) + _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) \ diff --git a/trunk/gpgme/gpgme.h b/trunk/gpgme/gpgme.h index e056735..40ca9aa 100644 --- a/trunk/gpgme/gpgme.h +++ b/trunk/gpgme/gpgme.h @@ -72,7 +72,7 @@ extern "C" { AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.1-cvs" +#define GPGME_VERSION "1.1.1-cvs1149" diff --git a/trunk/gpgme/w32-glib-io.c b/trunk/gpgme/w32-glib-io.c index 7dd5740..593cfba 100644 --- a/trunk/gpgme/w32-glib-io.c +++ b/trunk/gpgme/w32-glib-io.c @@ -290,6 +290,7 @@ _gpgme_io_close (int fd) else _close (fd); + return 0; } @@ -313,21 +314,25 @@ _gpgme_io_set_nonblocking (int fd) { GIOChannel *chan; GIOStatus status; - + chan = find_channel (fd, 0); if (!chan) { + DEBUG1 ("set nonblocking for fd %d failed: channel not found", fd); errno = EIO; return -1; } - status = g_io_channel_set_flags (chan, + status = g_io_channel_set_flags (chan, g_io_channel_get_flags (chan) | G_IO_FLAG_NONBLOCK, NULL); if (status != G_IO_STATUS_NORMAL) { - errno = EIO; - return -1; + /* 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; */ } return 0; -- 2.26.2