-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message This is a patch file to create version 1.1.6 from 1.1.5. Please check the signature of this patch file: zcat somepath/gpgme-1.1.5-1.1.6.diff.gz | gpg --verify Change to directory gpgme-1.1.5 (or however you renamed it) and give this command: zcat somepath/gpgme-1.1.5-1.1.6.diff.gz | patch -p1 It is a good idea to rename your current directory to gpgme-1.1.6 now. diff -urpNP gpgme-1.1.5/VERSION gpgme-1.1.6/VERSION --- gpgme-1.1.5/VERSION 2007-07-09 13:15:54.000000000 +0000 +++ gpgme-1.1.6/VERSION 2008-01-04 14:31:04.000000000 +0000 @@ -1 +1 @@ -1.1.5 +1.1.6 diff -urpNP gpgme-1.1.5/AUTHORS gpgme-1.1.6/AUTHORS --- gpgme-1.1.5/AUTHORS 2005-09-08 14:42:33.000000000 +0000 +++ gpgme-1.1.6/AUTHORS 2007-11-23 15:24:05.000000000 +0000 @@ -2,6 +2,7 @@ Package: gpgme Maintainer: Marcus Brinkmann Bug reports: bug-gpgme@gnupg.org Security related bug reports: security@gnupg.org +License: LGPLv2.1+ FSF diff -urpNP gpgme-1.1.5/ChangeLog gpgme-1.1.6/ChangeLog --- gpgme-1.1.5/ChangeLog 2007-07-09 13:06:58.000000000 +0000 +++ gpgme-1.1.6/ChangeLog 2008-01-04 14:18:57.000000000 +0000 @@ -1,3 +1,45 @@ +2008-01-04 Marcus Brinkmann + + Release GPGME 1.1.6. + + * configure.ac: Support gpgconf. + +2007-09-27 Marcus Brinkmann + + * assuan-pipe-connect.c (pipe_connect_gpgme): Do not close process + handle here. Use this function also on Unix systems. + + * assuan-pipe-connect.c (pipe_connect_gpgme): Fix last change. + + * assuan-pipe-connect.c (pipe_connect_gpgme): New function, use it + if _ASSUAN_IN_GPGME_BUILD_ASSUAN. + +2007-09-17 Werner Koch + + * configure.ac: Use the svn version magic. + +2007-09-07 Marcus Brinkmann + + * configure.ac: Check for C++, Qt and support --enable-w32-qt. + * m4/pkg.m4: New file. + +2007-08-21 Marcus Brinkmann + + * configure.ac (--enable-w32-glib): Use --enableval, not + --withval. + +2007-07-16 Marcus Brinkmann + + * assuan/assuan-socket.c (_assuan_close): Always use close(). + * assuan/assuan.h (_gpgme_io_close): New prototype. + (close): New macro, define as _gpgme_io_close. + +2007-07-13 Marcus Brinkmann + + * assuan/assuan-io.c (_assuan_simple_read, _assuan_simple_write): + Always use read/write (which means _gpgme_io_read and + _gpgme_io_write). + 2007-07-09 Marcus Brinkmann Released 1.1.5. @@ -758,7 +800,7 @@ * autogen.sh: Added option --build-w32. - Copyright 2001, 2002, 2003, 2004, 2005 g10 Code GmbH + Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff -urpNP gpgme-1.1.5/Makefile.in gpgme-1.1.6/Makefile.in --- gpgme-1.1.5/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/Makefile.in 2008-01-04 14:26:40.000000000 +0000 @@ -133,6 +133,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -174,6 +175,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/NEWS gpgme-1.1.6/NEWS --- gpgme-1.1.5/NEWS 2007-07-09 13:05:43.000000000 +0000 +++ gpgme-1.1.6/NEWS 2008-01-04 14:18:10.000000000 +0000 @@ -1,3 +1,21 @@ +Noteworthy changes in version 1.1.6 (2008-01-04) +------------------------------------------------ + + * Bug fixes for for W32. + + * A new, experimental (and thus undocumented and potentially + unstable) interface for accessing gpg-conf through GPGME has been + added. + + * Interface changes relative to the 1.1.1 release: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + gpgme_signature_t EXTENDED: New field chain_model. + gpgme_op_getauditlog_start NEW. + gpgme_op_getauditlog NEW. + GPGME_AUDITLOG_HTML NEW. + GPGME_AUDITLOG_WITH_HELP NEW. + + Noteworthy changes in version 1.1.5 (2007-07-09) ------------------------------------------------ @@ -1182,7 +1200,7 @@ Noteworthy changes in version 0.2.1 (200 * Made the W32 support more robust. - Copyright 2001, 2002, 2003, 2004, 2005 g10 Code GmbH + Copyright 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff -urpNP gpgme-1.1.5/TODO gpgme-1.1.6/TODO --- gpgme-1.1.5/TODO 2007-01-17 15:55:32.000000000 +0000 +++ gpgme-1.1.6/TODO 2007-07-18 17:46:50.000000000 +0000 @@ -149,6 +149,18 @@ Hey Emacs, this is -*- outline -*- mode! ** Test reading key signatures. * Debug +** Tracepoints should be added at: Every public interface enter/leave, + before and in every callback, at major decision points, at every + internal data point which might easily be observed by the outside + (system handles). We also trace handles and I/O support threads in + the w32 implementation because that's fragile code. + Files left to do: + data-fd.c data-mem.c data-stream.c data-user.c debug.c rungpg.c + engine.c engine-gpgsm.c funopen.c w32-glib-io.c wait.c + wait-global.c wait-private.c wait-user.c op-support.c decrypt.c + decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c + genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c + sig-notation.c trust-item.c trustlist.c verify.c ** Handle malloc and vasprintf errors. But decide first if they should be ignored (and logged with 255?!), or really be assertions. ! diff -urpNP gpgme-1.1.5/assuan/ChangeLog gpgme-1.1.6/assuan/ChangeLog diff -urpNP gpgme-1.1.5/assuan/ChangeLog gpgme-1.1.6/assuan/ChangeLog --- gpgme-1.1.5/assuan/ChangeLog 2007-07-08 15:47:06.000000000 +0000 +++ gpgme-1.1.6/assuan/ChangeLog 2007-09-27 11:00:06.000000000 +0000 @@ -1,3 +1,30 @@ +2007-09-25 Werner Koch + + * assuan.h (_assuan_gpg_strerror_r, _assuan_gpg_strsource): Add + new wrappers. + +2007-09-03 Marcus Brinkmann + + * assuan.h [_ASSUAN_EXT_SYM_PREFIX]: Add missing symbol renames + with _ASSUAN_PREFIX. + +2007-08-02 Werner Koch + + * assuan-pipe-connect.c (pipe_connect_w32): A bit more debug output. + (pipe_connect_w32): Use DETACHED_PROCESS flag. + * assuan-logging.c (log_level): New. Use this to disable logging. + (assuan_set_assuan_log_level): New. + * assuan.h: Add prototype. + +2007-07-12 Werner Koch + + * assuan-handler.c (assuan_get_active_fds): Use get_osfhandle for + the data fp. + * assuan-socket.c (_assuan_close) [W32]: Use CloseHandle and not close. + + * assuan-io.c (_assuan_simple_write, _assuan_simple_read): Map + ERROR_BROKEN_PIPE to EPIPE. + 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have partial peercred diff -urpNP gpgme-1.1.5/assuan/Makefile.in gpgme-1.1.6/assuan/Makefile.in --- gpgme-1.1.5/assuan/Makefile.in 2007-07-09 13:08:30.000000000 +0000 +++ gpgme-1.1.6/assuan/Makefile.in 2008-01-04 14:26:37.000000000 +0000 @@ -128,6 +128,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -169,6 +170,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/assuan/assuan-buffer.c gpgme-1.1.6/assuan/assuan-buffer.c --- gpgme-1.1.5/assuan/assuan-buffer.c 2006-11-29 16:02:27.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-buffer.c 2007-11-23 15:24:05.000000000 +0000 @@ -135,10 +135,10 @@ _assuan_read_line (assuan_context_t ctx) if (rc) { if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s (%d)]\n", assuan_get_assuan_log_prefix (), (unsigned int)getpid (), ctx->inbound.fd, - strerror (errno)); + strerror (errno), errno); return _assuan_error (ASSUAN_Read_Error); } if (!nread) diff -urpNP gpgme-1.1.5/assuan/assuan-errors.c gpgme-1.1.6/assuan/assuan-errors.c --- gpgme-1.1.5/assuan/assuan-errors.c 2007-07-09 13:14:15.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-errors.c 2008-01-04 14:31:01.000000000 +0000 @@ -36,8 +36,13 @@ _assuan_error (int oldcode) unsigned int n; if (!err_source) - return (oldcode & 0x00ffffff); /* Make sure that the gpg-error - source part is cleared. */ + { + if (oldcode == -1) + return -1; + else + return (oldcode & 0x00ffffff); /* Make sure that the gpg-error + source part is cleared. */ + } switch (oldcode) { @@ -68,6 +73,12 @@ _assuan_error (int oldcode) switch (errno) { case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; + case EAGAIN: + if (errno > 0 && errno < 4096) + { + n = (EAGAIN | (1 << 15)); + break; + } default: n = 270; /*GPG_ERR_ASS_READ_ERROR*/ break; } break; @@ -76,6 +87,12 @@ _assuan_error (int oldcode) switch (errno) { case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; + case EAGAIN: + if (errno > 0 && errno < 4096) + { + n = (EAGAIN | (1 << 15)); + break; + } default: n = 271; /*GPG_ERR_ASS_WRITE_ERROR*/ break; } break; @@ -89,7 +106,12 @@ _assuan_error (int oldcode) an error is indeed returned. */ n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; - case ENOMEM: n = (1 << 15) | 86; break; + case ENOMEM: + if (errno > 0 && errno < 4096) + { + n = (ENOMEM | (1 << 15)); + break; + } default: n = 16382; /*GPG_ERR_UNKNOWN_ERRNO*/ break; diff -urpNP gpgme-1.1.5/assuan/assuan-handler.c gpgme-1.1.6/assuan/assuan-handler.c --- gpgme-1.1.5/assuan/assuan-handler.c 2007-07-04 20:08:19.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-handler.c 2007-07-12 19:23:29.000000000 +0000 @@ -663,7 +663,11 @@ assuan_get_active_fds (assuan_context_t if (ctx->outbound.fd != -1) fdarray[n++] = ctx->outbound.fd; if (ctx->outbound.data.fp) +#ifdef HAVE_W32_SYSTEM + fdarray[n++] = _get_osfhandle (fileno (ctx->outbound.data.fp)); +#else fdarray[n++] = fileno (ctx->outbound.data.fp); +#endif } return n; diff -urpNP gpgme-1.1.5/assuan/assuan-io.c gpgme-1.1.6/assuan/assuan-io.c --- gpgme-1.1.5/assuan/assuan-io.c 2007-07-04 20:08:19.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-io.c 2007-07-13 00:44:14.000000000 +0000 @@ -51,7 +51,7 @@ _assuan_waitpid (pid_t pid, int *status, ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) /* Due to the peculiarities of the W32 API we can't use read for a network socket and thus we try to use recv first and fallback to read if recv detects that it is not a network socket. */ @@ -65,7 +65,11 @@ _assuan_simple_read (assuan_context_t ct n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError()) + { + case ERROR_BROKEN_PIPE: errno = EPIPE; break; + default: errno = EIO; + } n = -1; } else @@ -80,7 +84,7 @@ _assuan_simple_read (assuan_context_t ct ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) /* Due to the peculiarities of the W32 API we can't use write for a network socket and thus we try to use send first and fallback to write if send detects that it is not a network socket. */ @@ -94,7 +98,12 @@ _assuan_simple_write (assuan_context_t c n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError ()) + { + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: errno = EPIPE; break; + default: errno = EIO; break; + } n = -1; } else diff -urpNP gpgme-1.1.5/assuan/assuan-logging.c gpgme-1.1.6/assuan/assuan-logging.c --- gpgme-1.1.5/assuan/assuan-logging.c 2007-07-04 20:08:19.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-logging.c 2007-08-09 20:20:36.000000000 +0000 @@ -37,6 +37,23 @@ static char prefix_buffer[80]; static FILE *_assuan_log; static int full_logging; +static int log_level = 1; /* Defaults to logging enabled. */ + + +/* Set the log level for general assuan commands. 0 is no logging at + all, 1 is the standard logging and the default. Higher leveles may + be defined in the future. Passing a level of -1 will not change + the current log level. Returns previosu log level. */ +int +assuan_set_assuan_log_level (int level) +{ + int old = log_level; + + if (level != -1) + log_level = level; + return old; +} + void _assuan_set_default_log_stream (FILE *fp) @@ -105,6 +122,9 @@ _assuan_log_printf (const char *format, FILE *fp; const char *prf; int save_errno = errno; + + if (!log_level) + return; fp = assuan_get_assuan_log_stream (); prf = assuan_get_assuan_log_prefix (); @@ -128,6 +148,9 @@ _assuan_log_print_buffer (FILE *fp, cons const unsigned char *s; int n; + if (!log_level) + return; + for (n=length,s=buffer; n; n--, s++) if ((!isascii (*s) || iscntrl (*s) || !isprint (*s)) && !(*s >= 0x80)) break; @@ -166,11 +189,16 @@ void _assuan_log_sanitized_string (const char *string) { const unsigned char *s = (const unsigned char *) string; - FILE *fp = assuan_get_assuan_log_stream (); + FILE *fp; - if (! *s) + if (!log_level) return; + if (!*s) + return; + + fp = assuan_get_assuan_log_stream (); + #ifdef HAVE_FLOCKFILE flockfile (fp); #endif diff -urpNP gpgme-1.1.5/assuan/assuan-pipe-connect.c gpgme-1.1.6/assuan/assuan-pipe-connect.c --- gpgme-1.1.5/assuan/assuan-pipe-connect.c 2007-07-04 20:08:19.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-pipe-connect.c 2007-09-27 13:00:05.000000000 +0000 @@ -181,6 +181,8 @@ initial_handshake (assuan_context_t *ctx } +#ifndef _ASSUAN_IN_GPGME_BUILD_ASSUAN + #ifndef HAVE_W32_SYSTEM #define pipe_connect pipe_connect_unix /* Unix version of the pipe connection code. We use an extra macro to @@ -365,6 +367,7 @@ pipe_connect_unix (assuan_context_t *ctx return initial_handshake (ctx); } #endif /*!HAVE_W32_SYSTEM*/ +#endif /* _ASSUAN_IN_GPGME_BUILD_ASSUAN */ #ifndef HAVE_W32_SYSTEM @@ -550,6 +553,105 @@ socketpair_connect (assuan_context_t *ct + +#ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN + +#define pipe_connect pipe_connect_gpgme + +/* From GPGME priv-io.h */ +struct spawn_fd_item_s +{ + int fd; + int dup_to; +}; + +/* W32 version of the pipe connection code. */ +static assuan_error_t +pipe_connect_gpgme (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) +{ + assuan_error_t err; + int res; + int rp[2]; + int wp[2]; + char mypidstr[50]; + struct spawn_fd_item_s child_fds[3]; /* stdin, stdout, terminating -1 */ + + if (!ctx || !name || !argv || !argv[0]) + return _assuan_error (ASSUAN_Invalid_Value); + + /* Actually, GPGME does this for us. But we plan to reuse this code + in the generic assuan. */ + fix_signals (); + + sprintf (mypidstr, "%lu", (unsigned long)getpid ()); + + /* Create the two pipes. */ + if (_gpgme_io_pipe (rp, 1)) + return _assuan_error (ASSUAN_General_Error); + + if (_gpgme_io_pipe (wp, 0)) + { + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + return _assuan_error (ASSUAN_General_Error); + } + + err = _assuan_new_context (ctx); + if (err) + { + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + _gpgme_io_close (wp[0]); + _gpgme_io_close (wp[1]); + return _assuan_error (ASSUAN_General_Error); + } + + (*ctx)->pipe_mode = 1; + (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ + (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ + (*ctx)->deinit_handler = do_deinit; + (*ctx)->finish_handler = do_finish; + + /* fixme: Actually we should set the "_assuan_pipe_connect_pid" env + variable to mypidstr. However this requires us to write a full + environment handler, because the strings are expected in sorted + order. The suggestion given in the MS Reference Library, to save + the old value, changeit, create proces and restore it, is not + thread safe. */ + + /* Parent list is same as client list. Note that GPGME will dup nul + to stderr even if the caller wants to inherit the handle for + it. */ + /* Server stdout is its write end of our read pipe. */ + child_fds[0].fd = rp[1]; + child_fds[0].dup_to = 1; + /* Server stdin is its read end of our write pipe. */ + child_fds[1].fd = wp[0]; + child_fds[1].dup_to = 0; + child_fds[2].fd = -1; + + /* Start the process. */ + res = _gpgme_io_spawn (name, argv, child_fds, child_fds); + if (res == -1) + { + _assuan_log_printf ("CreateProcess failed: %s\n", strerror (errno)); + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + _gpgme_io_close (wp[0]); + _gpgme_io_close (wp[1]); + return _assuan_error (ASSUAN_General_Error); + } + + (*ctx)->pid = 0; /* We don't use the PID. */ + + return initial_handshake (ctx); +} + +#else #ifdef HAVE_W32_SYSTEM /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ @@ -604,7 +706,7 @@ build_w32_commandline (const char * cons #ifdef HAVE_W32_SYSTEM -/* Create pipe where one end end is inheritable. */ +/* Create pipe where one end is inheritable. */ static int create_inheritable_pipe (int filedes[2], int for_write) { @@ -641,12 +743,14 @@ create_inheritable_pipe (int filedes[2], w = h; } + _assuan_log_printf ("created pipe: read=%p%s, write=%p%s\n", + r, for_write? " (inherit)":"", + w, for_write? "":" (inherit)"); filedes[0] = handle_to_fd (r); filedes[1] = handle_to_fd (w); return 0; } -#endif /*HAVE_W32_SYSTEM*/ - +#endif /* HAVE_W32_SYSTEM */ #ifdef HAVE_W32_SYSTEM #define pipe_connect pipe_connect_w32 @@ -752,6 +856,7 @@ pipe_connect_w32 (assuan_context_t *ctx, nullfd = CreateFile ("nul", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + _assuan_log_printf ("created nul device, hd=%p\n", nullfd); if (nullfd == INVALID_HANDLE_VALUE) { _assuan_log_printf ("can't open `nul': %s\n", w32_strerror (-1)); @@ -772,14 +877,17 @@ pipe_connect_w32 (assuan_context_t *ctx, /* Note: We inherit all handles flagged as inheritable. This seems to be a security flaw but there seems to be no way of selecting handles to inherit. */ - /* _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */ - /* name, cmdline); */ + _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", + name, cmdline); + _assuan_log_printf (" stdin=%p stdout=%p stderr=%p\n", + si.hStdInput, si.hStdOutput, si.hStdError); if (!CreateProcess (name, /* Program to start. */ cmdline, /* Command line arguments. */ &sec_attr, /* Process security attributes. */ &sec_attr, /* Thread security attributes. */ TRUE, /* Inherit handles. */ (CREATE_DEFAULT_ERROR_MODE + | DETACHED_PROCESS | GetPriorityClass (GetCurrentProcess ()) | CREATE_SUSPENDED), /* Creation flags. */ NULL, /* Environment. */ @@ -807,13 +915,15 @@ pipe_connect_w32 (assuan_context_t *ctx, nullfd = INVALID_HANDLE_VALUE; } + _assuan_log_printf ("closing handles %p and %p\n", + fd_to_handle (rp[1]), fd_to_handle (wp[0]) ); CloseHandle (fd_to_handle (rp[1])); CloseHandle (fd_to_handle (wp[0])); - /* _assuan_log_printf ("CreateProcess ready: hProcess=%p hThread=%p" */ - /* " dwProcessID=%d dwThreadId=%d\n", */ - /* pi.hProcess, pi.hThread, */ - /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ + _assuan_log_printf ("CreateProcess ready: hProcess=%p hThread=%p" + " dwProcessID=%d dwThreadId=%d\n", + pi.hProcess, pi.hThread, + (int) pi.dwProcessId, (int) pi.dwThreadId); ResumeThread (pi.hThread); CloseHandle (pi.hThread); @@ -823,6 +933,7 @@ pipe_connect_w32 (assuan_context_t *ctx, return initial_handshake (ctx); } #endif /*HAVE_W32_SYSTEM*/ +#endif /* !_ASSUAN_IN_GPGME_BUILD_ASSUAN */ /* Connect to a server over a pipe, creating the assuan context and diff -urpNP gpgme-1.1.5/assuan/assuan-socket.c gpgme-1.1.6/assuan/assuan-socket.c --- gpgme-1.1.5/assuan/assuan-socket.c 2006-09-19 13:22:27.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan-socket.c 2007-07-16 17:27:22.000000000 +0000 @@ -45,13 +45,13 @@ int _assuan_close (int fd) { -#ifndef HAVE_W32_SYSTEM - return close (fd); -#else +#if defined (HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) int rc = closesocket (fd); if (rc && WSAGetLastError () == WSAENOTSOCK) - rc = close (fd); + rc = CloseHandle (fd); return rc; +#else + return close (fd); #endif } diff -urpNP gpgme-1.1.5/assuan/assuan.h gpgme-1.1.6/assuan/assuan.h --- gpgme-1.1.5/assuan/assuan.h 2007-07-08 15:46:47.000000000 +0000 +++ gpgme-1.1.6/assuan/assuan.h 2007-09-27 08:27:34.000000000 +0000 @@ -1,5 +1,5 @@ -/* assuan.c - Definitions for the Assuan IPC library - * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +/* assuan.h - Definitions for the Assuan IPC library + * Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -63,11 +63,13 @@ #ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN #include +int _gpgme_io_close (int fd); int _gpgme_io_read (int fd, void *buffer, size_t count); int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_sendmsg (int sock, const struct msghdr *msg, int flags); int _gpgme_io_recvmsg (int sock, struct msghdr *msg, int flags); +#define close _gpgme_io_close #define read _gpgme_io_read #define write _gpgme_io_write #define waitpid _gpgme_ath_waitpid @@ -135,6 +137,7 @@ int _gpgme_io_recvmsg (int sock, struct #define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd) #define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd) #define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks) +#define assuan_set_assuan_log_level _ASSUAN_PREFIX(assuan_set_assuan_log_level) #define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream) #define assuan_set_error _ASSUAN_PREFIX(assuan_set_error) #define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer) @@ -153,6 +156,9 @@ int _gpgme_io_recvmsg (int sock, struct _ASSUAN_PREFIX(assuan_get_assuan_log_prefix) #define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag) #define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag) +#define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2) +#define assuan_set_assuan_log_prefix \ + _ASSUAN_PREFIX(assuan_set_assuan_log_prefix) /* And now the internal functions, argh... */ #define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line) @@ -179,11 +185,20 @@ int _gpgme_io_recvmsg (int sock, struct #define _assuan_set_default_log_stream \ _ASSUAN_PREFIX(_assuan_set_default_log_stream) #define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror) +#define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r) +#define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource) #define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line) #define _assuan_close _ASSUAN_PREFIX(_assuan_close) #define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new) #define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind) #define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect) +#define _assuan_error _ASSUAN_PREFIX(_assuan_error) +#define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io) +#define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds) +#define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit) +#define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg) +#define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg) +#define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid) #define _assuan_funopen _gpgme_funopen #endif /*_ASSUAN_EXT_SYM_PREFIX*/ @@ -530,6 +545,14 @@ void assuan_set_assuan_err_source (int e /*-- assuan-logging.c --*/ +/* Set the log level for general assuan commands. 0 is no logging at + all, 1 is the standard logging and the default. Higher leveles may + be defined in the future. Passing a level of -1 will not change + the current log level. Returns previous log level. Note, that + this function is not thread-safe and should in general be used + right at startup. */ +int assuan_set_assuan_log_level (int level); + /* Set the stream to which assuan should log message not associated with a context. By default, this is stderr. The default value will be changed when the first log stream is associated with a diff -urpNP gpgme-1.1.5/assuan/mkerrors gpgme-1.1.6/assuan/mkerrors --- gpgme-1.1.5/assuan/mkerrors 2006-11-29 16:02:27.000000000 +0000 +++ gpgme-1.1.6/assuan/mkerrors 2007-11-23 15:24:05.000000000 +0000 @@ -16,9 +16,7 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - +# License along with this program; if not, see . cat < 0 && errno < 4096) + { + n = (EAGAIN | (1 << 15)); + break; + } default: n = 270; /*GPG_ERR_ASS_READ_ERROR*/ break; } break; @@ -98,6 +107,12 @@ _assuan_error (int oldcode) switch (errno) { case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; + case EAGAIN: + if (errno > 0 && errno < 4096) + { + n = (EAGAIN | (1 << 15)); + break; + } default: n = 271; /*GPG_ERR_ASS_WRITE_ERROR*/ break; } break; @@ -111,7 +126,12 @@ _assuan_error (int oldcode) an error is indeed returned. */ n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; - case ENOMEM: n = (1 << 15) | 86; break; + case ENOMEM: + if (errno > 0 && errno < 4096) + { + n = (ENOMEM | (1 << 15)); + break; + } default: n = 16382; /*GPG_ERR_UNKNOWN_ERRNO*/ break; diff -urpNP gpgme-1.1.5/autogen.sh gpgme-1.1.6/autogen.sh --- gpgme-1.1.5/autogen.sh 2007-07-04 20:08:19.000000000 +0000 +++ gpgme-1.1.6/autogen.sh 2007-07-12 18:23:13.000000000 +0000 @@ -80,7 +80,7 @@ if test "$1" = "--build-w32"; then ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=i586-mingw32msvc --build=${build} \ - --with-gpg-error-prefix=${w32root} --without-gpgsm \ + --with-gpg-error-prefix=${w32root} \ --enable-shared --enable-static --enable-w32-glib \ PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" diff -urpNP gpgme-1.1.5/complus/Makefile.in gpgme-1.1.6/complus/Makefile.in --- gpgme-1.1.5/complus/Makefile.in 2007-07-09 13:08:30.000000000 +0000 +++ gpgme-1.1.6/complus/Makefile.in 2008-01-04 14:26:37.000000000 +0000 @@ -136,6 +136,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -177,6 +178,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/config.h.in gpgme-1.1.6/config.h.in --- gpgme-1.1.5/config.h.in 2007-07-09 13:08:29.000000000 +0000 +++ gpgme-1.1.6/config.h.in 2008-01-04 14:26:35.000000000 +0000 @@ -1,8 +1,14 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Whether GPGCONF support is enabled */ +#undef ENABLE_GPGCONF + /* Whether GPGSM support is enabled */ #undef ENABLE_GPGSM +/* Path to the GPGCONF binary. */ +#undef GPGCONF_PATH + /* Path to the GPGSM binary. */ #undef GPGSM_PATH @@ -34,6 +40,9 @@ /* Define to 1 if you have the `getenv_r' function. */ #undef HAVE_GETENV_R +/* Defined if we are building with gpgconf support. */ +#undef HAVE_GPGCONF + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -109,6 +118,9 @@ /* used to implement the va_copy macro */ #undef MUST_COPY_VA_BYVAL +/* Min. needed GPGCONF version. */ +#undef NEED_GPGCONF_VERSION + /* Min. needed GPGSM version. */ #undef NEED_GPGSM_VERSION diff -urpNP gpgme-1.1.5/configure gpgme-1.1.6/configure --- gpgme-1.1.5/configure 2007-07-09 13:08:32.000000000 +0000 +++ gpgme-1.1.6/configure 2008-01-04 14:26:42.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for gpgme 1.1.5. +# Generated by GNU Autoconf 2.61 for gpgme 1.1.6. # # Report bugs to . # @@ -730,8 +730,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='gpgme' PACKAGE_TARNAME='gpgme' -PACKAGE_VERSION='1.1.5' -PACKAGE_STRING='gpgme 1.1.5' +PACKAGE_VERSION='1.1.6' +PACKAGE_STRING='gpgme 1.1.6' PACKAGE_BUGREPORT='bug-gpgme@gnupg.org' ac_unique_file="gpgme/gpgme.h" @@ -857,6 +857,12 @@ AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE +CXX +CXXFLAGS +ac_ct_CXX +CXXDEPMODE +am__fastdepCXX_TRUE +am__fastdepCXX_FALSE LIBGPGME_LT_CURRENT LIBGPGME_LT_AGE LIBGPGME_LT_REVISION @@ -871,12 +877,6 @@ DLLTOOL AS OBJDUMP CPP -CXX -CXXFLAGS -ac_ct_CXX -CXXDEPMODE -am__fastdepCXX_TRUE -am__fastdepCXX_FALSE CXXCPP F77 FFLAGS @@ -884,6 +884,14 @@ ac_ct_F77 LIBTOOL HAVE_LD_VERSION_SCRIPT_TRUE HAVE_LD_VERSION_SCRIPT_FALSE +PKG_CONFIG +GLIB_CFLAGS +GLIB_LIBS +GLIB_GENMARSHAL +GOBJECT_QUERY +GLIB_MKENUMS +QT4_CORE_CFLAGS +QT4_CORE_LIBS PTH_CPPFLAGS PTH_CFLAGS PTH_LDFLAGS @@ -892,14 +900,10 @@ HAVE_DOSISH_SYSTEM_TRUE HAVE_DOSISH_SYSTEM_FALSE HAVE_W32_SYSTEM_TRUE HAVE_W32_SYSTEM_FALSE -PKG_CONFIG -GLIB_CFLAGS -GLIB_LIBS -GLIB_GENMARSHAL -GOBJECT_QUERY -GLIB_MKENUMS BUILD_W32_GLIB_TRUE BUILD_W32_GLIB_FALSE +BUILD_W32_QT_TRUE +BUILD_W32_QT_FALSE HAVE_PTH_TRUE HAVE_PTH_FALSE HAVE_PTHREAD_TRUE @@ -919,6 +923,13 @@ HAVE_GPGSM_TRUE HAVE_GPGSM_FALSE RUN_GPGSM_TESTS_TRUE RUN_GPGSM_TESTS_FALSE +GPGCONF +HAVE_GPGCONF_TRUE +HAVE_GPGCONF_FALSE +RUN_GPGCONF_TESTS_TRUE +RUN_GPGCONF_TESTS_FALSE +BUILD_GPGCONF_TRUE +BUILD_GPGCONF_FALSE BUILD_ASSUAN_TRUE BUILD_ASSUAN_FALSE USE_DESCRIPTOR_PASSING_TRUE @@ -941,10 +952,10 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP CXX CXXFLAGS CCC +CPP CXXCPP F77 FFLAGS' @@ -1450,7 +1461,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures gpgme 1.1.5 to adapt to many kinds of systems. +\`configure' configures gpgme 1.1.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1520,7 +1531,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of gpgme 1.1.5:";; + short | recursive ) echo "Configuration of gpgme 1.1.6:";; esac cat <<\_ACEOF @@ -1538,9 +1549,11 @@ Optional Features: --disable-libtool-lock avoid locking (might break parallel builds) --disable-glibtest do not try to compile and run a test GLIB program --enable-w32-glib build GPGME Glib for W32 + --enable-w32-qt build GPGME Qt for W32 --disable-largefile omit support for large files --disable-gpg-test disable GPG run test --disable-gpgsm-test disable GPGSM run test + --disable-gpgconf-test disable GPGCONF run test --enable-fd-passing use FD passing if supported Optional Packages: @@ -1557,8 +1570,11 @@ Optional Packages: --with-gpg-version=VER require GnuPG version VER --with-gpgsm-version=VER require GPGSM version VER + --with-gpgconf-version=VER + require GPGCONF version VER --with-gpg=PATH use GnuPG binary at PATH --with-gpgsm=PATH use GpgSM binary at PATH + --with-gpgconf=PATH use gpgconf binary at PATH Some influential environment variables: CC C compiler command @@ -1568,9 +1584,9 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory - CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags + CPP C preprocessor CXXCPP C++ preprocessor F77 Fortran 77 compiler command FFLAGS Fortran 77 compiler flags @@ -1639,7 +1655,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -gpgme configure 1.1.5 +gpgme configure 1.1.6 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1653,7 +1669,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by gpgme $as_me 1.1.5, which was +It was created by gpgme $as_me 1.1.6, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2007,6 +2023,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) @@ -2024,6 +2041,7 @@ GPGME_CONFIG_API_VERSION=1 ############################################## +BUILD_REVISION=1284 PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -3719,62 +3737,27 @@ else fi - - - - - - - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - - -# Don't default to build static libs. -# Check whether --enable-static was given. -if test "${enable_static+set}" = set; then - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=no -fi - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. -set dummy ${ac_tool_prefix}windres; ac_word=$2 +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_RC+set}" = set; then +if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$RC"; then - ac_cv_prog_RC="$RC" # Let the user override the test. + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -3783,7 +3766,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RC="${ac_tool_prefix}windres" + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -3793,28 +3776,32 @@ IFS=$as_save_IFS fi fi -RC=$ac_cv_prog_RC -if test -n "$RC"; then - { echo "$as_me:$LINENO: result: $RC" >&5 -echo "${ECHO_T}$RC" >&6; } +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi + test -n "$CXX" && break + done fi -if test -z "$ac_cv_prog_RC"; then - ac_ct_RC=$RC - # Extract the first word of "windres", so it can be a program name with args. -set dummy windres; ac_word=$2 +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_RC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$ac_ct_RC"; then - ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -3823,7 +3810,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RC="windres" + ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -3833,17 +3820,21 @@ IFS=$as_save_IFS fi fi -ac_ct_RC=$ac_cv_prog_ac_ct_RC -if test -n "$ac_ct_RC"; then - { echo "$as_me:$LINENO: result: $ac_ct_RC" >&5 -echo "${ECHO_T}$ac_ct_RC" >&6; } +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi - if test "x$ac_ct_RC" = x; then - RC="no" + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) @@ -3855,47 +3846,546 @@ whose name does not start with the host configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac - RC=$ac_ct_RC + CXX=$ac_ct_CXX fi -else - RC="$ac_cv_prog_RC" fi + fi +fi +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ +#ifndef __GNUC__ + choke me +#endif - - -# Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then - enableval=$enable_shared; p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes else - enable_shared=yes + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu -# Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then - enableval=$enable_fast_install; p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; +fi +{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + + + + + + + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + + +# Don't default to build static libs. +# Check whether --enable-static was given. +if test "${enable_static+set}" = set; then + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=no +fi + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. +set dummy ${ac_tool_prefix}windres; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_RC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RC"; then + ac_cv_prog_RC="$RC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RC="${ac_tool_prefix}windres" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +RC=$ac_cv_prog_RC +if test -n "$RC"; then + { echo "$as_me:$LINENO: result: $RC" >&5 +echo "${ECHO_T}$RC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RC"; then + ac_ct_RC=$RC + # Extract the first word of "windres", so it can be a program name with args. +set dummy windres; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_RC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RC"; then + ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RC="windres" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_RC=$ac_cv_prog_ac_ct_RC +if test -n "$ac_ct_RC"; then + { echo "$as_me:$LINENO: result: $ac_ct_RC" >&5 +echo "${ECHO_T}$ac_ct_RC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_RC" = x; then + RC="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + RC=$ac_ct_RC + fi +else + RC="$ac_cv_prog_RC" +fi + + + + + + +# Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + +# Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. @@ -4534,7 +5024,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4537 "configure"' > conftest.$ac_ext + echo '#line 5027 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4951,162 +5441,57 @@ fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5 -echo "${ECHO_T}$ac_ct_OBJDUMP" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - - ;; - -esac - -need_locks="$enable_libtool_lock" - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : +echo "${ECHO_T}$ac_ct_OBJDUMP" >&6; } else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue + OBJDUMP=$ac_ct_OBJDUMP + fi else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break + OBJDUMP="$ac_cv_prog_OBJDUMP" fi -rm -f conftest.err conftest.$ac_ext + ;; -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi +esac - done - ac_cv_prog_CPP=$CPP +need_locks="$enable_libtool_lock" + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= fi - CPP=$ac_cv_prog_CPP +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_CPP=$CPP -fi -{ echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6; } -ac_preproc_ok=false + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc @@ -5137,624 +5522,285 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else - ac_cv_header_stdc=no -fi -rm -f conftest* + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Broken: fails on valid input. +continue fi -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} +#include _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" +if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + # Passes both tests. +ac_preproc_ok=: +break fi +rm -f conftest.err conftest.$ac_ext +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF + done + ac_cv_prog_CPP=$CPP fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + CPP=$ac_cv_prog_CPP else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" + }; then + : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - + # Broken: fails on valid input. +continue fi -done - - +rm -f conftest.err conftest.$ac_ext -for ac_header in dlfcn.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> +#include _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes + }; then + # Broken: success on invalid input. +continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no + # Passes both tests. +ac_preproc_ok=: +break fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +rm -f conftest.err conftest.$ac_ext -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include <$ac_header> +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || test ! -s conftest.err - }; then - ac_header_preproc=yes + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no + ac_cv_header_stdc=no fi -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to bug-gpgme@gnupg.org ## -## ---------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include -fi - -done - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { echo "$as_me:$LINENO: result: $CXX" >&5 -echo "${ECHO_T}$CXX" >&6; } +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$CXX" && break - done + ac_cv_header_stdc=no fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS +rm -f conftest* fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -echo "${ECHO_T}$ac_ct_CXX" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - test -n "$ac_ct_CXX" && break -done +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no fi +rm -f conftest* - fi fi -# Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C++ compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -5762,75 +5808,104 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { -#ifndef __GNUC__ - choke me -#endif - - ; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_link") 2>&5 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_compiler_gnu=yes + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_compiler_gnu=no +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } -GXX=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default -int -main () -{ - - ; - return 0; -} +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" @@ -5846,29 +5921,57 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || + test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_cv_prog_cxx_g=yes + eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - CXXFLAGS="" - cat >conftest.$ac_ext <<_ACEOF + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} +$ac_includes_default +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" @@ -5884,195 +5987,110 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || + test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - : + ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} +#include <$ac_header> _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cxx_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -depcc="$CXX" am_compiler_list= - -{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } -if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + ac_header_preproc=no +fi - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } - cd .. - rm -rf conftest.dir +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ---------------------------------- ## +## Report this to bug-gpgme@gnupg.org ## +## ---------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - am_cv_CXX_dependencies_compiler_type=none + eval "$as_ac_Header=\$ac_header_preproc" fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= fi +done ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -7503,11 +7521,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7506: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7524: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7510: \$? = $ac_status" >&5 + echo "$as_me:7528: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7736,11 +7754,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7739: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7757: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7743: \$? = $ac_status" >&5 + echo "$as_me:7761: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7796,11 +7814,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7799: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7817: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7803: \$? = $ac_status" >&5 + echo "$as_me:7821: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9944,7 +9962,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12242: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12228: \$? = $ac_status" >&5 + echo "$as_me:12246: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -12281,11 +12299,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12284: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12302: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12288: \$? = $ac_status" >&5 + echo "$as_me:12306: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13612,7 +13630,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:14558: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14544: \$? = $ac_status" >&5 + echo "$as_me:14562: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14597,11 +14615,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14600: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14618: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14604: \$? = $ac_status" >&5 + echo "$as_me:14622: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16631,11 +16649,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16634: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16652: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16638: \$? = $ac_status" >&5 + echo "$as_me:16656: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16864,11 +16882,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16885: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16871: \$? = $ac_status" >&5 + echo "$as_me:16889: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16924,11 +16942,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16927: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16945: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16931: \$? = $ac_status" >&5 + echo "$as_me:16949: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19072,7 +19090,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5 +echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + + + + + + +# For now we hardcode the use of version scripts. It would be better +# to write a test for this or even implement this within libtool. +have_ld_version_script=no +case "${host}" in + *-*-linux*) + have_ld_version_script=yes + ;; + *-*-gnu*) + have_ld_version_script=yes + ;; +esac + if test "$have_ld_version_script" = "yes"; then + HAVE_LD_VERSION_SCRIPT_TRUE= + HAVE_LD_VERSION_SCRIPT_FALSE='#' +else + HAVE_LD_VERSION_SCRIPT_TRUE='#' + HAVE_LD_VERSION_SCRIPT_FALSE= +fi + -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_RC +GPG_DEFAULT=no +GPGSM_DEFAULT=no +GPGCONF_DEFAULT=no +component_system=None +have_dosish_system=no +have_w32_system=no +build_w32_glib=no +build_w32_qt=no +case "${host}" in + *-mingw32*) + # special stuff for Windoze NT + have_dosish_system=yes + have_w32_system=yes + GPG_DEFAULT='c:\\gnupg\\gpg.exe' + GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' + GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe' + #component_system='COM+' -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" + # Check whether --enable-glibtest was given. +if test "${enable_glibtest+set}" = set; then + enableval=$enable_glibtest; +else + enable_glibtest=yes +fi -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_RC -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + pkg_config_args=glib-2.0 + for module in . + do + case "$module" in + gmodule) + pkg_config_args="$pkg_config_args gmodule-2.0" + ;; + gmodule-no-export) + pkg_config_args="$pkg_config_args gmodule-no-export-2.0" + ;; + gobject) + pkg_config_args="$pkg_config_args gobject-2.0" + ;; + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + esac + done -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_RC" + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +echo "${ECHO_T}$PKG_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_RC -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_RC -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds + no_glib="" -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_RC + if test x$PKG_CONFIG != xno ; then + if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then + : + else + echo *** pkg-config too old; version 0.7 or better required. + no_glib=yes + PKG_CONFIG=no + fi + else + no_glib=yes + fi -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_RC + min_glib_version=2.0.0 + { echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 +echo $ECHO_N "checking for GLIB - version >= $min_glib_version... $ECHO_C" >&6; } -# ### END LIBTOOL TAG CONFIG: $tagname + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" + enable_glibtest=no + fi -__EOF__ + if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then + : + else + no_glib=yes + fi + fi + if test x"$no_glib" = x ; then + GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` + GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` + GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` + glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" + rm -f conf.glibtest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu +int +main () +{ + int major, minor, micro; + char *tmp_version; -CC="$lt_save_CC" + system ("touch conf.glibtest"); - ;; + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } - *) - { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 -echo "$as_me: error: Unsupported tag name: $tagname" >&2;} - { (exit 1); exit 1; }; } - ;; - esac + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 -echo "$as_me: error: unable to update list of available tagged configurations." >&2;} - { (exit 1); exit 1; }; } - fi +( exit $ac_status ) +no_glib=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + { echo "$as_me:$LINENO: result: yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&5 +echo "${ECHO_T}yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&6; } + : + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://www.freedesktop.org/software/pkgconfig/" + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - -# Prevent multiple expansion - - - - - - - +#include +#include +int +main () +{ + return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB is incorrectly installed." +fi +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + GLIB_GENMARSHAL="" + GOBJECT_QUERY="" + GLIB_MKENUMS="" + : + fi + rm -f conf.glibtest + # Check whether --enable-w32-glib was given. +if test "${enable_w32_glib+set}" = set; then + enableval=$enable_w32_glib; build_w32_glib=$enableval +fi + # Check disabled, because the qt-dev packages in gpg4win do + # not provide any support for cross compilation. + # PKG_CHECK_MODULES(QT4_CORE, QtCore) + # Use it like this: + # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..." -# For now we hardcode the use of version scripts. It would be better -# to write a test for this or even implement this within libtool. -have_ld_version_script=no -case "${host}" in - *-*-linux*) - have_ld_version_script=yes - ;; - *-*-gnu*) - have_ld_version_script=yes - ;; -esac - if test "$have_ld_version_script" = "yes"; then - HAVE_LD_VERSION_SCRIPT_TRUE= - HAVE_LD_VERSION_SCRIPT_FALSE='#' -else - HAVE_LD_VERSION_SCRIPT_TRUE='#' - HAVE_LD_VERSION_SCRIPT_FALSE= + # Check whether --enable-w32-qt was given. +if test "${enable_w32_qt+set}" = set; then + enableval=$enable_w32_qt; build_w32_qt=$enableval fi - -GPG_DEFAULT=no -GPGSM_DEFAULT=no -component_system=None -have_dosish_system=no -have_w32_system=no -case "${host}" in - *-mingw32*) - # special stuff for Windoze NT - have_dosish_system=yes - have_w32_system=yes - GPG_DEFAULT='c:\\gnupg\\gpg.exe' - GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' - #component_system='COM+' ;; *) PTH_CPPFLAGS='' @@ -20456,175 +20829,33 @@ fi if test ".$verbose" = .yes; then { echo "$as_me:$LINENO: result: o CFLAGS=\"$CFLAGS\"" >&5 -echo "${ECHO_T} o CFLAGS=\"$CFLAGS\"" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o LDFLAGS=\"$LDFLAGS\"" >&5 -echo "${ECHO_T} o LDFLAGS=\"$LDFLAGS\"" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o LIBS=\"$LIBS\"" >&5 -echo "${ECHO_T} o LIBS=\"$LIBS\"" >&6; } -fi - - cross_compile=no - - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: + Performing Sanity Checks:" >&5 -echo "${ECHO_T} + Performing Sanity Checks:" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o pre-processor test" >&5 -echo "${ECHO_T} o pre-processor test" >&6; } -fi - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - #include - #include - -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - _ok=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - _ok=no -fi - -rm -f conftest.err conftest.$ac_ext - if test ".$_ok" != .yes; then - { echo "$as_me:$LINENO: result: *FAILED*" >&5 -echo "${ECHO_T}*FAILED*" >&6; } -cat <>/ /' 1>&2 - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity pre-processor check. This means - the GNU Pth header pth.h was not found. - We used the following build environment: - >> CPP="$CPP" - >> CPPFLAGS="$CPPFLAGS" - See config.log for possibly more details. -EOT -exit 1 +echo "${ECHO_T} o CFLAGS=\"$CFLAGS\"" >&6; } +fi - fi if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o link check" >&5 -echo "${ECHO_T} o link check" >&6; } + { echo "$as_me:$LINENO: result: o LDFLAGS=\"$LDFLAGS\"" >&5 +echo "${ECHO_T} o LDFLAGS=\"$LDFLAGS\"" >&6; } fi - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - #include - #include + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o LIBS=\"$LIBS\"" >&5 +echo "${ECHO_T} o LIBS=\"$LIBS\"" >&6; } +fi -int -main () -{ - FILE *fp; - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "hmm"); - fclose(fp); - pth_init(); - pth_kill(); - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "yes"); - fclose(fp); - exit(0); + cross_compile=no - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - _ok=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - _ok=no + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: + Performing Sanity Checks:" >&5 +echo "${ECHO_T} + Performing Sanity Checks:" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - if test ".$_ok" != .yes; then - { echo "$as_me:$LINENO: result: *FAILED*" >&5 -echo "${ECHO_T}*FAILED*" >&6; } -cat <>/ /' 1>&2 - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity linker check. This means - the GNU Pth library libpth.a was not found. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details. -EOT -exit 1 - - fi if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o run-time check" >&5 -echo "${ECHO_T} o run-time check" >&6; } + { echo "$as_me:$LINENO: result: o pre-processor test" >&5 +echo "${ECHO_T} o pre-processor test" >&6; } fi - if test "$cross_compiling" = yes; then - _ok=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -20633,196 +20864,77 @@ cat >>conftest.$ac_ext <<_ACEOF #include #include -int -main () -{ - FILE *fp; - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "hmm"); - fclose(fp); - pth_init(); - pth_kill(); - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "yes"); - fclose(fp); - exit(0); - - ; - return 0; -} _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" +if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - _ok=`cat conftestval` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -_ok=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - if test ".$_ok" != .yes; then - if test ".$_ok" = .no; then - { echo "$as_me:$LINENO: result: *FAILED*" >&5 -echo "${ECHO_T}*FAILED*" >&6; } -cat <>/ /' 1>&2 - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity execution check. This usually - means that the GNU Pth shared library libpth.so is present - but \$LD_LIBRARY_PATH is incomplete to execute a Pth test. - In this case either disable this test via --without-pth-test, - or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static - library only via its --disable-shared Autoconf option. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details. -EOT -exit 1 - - else - { echo "$as_me:$LINENO: result: *FAILED*" >&5 -echo "${ECHO_T}*FAILED*" >&6; } -cat <>/ /' 1>&2 - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity run-time check. This usually - means that the GNU Pth library failed to work and possibly - caused a core dump in the test program. In this case it - is strongly recommended that you re-install GNU Pth and this - time make sure that it really passes its "make test" procedure. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details. -EOT -exit 1 - - fi - fi - _extendvars="no" - if test ".$_extendvars" != .yes; then - CPPFLAGS="$_ac_save_CPPFLAGS" - CFLAGS="$_ac_save_CFLAGS" - LDFLAGS="$_ac_save_LDFLAGS" - LIBS="$_ac_save_LIBS" - fi - else - _extendvars="no" - if test ".$_extendvars" = .yes; then - if test ".$_pth_subdir" = .yes; then - CPPFLAGS="$CPPFLAGS $_pth_cppflags" - CFLAGS="$CFLAGS $_pth_cflags" - LDFLAGS="$LDFLAGS $_pth_ldflags" - LIBS="$LIBS $_pth_libs" - fi - fi - fi - PTH_CPPFLAGS="$_pth_cppflags" - PTH_CFLAGS="$_pth_cflags" - PTH_LDFLAGS="$_pth_ldflags" - PTH_LIBS="$_pth_libs" - - - - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: + Final Results:" >&5 -echo "${ECHO_T} + Final Results:" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"" >&5 -echo "${ECHO_T} o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o PTH_CFLAGS=\"$PTH_CFLAGS\"" >&5 -echo "${ECHO_T} o PTH_CFLAGS=\"$PTH_CFLAGS\"" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o PTH_LDFLAGS=\"$PTH_LDFLAGS\"" >&5 -echo "${ECHO_T} o PTH_LDFLAGS=\"$PTH_LDFLAGS\"" >&6; } -fi - - if test ".$verbose" = .yes; then - { echo "$as_me:$LINENO: result: o PTH_LIBS=\"$PTH_LIBS\"" >&5 -echo "${ECHO_T} o PTH_LIBS=\"$PTH_LIBS\"" >&6; } -fi - -fi -fi -if test ".$with_pth" != .no; then - { echo "$as_me:$LINENO: result: version $_pth_version, $_pth_type under $_pth_location" >&5 -echo "${ECHO_T}version $_pth_version, $_pth_type under $_pth_location" >&6; } - have_pth=yes + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + _ok=yes else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - : + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + _ok=no fi - if test "$have_pth" = yes; then +rm -f conftest.err conftest.$ac_ext + if test ".$_ok" != .yes; then + { echo "$as_me:$LINENO: result: *FAILED*" >&5 +echo "${ECHO_T}*FAILED*" >&6; } +cat <>/ /' 1>&2 + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity pre-processor check. This means + the GNU Pth header pth.h was not found. + We used the following build environment: + >> CPP="$CPP" + >> CPPFLAGS="$CPPFLAGS" + See config.log for possibly more details. +EOT +exit 1 -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTH -_ACEOF + fi + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o link check" >&5 +echo "${ECHO_T} o link check" >&6; } +fi - fi - { echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 -echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6; } -if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ + #include + #include -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_create (); int main () { -return pthread_create (); + FILE *fp; + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "hmm"); + fclose(fp); + pth_init(); + pth_kill(); + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "yes"); + fclose(fp); + exit(0); + ; return 0; } @@ -20845,193 +20957,40 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - ac_cv_lib_pthread_pthread_create=yes + _ok=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pthread_pthread_create=no + _ok=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5 -echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6; } -if test $ac_cv_lib_pthread_pthread_create = yes; then - have_pthread=yes -fi - - if test "$have_pthread" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTHREAD -_ACEOF - - fi - - # XXX: Probably use exec-prefix here? -# GPG_DEFAULT='/usr/bin/gpg' -# GPGSM_DEFAULT='/usr/bin/gpgsm' - ;; -esac - -if test "$have_dosish_system" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DOSISH_SYSTEM 1 -_ACEOF - -fi - if test "$have_dosish_system" = yes; then - HAVE_DOSISH_SYSTEM_TRUE= - HAVE_DOSISH_SYSTEM_FALSE='#' -else - HAVE_DOSISH_SYSTEM_TRUE='#' - HAVE_DOSISH_SYSTEM_FALSE= -fi - - -if test "$have_w32_system" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_W32_SYSTEM 1 -_ACEOF - -fi - if test "$have_w32_system" = yes; then - HAVE_W32_SYSTEM_TRUE= - HAVE_W32_SYSTEM_FALSE='#' -else - HAVE_W32_SYSTEM_TRUE='#' - HAVE_W32_SYSTEM_FALSE= -fi - - -build_w32_glib=no -# Check whether --enable-glibtest was given. -if test "${enable_glibtest+set}" = set; then - enableval=$enable_glibtest; -else - enable_glibtest=yes -fi - - - pkg_config_args=glib-2.0 - for module in . - do - case "$module" in - gmodule) - pkg_config_args="$pkg_config_args gmodule-2.0" - ;; - gmodule-no-export) - pkg_config_args="$pkg_config_args gmodule-no-export-2.0" - ;; - gobject) - pkg_config_args="$pkg_config_args gobject-2.0" - ;; - gthread) - pkg_config_args="$pkg_config_args gthread-2.0" - ;; - esac - done - - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS + if test ".$_ok" != .yes; then + { echo "$as_me:$LINENO: result: *FAILED*" >&5 +echo "${ECHO_T}*FAILED*" >&6; } +cat <>/ /' 1>&2 + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity linker check. This means + the GNU Pth library libpth.a was not found. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details. +EOT +exit 1 - test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 -echo "${ECHO_T}$PKG_CONFIG" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } + fi + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o run-time check" >&5 +echo "${ECHO_T} o run-time check" >&6; } fi - - - no_glib="" - - if test x$PKG_CONFIG != xno ; then - if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then - : - else - echo *** pkg-config too old; version 0.7 or better required. - no_glib=yes - PKG_CONFIG=no - fi - else - no_glib=yes - fi - - min_glib_version=2.0.0 - { echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 -echo $ECHO_N "checking for GLIB - version >= $min_glib_version... $ECHO_C" >&6; } - - if test x$PKG_CONFIG != xno ; then - ## don't try to run the test against uninstalled libtool libs - if $PKG_CONFIG --uninstalled $pkg_config_args; then - echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" - enable_glibtest=no - fi - - if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then - : - else - no_glib=yes - fi - fi - - if test x"$no_glib" = x ; then - GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` - GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` - GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` - - GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` - GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` - glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - if test "x$enable_glibtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $GLIB_CFLAGS" - LIBS="$GLIB_LIBS $LIBS" - rm -f conf.glibtest - if test "$cross_compiling" = yes; then - echo $ac_n "cross compiling; assumed OK... $ac_c" + if test "$cross_compiling" = yes; then + _ok=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -21039,78 +20998,33 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -#include -#include -#include +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include + #include int main () { - int major, minor, micro; - char *tmp_version; - - system ("touch conf.glibtest"); - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = g_strdup("$min_glib_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_glib_version"); - exit(1); - } + FILE *fp; + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "hmm"); + fclose(fp); + pth_init(); + pth_kill(); + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "yes"); + fclose(fp); + exit(0); - if ((glib_major_version != $glib_config_major_version) || - (glib_minor_version != $glib_config_minor_version) || - (glib_micro_version != $glib_config_micro_version)) - { - printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", - $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, - glib_major_version, glib_minor_version, glib_micro_version); - printf ("*** was found! If pkg-config was correct, then it is best\n"); - printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); - printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); - printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); - printf("*** required on your system.\n"); - printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); - printf("*** to point to the correct configuration files\n"); - } - else if ((glib_major_version != GLIB_MAJOR_VERSION) || - (glib_minor_version != GLIB_MINOR_VERSION) || - (glib_micro_version != GLIB_MICRO_VERSION)) - { - printf("*** GLIB header files (version %d.%d.%d) do not match\n", - GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); - printf("*** library (version %d.%d.%d)\n", - glib_major_version, glib_minor_version, glib_micro_version); - } - else - { - if ((glib_major_version > major) || - ((glib_major_version == major) && (glib_minor_version > minor)) || - ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", - glib_major_version, glib_minor_version, glib_micro_version); - printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", - major, minor, micro); - printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); - printf("***\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); - printf("*** being found. The easiest way to fix this is to remove the old version\n"); - printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); - printf("*** correct copy of pkg-config. (In this case, you will have to\n"); - printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); - printf("*** so that the correct libraries are found at run-time))\n"); - } - } - return 1; + ; + return 0; } - _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" @@ -21132,56 +21046,156 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - : + _ok=`cat conftestval` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -no_glib=yes +_ok=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_glib" = x ; then - { echo "$as_me:$LINENO: result: yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&5 -echo "${ECHO_T}yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&6; } - : - else - { echo "$as_me:$LINENO: result: no" >&5 + if test ".$_ok" != .yes; then + if test ".$_ok" = .no; then + { echo "$as_me:$LINENO: result: *FAILED*" >&5 +echo "${ECHO_T}*FAILED*" >&6; } +cat <>/ /' 1>&2 + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity execution check. This usually + means that the GNU Pth shared library libpth.so is present + but \$LD_LIBRARY_PATH is incomplete to execute a Pth test. + In this case either disable this test via --without-pth-test, + or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static + library only via its --disable-shared Autoconf option. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details. +EOT +exit 1 + + else + { echo "$as_me:$LINENO: result: *FAILED*" >&5 +echo "${ECHO_T}*FAILED*" >&6; } +cat <>/ /' 1>&2 + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity run-time check. This usually + means that the GNU Pth library failed to work and possibly + caused a core dump in the test program. In this case it + is strongly recommended that you re-install GNU Pth and this + time make sure that it really passes its "make test" procedure. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details. +EOT +exit 1 + + fi + fi + _extendvars="no" + if test ".$_extendvars" != .yes; then + CPPFLAGS="$_ac_save_CPPFLAGS" + CFLAGS="$_ac_save_CFLAGS" + LDFLAGS="$_ac_save_LDFLAGS" + LIBS="$_ac_save_LIBS" + fi + else + _extendvars="no" + if test ".$_extendvars" = .yes; then + if test ".$_pth_subdir" = .yes; then + CPPFLAGS="$CPPFLAGS $_pth_cppflags" + CFLAGS="$CFLAGS $_pth_cflags" + LDFLAGS="$LDFLAGS $_pth_ldflags" + LIBS="$LIBS $_pth_libs" + fi + fi + fi + PTH_CPPFLAGS="$_pth_cppflags" + PTH_CFLAGS="$_pth_cflags" + PTH_LDFLAGS="$_pth_ldflags" + PTH_LIBS="$_pth_libs" + + + + + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: + Final Results:" >&5 +echo "${ECHO_T} + Final Results:" >&6; } +fi + + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"" >&5 +echo "${ECHO_T} o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"" >&6; } +fi + + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o PTH_CFLAGS=\"$PTH_CFLAGS\"" >&5 +echo "${ECHO_T} o PTH_CFLAGS=\"$PTH_CFLAGS\"" >&6; } +fi + + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o PTH_LDFLAGS=\"$PTH_LDFLAGS\"" >&5 +echo "${ECHO_T} o PTH_LDFLAGS=\"$PTH_LDFLAGS\"" >&6; } +fi + + if test ".$verbose" = .yes; then + { echo "$as_me:$LINENO: result: o PTH_LIBS=\"$PTH_LIBS\"" >&5 +echo "${ECHO_T} o PTH_LIBS=\"$PTH_LIBS\"" >&6; } +fi + +fi +fi +if test ".$with_pth" != .no; then + { echo "$as_me:$LINENO: result: version $_pth_version, $_pth_type under $_pth_location" >&5 +echo "${ECHO_T}version $_pth_version, $_pth_type under $_pth_location" >&6; } + have_pth=yes +else + { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - if test "$PKG_CONFIG" = "no" ; then - echo "*** A new enough version of pkg-config was not found." - echo "*** See http://www.freedesktop.org/software/pkgconfig/" - else - if test -f conf.glibtest ; then - : - else - echo "*** Could not run GLIB test program, checking why..." - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $GLIB_CFLAGS" - LIBS="$LIBS $GLIB_LIBS" - cat >conftest.$ac_ext <<_ACEOF + : +fi + + if test "$have_pth" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTH +_ACEOF + + fi + { echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 +echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6; } +if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include - +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_create (); int main () { - return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); +return pthread_create (); ; return 0; } @@ -21204,46 +21218,68 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding GLIB or finding the wrong" - echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + ac_cv_lib_pthread_pthread_create=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means GLIB is incorrectly installed." + ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - GLIB_CFLAGS="" - GLIB_LIBS="" - GLIB_GENMARSHAL="" - GOBJECT_QUERY="" - GLIB_MKENUMS="" - : - fi +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6; } +if test $ac_cv_lib_pthread_pthread_create = yes; then + have_pthread=yes +fi + if test "$have_pthread" = yes; then +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTHREAD +_ACEOF + fi + # XXX: Probably use exec-prefix here? +# GPG_DEFAULT='/usr/bin/gpg' +# GPGSM_DEFAULT='/usr/bin/gpgsm' +# GPGCONF_DEFAULT='/usr/bin/gpgconf' + ;; +esac - rm -f conf.glibtest +if test "$have_dosish_system" = yes; then -# Check whether --enable-w32-glib was given. -if test "${enable_w32_glib+set}" = set; then - enableval=$enable_w32_glib; build_w32_glib=$withval +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOSISH_SYSTEM 1 +_ACEOF + +fi + if test "$have_dosish_system" = yes; then + HAVE_DOSISH_SYSTEM_TRUE= + HAVE_DOSISH_SYSTEM_FALSE='#' +else + HAVE_DOSISH_SYSTEM_TRUE='#' + HAVE_DOSISH_SYSTEM_FALSE= +fi + + +if test "$have_w32_system" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_W32_SYSTEM 1 +_ACEOF + +fi + if test "$have_w32_system" = yes; then + HAVE_W32_SYSTEM_TRUE= + HAVE_W32_SYSTEM_FALSE='#' +else + HAVE_W32_SYSTEM_TRUE='#' + HAVE_W32_SYSTEM_FALSE= fi if test "$build_w32_glib" = yes; then @@ -21254,6 +21290,14 @@ else BUILD_W32_GLIB_FALSE= fi + if test "$build_w32_qt" = yes; then + BUILD_W32_QT_TRUE= + BUILD_W32_QT_FALSE='#' +else + BUILD_W32_QT_TRUE='#' + BUILD_W32_QT_FALSE= +fi + if test "$have_pth" = "yes"; then HAVE_PTH_TRUE= @@ -23435,8 +23479,10 @@ _ACEOF # Checks for system services NEED_GPG_VERSION_DEFAULT=1.3.0 NEED_GPGSM_VERSION_DEFAULT=1.9.6 +NEED_GPGCONF_VERSION_DEFAULT=2.0.4 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT" NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT" +NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" # Check whether --with-gpg-version was given. if test "${with_gpg_version+set}" = set; then @@ -23462,6 +23508,18 @@ if test "$NEED_GPGSM_VERSION" = "no"; th NEED_GPGSM_VERSION=0.0.0 fi +# Check whether --with-gpgconf-version was given. +if test "${with_gpgconf_version+set}" = set; then + withval=$with_gpgconf_version; NEED_GPGCONF_VERSION=$withval +fi + +if test "$NEED_GPGCONF_VERSION" = "yes"; then + NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" +fi +if test "$NEED_GPGCONF_VERSION" = "no"; then + NEED_GPGCONF_VERSION=0.0.0 +fi + cat >>confdefs.h <<_ACEOF #define NEED_GPG_VERSION "$NEED_GPG_VERSION" @@ -23473,6 +23531,11 @@ cat >>confdefs.h <<_ACEOF _ACEOF +cat >>confdefs.h <<_ACEOF +#define NEED_GPGCONF_VERSION "$NEED_GPGCONF_VERSION" +_ACEOF + + NO_OVERRIDE=no @@ -23816,6 +23879,200 @@ fi +NO_OVERRIDE=no + +# Check whether --with-gpgconf was given. +if test "${with_gpgconf+set}" = set; then + withval=$with_gpgconf; GPGCONF=$withval +else + NO_OVERRIDE=yes +fi + +if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then + GPGCONF= + NO_OVERRIDE=yes + if test "$cross_compiling" != "yes"; then + # Extract the first word of "gpgconf", so it can be a program name with args. +set dummy gpgconf; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_GPGCONF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GPGCONF in + [\\/]* | ?:[\\/]*) + ac_cv_path_GPGCONF="$GPGCONF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GPGCONF="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +GPGCONF=$ac_cv_path_GPGCONF +if test -n "$GPGCONF"; then + { echo "$as_me:$LINENO: result: $GPGCONF" >&5 +echo "${ECHO_T}$GPGCONF" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi + if test -z "$GPGCONF"; then + GPGCONF="$GPGCONF_DEFAULT" + fi +fi +if test "$GPGCONF" = no; then + if test "$NO_OVERRIDE" = "yes"; then + if test "$cross_compiling" != "yes"; then + { echo "$as_me:$LINENO: WARNING: +*** +*** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it +***" >&5 +echo "$as_me: WARNING: +*** +*** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it +***" >&2;} + else + { { echo "$as_me:$LINENO: error: +*** +*** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH +***" >&5 +echo "$as_me: error: +*** +*** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH +***" >&2;} + { (exit 1); exit 1; }; } + fi + fi +else + +cat >>confdefs.h <<_ACEOF +#define GPGCONF_PATH "$GPGCONF" +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_GPGCONF 1 +_ACEOF + +fi + if test "$GPGCONF" != "no"; then + HAVE_GPGCONF_TRUE= + HAVE_GPGCONF_FALSE='#' +else + HAVE_GPGCONF_TRUE='#' + HAVE_GPGCONF_FALSE= +fi + + +GPGCONF_VERSION=unknown +ok=maybe +if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then + ok=no +else + if test "$cross_compiling" = "yes"; then + { echo "$as_me:$LINENO: WARNING: GPGCONF version can not be checked when cross compiling" >&5 +echo "$as_me: WARNING: GPGCONF version can not be checked when cross compiling" >&2;} + ok=no + else + if test ! -x "$GPGCONF"; then + { echo "$as_me:$LINENO: WARNING: GPGCONF not executable, version check disabled" >&5 +echo "$as_me: WARNING: GPGCONF not executable, version check disabled" >&2;} + ok=no + fi + fi +fi +if test "$ok" = "maybe"; then + { echo "$as_me:$LINENO: checking for GPGCONF >= $NEED_GPGCONF_VERSION" >&5 +echo $ECHO_N "checking for GPGCONF >= $NEED_GPGCONF_VERSION... $ECHO_C" >&6; } + req_major=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` + req_minor=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` + req_micro=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` + GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[^0-9]*\(.*\)/\1/p'` + major=`echo $GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'` + minor=`echo $GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'` + micro=`echo $GPGCONF_VERSION | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'` + + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -gt "$req_minor"; then + ok=yes + else + if test "$minor" -eq "$req_minor"; then + if test "$micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + if test "$ok" = "yes"; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + { echo "$as_me:$LINENO: WARNING: GPGCONF must be at least version $NEED_GPGCONF_VERSION" >&5 +echo "$as_me: WARNING: GPGCONF must be at least version $NEED_GPGCONF_VERSION" >&2;} + fi +fi +run_gpgconf_test="$ok" +# Check whether --enable-gpgconf-test was given. +if test "${enable_gpgconf_test+set}" = set; then + enableval=$enable_gpgconf_test; run_gpgconf_test=$enableval +fi + + if test "$run_gpgconf_test" = "yes"; then + RUN_GPGCONF_TESTS_TRUE= + RUN_GPGCONF_TESTS_FALSE='#' +else + RUN_GPGCONF_TESTS_TRUE='#' + RUN_GPGCONF_TESTS_FALSE= +fi + + +# Only build if supported. + if test "$GPGCONF" != "no"; then + BUILD_GPGCONF_TRUE= + BUILD_GPGCONF_FALSE='#' +else + BUILD_GPGCONF_TRUE='#' + BUILD_GPGCONF_FALSE= +fi + +if test "$GPGCONF" != "no"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GPGCONF 1 +_ACEOF + +fi + + # FIXME: Only build if supported. if test "$GPGSM" != "no"; then BUILD_ASSUAN_TRUE= @@ -25211,8 +25468,6 @@ echo "$as_me: WARNING: fixed the GPGME_V # Generate values for the DLL version info -BUILD_REVISION="`echo '$Revision: 1225 $' | sed 's/[^0-9]//g'`" -test -z "$BUILD_REVISION" && BUILD_REVISION="0" if test "$have_w32_system" = yes; then BUILD_TIMESTAMP=`date --iso-8601=minutes` BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` @@ -25403,6 +25658,13 @@ echo "$as_me: error: conditional \"BUILD Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${BUILD_W32_QT_TRUE}" && test -z "${BUILD_W32_QT_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BUILD_W32_QT\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BUILD_W32_QT\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${HAVE_PTH_TRUE}" && test -z "${HAVE_PTH_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"HAVE_PTH\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -25438,6 +25700,27 @@ echo "$as_me: error: conditional \"RUN_G Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${HAVE_GPGCONF_TRUE}" && test -z "${HAVE_GPGCONF_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HAVE_GPGCONF\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HAVE_GPGCONF\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${RUN_GPGCONF_TESTS_TRUE}" && test -z "${RUN_GPGCONF_TESTS_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"RUN_GPGCONF_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"RUN_GPGCONF_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${BUILD_GPGCONF_TRUE}" && test -z "${BUILD_GPGCONF_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BUILD_GPGCONF\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BUILD_GPGCONF\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${BUILD_ASSUAN_TRUE}" && test -z "${BUILD_ASSUAN_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"BUILD_ASSUAN\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -25759,7 +26042,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by gpgme $as_me 1.1.5, which was +This file was extended by gpgme $as_me 1.1.6, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -25812,7 +26095,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -gpgme config.status 1.1.5 +gpgme config.status 1.1.6 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" @@ -26089,17 +26372,17 @@ AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CXX!$CXX$ac_delim +CXXFLAGS!$CXXFLAGS$ac_delim +ac_ct_CXX!$ac_ct_CXX$ac_delim +CXXDEPMODE!$CXXDEPMODE$ac_delim +am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim +am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim LIBGPGME_LT_CURRENT!$LIBGPGME_LT_CURRENT$ac_delim LIBGPGME_LT_AGE!$LIBGPGME_LT_AGE$ac_delim LIBGPGME_LT_REVISION!$LIBGPGME_LT_REVISION$ac_delim RC!$RC$ac_delim GREP!$GREP$ac_delim -EGREP!$EGREP$ac_delim -LN_S!$LN_S$ac_delim -ECHO!$ECHO$ac_delim -AR!$AR$ac_delim -RANLIB!$RANLIB$ac_delim -DLLTOOL!$DLLTOOL$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -26141,15 +26424,15 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +EGREP!$EGREP$ac_delim +LN_S!$LN_S$ac_delim +ECHO!$ECHO$ac_delim +AR!$AR$ac_delim +RANLIB!$RANLIB$ac_delim +DLLTOOL!$DLLTOOL$ac_delim AS!$AS$ac_delim OBJDUMP!$OBJDUMP$ac_delim CPP!$CPP$ac_delim -CXX!$CXX$ac_delim -CXXFLAGS!$CXXFLAGS$ac_delim -ac_ct_CXX!$ac_ct_CXX$ac_delim -CXXDEPMODE!$CXXDEPMODE$ac_delim -am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim -am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim CXXCPP!$CXXCPP$ac_delim F77!$F77$ac_delim FFLAGS!$FFLAGS$ac_delim @@ -26157,6 +26440,14 @@ ac_ct_F77!$ac_ct_F77$ac_delim LIBTOOL!$LIBTOOL$ac_delim HAVE_LD_VERSION_SCRIPT_TRUE!$HAVE_LD_VERSION_SCRIPT_TRUE$ac_delim HAVE_LD_VERSION_SCRIPT_FALSE!$HAVE_LD_VERSION_SCRIPT_FALSE$ac_delim +PKG_CONFIG!$PKG_CONFIG$ac_delim +GLIB_CFLAGS!$GLIB_CFLAGS$ac_delim +GLIB_LIBS!$GLIB_LIBS$ac_delim +GLIB_GENMARSHAL!$GLIB_GENMARSHAL$ac_delim +GOBJECT_QUERY!$GOBJECT_QUERY$ac_delim +GLIB_MKENUMS!$GLIB_MKENUMS$ac_delim +QT4_CORE_CFLAGS!$QT4_CORE_CFLAGS$ac_delim +QT4_CORE_LIBS!$QT4_CORE_LIBS$ac_delim PTH_CPPFLAGS!$PTH_CPPFLAGS$ac_delim PTH_CFLAGS!$PTH_CFLAGS$ac_delim PTH_LDFLAGS!$PTH_LDFLAGS$ac_delim @@ -26165,14 +26456,10 @@ HAVE_DOSISH_SYSTEM_TRUE!$HAVE_DOSISH_SYS HAVE_DOSISH_SYSTEM_FALSE!$HAVE_DOSISH_SYSTEM_FALSE$ac_delim HAVE_W32_SYSTEM_TRUE!$HAVE_W32_SYSTEM_TRUE$ac_delim HAVE_W32_SYSTEM_FALSE!$HAVE_W32_SYSTEM_FALSE$ac_delim -PKG_CONFIG!$PKG_CONFIG$ac_delim -GLIB_CFLAGS!$GLIB_CFLAGS$ac_delim -GLIB_LIBS!$GLIB_LIBS$ac_delim -GLIB_GENMARSHAL!$GLIB_GENMARSHAL$ac_delim -GOBJECT_QUERY!$GOBJECT_QUERY$ac_delim -GLIB_MKENUMS!$GLIB_MKENUMS$ac_delim BUILD_W32_GLIB_TRUE!$BUILD_W32_GLIB_TRUE$ac_delim BUILD_W32_GLIB_FALSE!$BUILD_W32_GLIB_FALSE$ac_delim +BUILD_W32_QT_TRUE!$BUILD_W32_QT_TRUE$ac_delim +BUILD_W32_QT_FALSE!$BUILD_W32_QT_FALSE$ac_delim HAVE_PTH_TRUE!$HAVE_PTH_TRUE$ac_delim HAVE_PTH_FALSE!$HAVE_PTH_FALSE$ac_delim HAVE_PTHREAD_TRUE!$HAVE_PTHREAD_TRUE$ac_delim @@ -26192,6 +26479,13 @@ HAVE_GPGSM_TRUE!$HAVE_GPGSM_TRUE$ac_deli HAVE_GPGSM_FALSE!$HAVE_GPGSM_FALSE$ac_delim RUN_GPGSM_TESTS_TRUE!$RUN_GPGSM_TESTS_TRUE$ac_delim RUN_GPGSM_TESTS_FALSE!$RUN_GPGSM_TESTS_FALSE$ac_delim +GPGCONF!$GPGCONF$ac_delim +HAVE_GPGCONF_TRUE!$HAVE_GPGCONF_TRUE$ac_delim +HAVE_GPGCONF_FALSE!$HAVE_GPGCONF_FALSE$ac_delim +RUN_GPGCONF_TESTS_TRUE!$RUN_GPGCONF_TESTS_TRUE$ac_delim +RUN_GPGCONF_TESTS_FALSE!$RUN_GPGCONF_TESTS_FALSE$ac_delim +BUILD_GPGCONF_TRUE!$BUILD_GPGCONF_TRUE$ac_delim +BUILD_GPGCONF_FALSE!$BUILD_GPGCONF_FALSE$ac_delim BUILD_ASSUAN_TRUE!$BUILD_ASSUAN_TRUE$ac_delim BUILD_ASSUAN_FALSE!$BUILD_ASSUAN_FALSE$ac_delim USE_DESCRIPTOR_PASSING_TRUE!$USE_DESCRIPTOR_PASSING_TRUE$ac_delim @@ -26207,7 +26501,7 @@ GPGME_CONFIG_CFLAGS!$GPGME_CONFIG_CFLAGS LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 75; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -26810,12 +27104,15 @@ fi echo " GPGME v${VERSION} has been configured as follows: - GnuPG path: $GPG - GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION + GnuPG path: $GPG + GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION + + GpgSM path: $GPGSM + GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION - GpgSM path: $GPGSM - GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION + GpgConf path: $GPGCONF + GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION - GPGME Pthread: $have_pthread - GPGME Pth: $have_pth + GPGME Pthread: $have_pthread + GPGME Pth: $have_pth " diff -urpNP gpgme-1.1.5/configure.ac gpgme-1.1.6/configure.ac --- gpgme-1.1.5/configure.ac 2007-07-09 13:07:55.000000000 +0000 +++ gpgme-1.1.6/configure.ac 2008-01-04 14:18:45.000000000 +0000 @@ -23,24 +23,22 @@ AC_PREREQ(2.59) min_automake_version="1.9.3" # Version number: Remember to change it immediately *after* a release. -# Make sure to run "svn up" before a "make dist". -# See below for the LT versions. +# Make sure to run "svn up" and "./autogen.sh --force" +# before a "make dist". See below for the LT versions. # -# The CVS version is usually the next intended release version with -# the string "-cvs" appended. The reason for this is that tests for a +# The SVN version is usually the next intended release version with +# the string "-svnNNN" appended. The reason for this is that tests for a # specific feature can already be done under the assumption that the -# CVS version is the most recent one in a branch. To disable the CVS -# version for the real release, just comment out the my_iscvs macro. -# Note, that we are now using Subversion instead of CVS and append the -# SVN revision number to the "cvs" suffix. To make this most useful -# for snapshot releases please do an "svn up" right before recreating -# the configure script, so that a proper revision number for all files -# is available when running a "make distcheck". -m4_define(my_version, [1.1.5]) -#m4_define(my_iscvs, yes) -AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit( - [$Revision: 1225 $],[Ra-z $:])]), - [bug-gpgme@gnupg.org]) +# SVN version is the most recent one in a branch. To disable the SVN +# version for the real release, set the my_issvn macro to no. +m4_define(my_version, [1.1.6]) +m4_define(my_issvn, [no]) + +m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ + || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) +AC_INIT([gpgme], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), + [bug-gpgme@gnupg.org]) + # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) @@ -59,6 +57,7 @@ GPGME_CONFIG_API_VERSION=1 ############################################## +BUILD_REVISION=svn_revision PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -83,6 +82,7 @@ AH_VERBATIM([_REENTRANT], #endif]) AC_PROG_CC +AC_PROG_CXX AC_SUBST(LIBGPGME_LT_CURRENT) AC_SUBST(LIBGPGME_LT_AGE) @@ -114,9 +114,12 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, t GPG_DEFAULT=no GPGSM_DEFAULT=no +GPGCONF_DEFAULT=no component_system=None have_dosish_system=no have_w32_system=no +build_w32_glib=no +build_w32_qt=no case "${host}" in *-mingw32*) # special stuff for Windoze NT @@ -124,7 +127,25 @@ case "${host}" in have_w32_system=yes GPG_DEFAULT='c:\\gnupg\\gpg.exe' GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' + GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe' #component_system='COM+' + + AM_PATH_GLIB_2_0 + AC_ARG_ENABLE(w32-glib, + AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]), + build_w32_glib=$enableval) + + # Check disabled, because the qt-dev packages in gpg4win do + # not provide any support for cross compilation. + # PKG_CHECK_MODULES(QT4_CORE, QtCore) + + # Use it like this: + # ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..." + AC_SUBST(QT4_CORE_CFLAGS) + AC_SUBST(QT4_CORE_LIBS) + AC_ARG_ENABLE(w32-qt, + AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]), + build_w32_qt=$enableval) ;; *) AC_CHECK_PTH(1.2.0,,,no,have_pth=yes) @@ -139,6 +160,7 @@ case "${host}" in # XXX: Probably use exec-prefix here? # GPG_DEFAULT='/usr/bin/gpg' # GPGSM_DEFAULT='/usr/bin/gpgsm' +# GPGCONF_DEFAULT='/usr/bin/gpgconf' ;; esac @@ -154,13 +176,8 @@ if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) - -build_w32_glib=no -AM_PATH_GLIB_2_0 -AC_ARG_ENABLE(w32-glib, - AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]), - build_w32_glib=$withval) AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes) +AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes) AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes") AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes") @@ -247,8 +264,10 @@ AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ER # Checks for system services NEED_GPG_VERSION_DEFAULT=1.3.0 NEED_GPGSM_VERSION_DEFAULT=1.9.6 +NEED_GPGCONF_VERSION_DEFAULT=2.0.4 NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT" NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT" +NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" AC_ARG_WITH(gpg-version, AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]), NEED_GPG_VERSION=$withval) @@ -267,11 +286,22 @@ fi if test "$NEED_GPGSM_VERSION" = "no"; then NEED_GPGSM_VERSION=0.0.0 fi +AC_ARG_WITH(gpgconf-version, + AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]), + NEED_GPGCONF_VERSION=$withval) +if test "$NEED_GPGCONF_VERSION" = "yes"; then + NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" +fi +if test "$NEED_GPGCONF_VERSION" = "no"; then + NEED_GPGCONF_VERSION=0.0.0 +fi AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION", [Min. needed GnuPG version.]) AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION", [Min. needed GPGSM version.]) +AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION", + [Min. needed GPGCONF version.]) NO_OVERRIDE=no @@ -463,6 +493,109 @@ AC_ARG_ENABLE(gpgsm-test, AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes") +NO_OVERRIDE=no +AC_ARG_WITH(gpgconf, + AC_HELP_STRING([--with-gpgconf=PATH], + [use gpgconf binary at PATH]), + GPGCONF=$withval, NO_OVERRIDE=yes) +if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then + GPGCONF= + NO_OVERRIDE=yes + if test "$cross_compiling" != "yes"; then + AC_PATH_PROG(GPGCONF, gpgconf) + fi + if test -z "$GPGCONF"; then + GPGCONF="$GPGCONF_DEFAULT" + fi +fi +if test "$GPGCONF" = no; then + if test "$NO_OVERRIDE" = "yes"; then + if test "$cross_compiling" != "yes"; then + AC_MSG_WARN([ +*** +*** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it +***]) + else + AC_MSG_ERROR([ +*** +*** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH +***]) + fi + fi +else + AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.]) + AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled]) +fi +AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no") + +dnl Check for GPGCONF version requirement. +GPGCONF_VERSION=unknown +ok=maybe +if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then + ok=no +else + if test "$cross_compiling" = "yes"; then + AC_MSG_WARN([GPGCONF version can not be checked when cross compiling]) + ok=no + else + if test ! -x "$GPGCONF"; then + AC_MSG_WARN([GPGCONF not executable, version check disabled]) + ok=no + fi + fi +fi +if test "$ok" = "maybe"; then + AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION) + req_major=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $NEED_GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'` + major=`echo $GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` + minor=`echo $GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` + micro=`echo $GPGCONF_VERSION | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` + + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -gt "$req_minor"; then + ok=yes + else + if test "$minor" -eq "$req_minor"; then + if test "$micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + if test "$ok" = "yes"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION]) + fi +fi +run_gpgconf_test="$ok" +AC_ARG_ENABLE(gpgconf-test, + AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]), + run_gpgconf_test=$enableval) +AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes") + +# Only build if supported. +AM_CONDITIONAL(BUILD_GPGCONF, test "$GPGCONF" != "no") +if test "$GPGCONF" != "no"; then + AC_DEFINE(HAVE_GPGCONF, 1, + [Defined if we are building with gpgconf support.]) +fi + + # FIXME: Only build if supported. AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no") if test "$GPGSM" != "no"; then @@ -562,10 +695,6 @@ AM_CONDITIONAL(BUILD_COMPLUS, test "$com GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION) # Generate values for the DLL version info -changequote(,)dnl -BUILD_REVISION="`echo '$Revision: 1225 $' | sed 's/[^0-9]//g'`" -changequote([,])dnl -test -z "$BUILD_REVISION" && BUILD_REVISION="0" if test "$have_w32_system" = yes; then BUILD_TIMESTAMP=`date --iso-8601=minutes` changequote(,)dnl @@ -624,12 +753,15 @@ AC_OUTPUT echo " GPGME v${VERSION} has been configured as follows: - GnuPG path: $GPG - GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION + GnuPG path: $GPG + GnuPG version: $GPG_VERSION, min. $NEED_GPG_VERSION + + GpgSM path: $GPGSM + GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION - GpgSM path: $GPGSM - GpgSM version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION + GpgConf path: $GPGCONF + GpgConf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION - GPGME Pthread: $have_pthread - GPGME Pth: $have_pth + GPGME Pthread: $have_pthread + GPGME Pth: $have_pth " diff -urpNP gpgme-1.1.5/doc/ChangeLog gpgme-1.1.6/doc/ChangeLog --- gpgme-1.1.5/doc/ChangeLog 2007-07-02 23:47:28.000000000 +0000 +++ gpgme-1.1.6/doc/ChangeLog 2007-09-27 12:11:25.000000000 +0000 @@ -1,3 +1,20 @@ +2007-09-27 Marcus Brinkmann + + * gpgme.texi (Protocols and Engines): Document GPGME_PROTOCOL_UNKNOWN. + +2007-09-11 Werner Koch + + * gpgme.texi (I/O Callback Example): Typo fix. + +2007-08-07 Werner Koch + + * gpgme.texi (Verify): Describe chain_model. + +2007-07-12 Werner Koch + + * gpgme.texi (Library Version Check): Add remark that the socket + layer will get initialized. + 2007-06-05 Marcus Brinkmann * gpgme.texi (Advanced Key Editing): New section. diff -urpNP gpgme-1.1.5/doc/Makefile.in gpgme-1.1.6/doc/Makefile.in --- gpgme-1.1.5/doc/Makefile.in 2007-07-09 13:08:30.000000000 +0000 +++ gpgme-1.1.6/doc/Makefile.in 2008-01-04 14:26:38.000000000 +0000 @@ -125,6 +125,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -166,6 +167,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/doc/gpgme.texi gpgme-1.1.6/doc/gpgme.texi --- gpgme-1.1.5/doc/gpgme.texi 2007-06-05 15:04:34.000000000 +0000 +++ gpgme-1.1.6/doc/gpgme.texi 2007-09-27 12:10:07.000000000 +0000 @@ -572,7 +572,11 @@ can verify that the version number is hi version number. In either case, the function initializes some sub-systems, and for this reason alone it must be invoked early in your program, before you make use of the other functions in -@acronym{GPGME}. +@acronym{GPGME}. + +As a side effect for W32 based systems, the socket layer will get +initialized. + If @var{required_version} is @code{NULL}, the function returns a pointer to a statically allocated string containing the version number @@ -744,6 +748,12 @@ This specifies the OpenPGP protocol. @item GPGME_PROTOCOL_CMS This specifies the Cryptographic Message Syntax. + +@item GPGME_PROTOCOL_UNKNOWN +Reserved for future extension. You may use this to indicate that the +used protocol is not known to the application. Currently, +@acronym{GPGME} does not accept this value in any operation, though, +except for @code{gpgme_get_protocol_name}. @end table @end deftp @@ -4072,6 +4082,16 @@ Values are: Depending on the configuration of the engine, this metric may also be reflected by the validity of the signature. +@item unsigned int chain_model : 1 +This is true if the validity of the signature has been checked using the +chain model. In the chain model the time the signature has been created +must be within the validity period of the certificate and the time the +certificate itself has been created must be within the validity period +of the issuing certificate. In contrast the default validation model +checks the validity of signature as well at the entire certificate chain +at the current time. + + @item gpgme_validity_t validity The validity of the signature. @@ -5017,7 +5037,7 @@ monitor these file descriptors for activ I/O callbacks. The following example illustrates how to do that. The example uses -locking to show in which way the the callbacks and the event loop can +locking to show in which way the callbacks and the event loop can run concurrently. For the event loop, we use a fixed array. For a real-world implementation, you should use a dynamically sized structure because the number of file descriptors needed for a crypto diff -urpNP gpgme-1.1.5/doc/stamp-vti gpgme-1.1.6/doc/stamp-vti --- gpgme-1.1.5/doc/stamp-vti 2007-07-09 13:14:16.000000000 +0000 +++ gpgme-1.1.6/doc/stamp-vti 2008-01-04 14:31:03.000000000 +0000 @@ -1,4 +1,4 @@ -@set UPDATED 5 June 2007 -@set UPDATED-MONTH June 2007 -@set EDITION 1.1.5 -@set VERSION 1.1.5 +@set UPDATED 27 September 2007 +@set UPDATED-MONTH September 2007 +@set EDITION 1.1.6 +@set VERSION 1.1.6 diff -urpNP gpgme-1.1.5/doc/version.texi gpgme-1.1.6/doc/version.texi --- gpgme-1.1.5/doc/version.texi 2007-07-09 13:14:16.000000000 +0000 +++ gpgme-1.1.6/doc/version.texi 2008-01-04 14:31:03.000000000 +0000 @@ -1,4 +1,4 @@ -@set UPDATED 5 June 2007 -@set UPDATED-MONTH June 2007 -@set EDITION 1.1.5 -@set VERSION 1.1.5 +@set UPDATED 27 September 2007 +@set UPDATED-MONTH September 2007 +@set EDITION 1.1.6 +@set VERSION 1.1.6 diff -urpNP gpgme-1.1.5/gpgme/ChangeLog gpgme-1.1.6/gpgme/ChangeLog --- gpgme-1.1.5/gpgme/ChangeLog 2007-07-08 15:46:47.000000000 +0000 +++ gpgme-1.1.6/gpgme/ChangeLog 2008-01-04 14:17:15.000000000 +0000 @@ -1,3 +1,322 @@ +2008-01-04 Marcus Brinkmann + + * Makefile.am (gpgconf_components): New variable. + (main_sources): Add gpgconf.c. + * gpgme.h (gpgme_protocol_t): New protocol GPGME_PROTOCOL_GPGCONF. + (gpgme_conf_level_t, gpgme_conf_type_t, gpgme_conf_arg_t) + (gpgme_conf_opt_t, gpgme_conf_comp_t, gpgme_conf_arg_new) + (gpgme_conf_arg_release, gpgme_conf_opt_change) + (gpgme_conf_release, gpgme_op_conf_load, gpgme_op_conf_save): New + types. + * gpgconf.c, engine-gpgconf.c: New files. + * engine.h: (_gpgme_engine_op_conf_load, + (_gpgme_engine_op_conf_save): New prototypes. + * op-support.c (_gpgme_op_reset): Ignore not implemented locale + function. + * posix-util.c (_gpgme_get_gpgconf_path): New function. + * w32-util.c (_gpgme_get_gpgconf_path): New function. + * engine-gpgsm.c: + (_gpgme_engine_ops_gpgsm): Add stubs for conf_load and conf_save. + * rungpg.c: + (_gpgme_engine_ops_gpg): Add stubs for conf_load and conf_save. + * gpgme.def: Add new gpgconf related interfaces. + * libgpgme.vers: Likewise. + * util.h (_gpgme_get_gpgconf_path): New prototype. + * gpgme.h (gpgme_protocol_t): Add GPGME_PROTOCOL_GPGCONF. + * engine-backend.h (_gpgme_engine_ops_gpgconf): New prototype. + (struct engine_ops): Add members for conf_load and conf_save. + * engine.c (engine_ops): Add _gpgme_engine_ops_gpgconf. + (_gpgme_engine_op_conf_load, + (_gpgme_engine_op_conf_save): New functions. + (gpgme_get_engine_info): Allow protocol GPGME_PROTOCOL_GPGCONF. + +2007-11-28 Marcus Brinkmann + + * w32-util.c (_gpgme_get_gpg_path, _gpgme_get_gpgsm_path): Search + for installation directory. Remove old fallback default. + (find_program_in_inst_dir): New function. + +2007-11-26 Werner Koch + + * engine-gpgsm.c (struct engine_gpgsm): Add field INLINE_DATA and + always reset it before calling start. + (gpgsm_new): Clear it. + (status_handler): Implement it. + (gpgsm_getauditlog) [USE_DESCRIPTOR_PASSING]: Use INLINE_DATA. + +2007-11-23 Werner Koch + + * op-support.c (_gpgme_op_reset): Implement a no-reset flag. + * getauditlog.c (getauditlog_start): Use that flag. + +2007-11-22 Werner Koch + + * gpgme.h (gpgme_op_getauditlog_start, gpgme_op_getauditlog): New. + * libgpgme.vers: Ditto. + * gpgme.def: Ditto. + * getauditlog.c: New. + * engine-backend.h (struct engine_ops): Add member GETAUDITLOG. + * engine-gpgsm.c (gpgsm_getauditlog): New. + (_gpgme_engine_ops_gpgsm): Insert new function. + (gpgsm_new): Try to enable audit log support. + * rungpg.c (_gpgme_engine_ops_gpg): Insert dummy entry. + +2007-11-20 Werner Koch + + * op-support.c (_gpgme_parse_inv_recp): Add new reason code 11. + +2007-11-12 Marcus Brinkmann + + * kdpipeiodevice.cpp: New version from Frank Osterfeld. + +2007-10-11 Marcus Brinkmann + + * kdpipeiodevice.cpp: New version from Frank Osterfeld. + +2007-10-09 Marcus Brinkmann + + * kdpipeiodevice.cpp: New version from Frank Osterfeld and Marc + Mutz. + +2007-10-05 Marcus Brinkmann + + * kdpipeiodevice.cpp, w32-qt-io.cpp: New versions from Frank + Osterfeld. + +2007-10-04 Marcus Brinkmann + + * kdpipeiodevice.h, kdpipeiodevice.cpp, kdpipeiodevice.moc, + w32-qt-io.cpp: New versions from Frank Osterfeld. + +2007-10-02 Marcus Brinkmann + + * kdpipeiodevice.cpp, kdpipeiodevice.moc: New versions. + * w32-qt-io.cpp (_gpgme_io_fd2str): Print actual_fd if available. + (_gpgme_io_dup): Only acquire a reference, do not actually dup. + Submitted by Frank Osterfeld. + + * priv-io.h, engine-gpgsm.c: Add comments. + * w32-qt-io.cpp (_gpgme_io_select): Remove code handling frozen FDs. + * w32-glib-io.c (_gpgme_io_close): Always dereference the channel, + even if not primary. + (_gpgme_io_dup): Acquire a reference. Replace unused + implementation by assertion. + +2007-09-28 Werner Koch + + * engine-gpgsm.c (iocb_data_t): Add SERVER_FD_STR. + (gpgsm_new): Set it. + (gpgsm_set_fd): Use it. + + * w32-glib-io.c (find_channel): Add a new primary flag. + (_gpgme_io_close): Close channel only if primary. + (_gpgme_io_dup): Put newfd into the table as shallow copy. + + * priv-io.h (struct io_select_fd_s): Remove member FROZEN. + * w32-io.c (_gpgme_io_select): Ditto. + * w32-glib-io.c (_gpgme_io_select): Ditto. + + * posix-io.c (_gpgme_io_select): Ditto. + * rungpg.c (read_status): Ditto. + * wait.c (fd_table_put): Ditto. + + * rungpg.c (gpg_io_event): Add tracing. + (start): Use gpg_io_event for sending the start event. + * engine-gpgsm.c (gpgsm_io_event): Add tracing. + (start): Use gpgsm_io_event for sending the start event. + * wait.c (_gpgme_add_io_cb, _gpgme_run_io_cb): Add tracing. + +2007-09-28 Marcus Brinkmann + + * kdpipeiodevice.moc, w32-qt-io.cpp, kdpipeiodevice.cpp: New + versions from Frank Osterfeld. + +2007-09-27 Marcus Brinkmann + + * w32-glib-io.c (_gpgme_io_spawn), + w32-qt-io.cpp (_gpgme_io_spawn), w32-io.c (_gpgme_io_spawn): Close + the process handle, return 0. + + * gpgme.h (gpgme_protocol_t): Add GPGME_PROTOCOL_UNKNOWN. + * gpgme.c (gpgme_get_protocol_name): Implement support for + GPGME_PROTOCOL_UNKNOWN. + + * kdpipeiodevice.h: Fix last change. + + * w32-glib-io.c (_gpgme_io_pipe), w32-qt-io.c (_gpgme_io_pipe), + w32-io.c (_gpgme_io_pipe), posix-io.c (_gpgme_io_pipe): Fix debug + output. + +2007-09-25 Marcus Brinkmann + + * conversion.c, keylist.c: Include . + + * kdpipeiodevice.h: Use namespace _gpgme_. + * kdpipeiodevice.cpp: Use namespace _gpgme_. + [Q_OS_WIN32 && NOMINMAX]: Do not define NOMINMAX again. + * w32-qt-io.cpp: Change namespace of KDPipeIODevice to + _gpgme_::KDPipeIODevice. + +2007-09-17 Werner Koch + + * rungpg.c (gpg_new): Make robust against undefined ttyname or + ttytype. + +2007-09-14 Werner Koch + + * data-mem.c (gpgme_data_release_and_get_mem): Fix tracing bug. + +2007-09-14 Marcus Brinkmann + + * gpgme.c (gpgme_release): Call gpgme_sig_notation_clear. + +2007-09-13 Marcus Brinkmann + + * rungpg.c (gpg_new): Handle return value of _gpgme_getenv (fixes + small memory leak). + +2007-09-07 Marcus Brinkmann + + * Makefile.am (libgpgme_qt_la_SOURCES): Move + moc_kdpipeiodevice.cpp to EXTRA_DIST, as this is only included by + another file (it's more like a header file than a cpp file, but + automake doesn't know that). + + * w32-qt-io.cpp (_gpgme_io_spawn): Fix several cast errors and typos. + * w32-io.c (_gpgme_io_write): Use TRACE_SYSRES instead of TRACE_SYS. + (libgpgme_qt_la_LIBADD): Add QT4_CORE_LIBS, not QT4_CORE_LIB. + + * kdpipeiodevice.h, kdpipeiodevice.cpp, moc_kdpipeiodevice.cpp, + kdpipeiodevice.moc, w32-qt-io.c: New files. + * Makefile.am (ltlib_gpgme_extra): Rename to ltlib_gpgme_glib. + (ltlib_gpgme_qt): New variable. + (lib_LTLIBRARIES): Add $(ltlib_gpgme_qt). + (libgpgme_qt_la_SOURCES): New variable. + (AM_CPPFLAGS): Add @QT4_CORE_INCLUDES@ + (AM_CFLAGS): Add @QT4_CORE_CFLAGS@. + (libgpgme_qt_la_LDFLAGS, libgpgme_qt_la_DEPENDENCIES) + (libgpgme_qt_la_LIBADD): New variables. + + * sema.h (struct critsect_s): Rename "private" to "priv" to make + C++ users happy. Change users. + * posix-sema.c (_gpgme_sema_cs_enter, _gpgme_sema_cs_leave) + (_gpgme_sema_cs_destroy): Likewise. + * w32-sema.c (critsect_init, _gpgme_sema_cs_enter) + (_gpgme_sema_cs_leave, _gpgme_sema_cs_destroy): Likewise. + * w32-glib-io.c (gpgme_get_giochannel): Change return type to + void*. + (gpgme_get_fdptr): New function. + * w32-io.c (gpgme_get_fdptr): New function + * gpgme.def: Add gpgme_get_fdptr. + +2007-08-22 Marcus Brinkmann + + * w32-io.c (_gpgme_io_write): Return early if COUNT is zero. + (writer): Remove superfluous check. + +2007-08-20 Marcus Brinkmann + + * gpgme.h: Move include of gpg-error.h out of extern "C". + +2007-08-07 Werner Koch + + * gpgme.h (struct _gpgme_signature): Add member CHAIN_MODEL. + * verify.c (parse_trust): Set Chain_MODEL. + +2007-08-02 Werner Koch + + * w32-glib-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS flag. + * w32-io.c (_gpgme_io_spawn): Ditto. + (_gpgme_io_write): Map ERROR_NO_DATA to EPIPE. + * debug.c (_gpgme_debug): Enable assuan logging. + (_gpgme_debug_subsystem_init): New. * version.c + (do_subsystem_inits): Disable assuan logging and initialize de + debug system. + (gpgme_check_version): Do not trace before the subsystems are + initialized. + +2007-07-17 Marcus Brinkmann + + * debug.c: Include 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 + + * engine-gpgsm.c (status_handler): Do not send BYE here. + + * w32-io.c (struct reader_context_s, struct writer_context_s): New + members REFCOUNT. + (create_reader, create_writer): Initialize C->refcount to 1. + (destroy_reader, destroy_writer): Only destroy if C->refcount + drops to 0. + (find_reader, find_writer, kill_reader, kill_writer): Beautify. + * priv-io.h (_gpgme_io_dup): New prototype. + * posix-io.c (_gpgme_io_dup): New function. + * w32-io.c (_gpgme_io_dup): Likewise. + * w32-glib-io.c (_gpgme_io_dup): Likewise. + * engine-gpgsm.c (start): Reverting to version 2007-07-10. + +2007-07-13 Marcus Brinkmann + + * data-user.c (user_read, user_write, user_seek): Set errno and + return -1 instead returning the error code directly. + * data-compat.c (old_user_seek): Likewise. + * gpgme.c (gpgme_sig_notation_add): Return error properly. + + * Revert the "close_notify_handler" returns int stuff. Always + close in the _gpgme_io_close implementations. + * engine-gpgsm.c (status_handler): Try to terminate the connection + in case of error. + * w32-io.c (_gpgme_io_read): Return C->error_code in ERRNO. + (_gpgme_io_write): Likewise. + + * priv-io.h (_gpgme_io_set_close_notify): Change type of HANDLER + to _gpgme_close_notify_handler. + (_gpgme_close_notify_handler): New type. + (_gpgme_io_dup): Remove prototype. + * posix-io.c (notify_table, _gpgme_io_set_close_notify): Change + type of HANDLER to _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + (_gpgme_io_dup): Remove function. + * w32-io.c (notify_table, _gpgme_io_set_close_notify, + _gpgme_io_close): Change type of HANDLER to + _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + (_gpgme_io_dup): Remove function. + * w32-glib-io.c (_gpgme_io_dup): Remove function. + (_gpgme_io_set_close_notify, notify_table): Change type of HANDLER + to _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + * rungpg.c (close_notify_handler): Change return type to int, + return 1. + * engine-gpgsm.c (close_notify_handler): Change return type to + int, return 0 for status FD and 1 for all other FDs. + (start): Do not duplicate the status FD. + +2007-07-12 Marcus Brinkmann + + * Makefile.am: Replace implicite rule by suffix rule. Add + SUFFIXES for that. + +2007-07-12 Werner Koch + + * version.c (do_subsystem_inits) [W32]: Make sure that the socket + system has been started. + +2007-07-10 Marcus Brinkmann + + * priv-io.h (_gpgme_io_dup): New prototype. + * posix-io.c (_gpgme_io_dup): New function. + * w32-io.c (_gpgme_io_dup): Likewise. + * w32-glib-io.c (_gpgme_io_dup): Likewise. + * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). + 2007-07-08 Marcus Brinkmann * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. @@ -5312,7 +5631,7 @@ * data.c (gpgme_data_rewind): Allow to rewind data_type_none. - Copyright 2001, 2002, 2003, 2004, 2005 g10 Code GmbH + Copyright 2001,2002,2003,2004,2005,2006,2007 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff -urpNP gpgme-1.1.5/gpgme/Makefile.am gpgme-1.1.6/gpgme/Makefile.am --- gpgme-1.1.5/gpgme/Makefile.am 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/Makefile.am 2008-01-04 14:17:15.000000000 +0000 @@ -1,5 +1,5 @@ - # Copyright (C) 2000 Werner Koch (dd9jn) -# Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH # # This file is part of GPGME. # @@ -19,8 +19,9 @@ ## Process this file with automake to produce Makefile.in +# Note: moc_kdpipeiodevice should actually be a dependcy below. EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers \ - versioninfo.rc.in gpgme.def + versioninfo.rc.in gpgme.def moc_kdpipeiodevice.cpp BUILT_SOURCES = status-table.h MOSTLYCLEANFILES = status-table.h bin_SCRIPTS = gpgme-config @@ -40,12 +41,18 @@ ltlib_gpgme_pth = endif if BUILD_W32_GLIB -ltlib_gpgme_extra = libgpgme-glib.la +ltlib_gpgme_glib = libgpgme-glib.la else -ltlib_gpgme_extra = +ltlib_gpgme_glib = endif -lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_extra) \ +if BUILD_W32_QT +ltlib_gpgme_qt = libgpgme-qt.la +else +ltlib_gpgme_qt = +endif + +lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \ $(ltlib_gpgme_pthread) $(ltlib_gpgme_pth) if HAVE_LD_VERSION_SCRIPT @@ -76,6 +83,12 @@ else gpgsm_components = endif +if HAVE_GPGCONF +gpgconf_components = engine-gpgconf.c +else +gpgconf_components = +endif + # These are the source files common to all library versions. We used # to build a non-installed library for that, but that does not work # correctly on all platforms (in particular, one can not specify the @@ -91,9 +104,10 @@ main_sources = \ encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c \ sign.c passphrase.c progress.c \ key.c keylist.c trust-item.c trustlist.c \ - import.c export.c genkey.c delete.c edit.c \ + import.c export.c genkey.c delete.c edit.c getauditlog.c \ engine.h engine-backend.h engine.c rungpg.c status-table.h \ - $(gpgsm_components) sema.h priv-io.h $(system_components) \ + $(gpgsm_components) $(gpgconf_components) gpgconf.c \ + sema.h priv-io.h $(system_components) \ debug.c debug.h gpgme.c version.c error.c libgpgme_la_SOURCES = $(main_sources) \ @@ -107,10 +121,24 @@ if BUILD_W32_GLIB libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c endif +if BUILD_W32_QT +libgpgme_qt_la_SOURCES = $(main_sources) ath.h ath.c w32-qt-io.cpp \ + kdpipeiodevice.h kdpipeiodevice.cpp kdpipeiodevice.moc +# FIXME: Add extra depedency: moc_kdpipeiodevice.cpp + +# These are built sources (normally). +# moc_kdpipeiodevice.cpp: kdpipeiodevice.h +# $(MOC4) -o $@ $< +# +# kdpipeiodevice.moc: kdpipeiodevice.cpp +# $(MOC4) -o $@ $< +endif + # We use a global CFLAGS and CPPFLAGS setting for all library # versions, because then every object file is only compiled once. -AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ -AM_CFLAGS = @PTH_CFLAGS@ @GLIB_CFLAGS@ +AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ \ + @QT4_CORE_CFLAGS@ +AM_CFLAGS = @PTH_CFLAGS@ @GLIB_CFLAGS@ @QT4_CORE_CFLAGS@ if HAVE_W32_SYSTEM @@ -118,7 +146,9 @@ LTRCCOMPILE = $(LIBTOOL) --mode=compile `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -%.lo : %.rc +SUFFIXES: .rc .lo + +.rc.lo: $(LTRCCOMPILE) -i $< -o $@ gpgme_res = versioninfo.lo @@ -179,6 +209,16 @@ libgpgme_glib_la_LIBADD = $(assuan_libob @GPG_ERROR_LIBS@ @GLIB_LIBS@ @NETLIBS@ endif +if BUILD_W32_QT +libgpgme_qt_la_LDFLAGS = $(gpgme_res_ldflag) $(no_undefined) \ + $(export_symbols) $(libgpgme_version_script_cmd) -version-info \ + @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ +libgpgme_qt_la_DEPENDENCIES = $(assuan_libobjs) \ + @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps) +libgpgme_qt_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \ + @GPG_ERROR_LIBS@ @QT4_CORE_LIBS@ @NETLIBS@ +endif + status-table.h : gpgme.h $(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h diff -urpNP gpgme-1.1.5/gpgme/Makefile.in gpgme-1.1.6/gpgme/Makefile.in --- gpgme-1.1.5/gpgme/Makefile.in 2007-07-09 13:08:30.000000000 +0000 +++ gpgme-1.1.6/gpgme/Makefile.in 2008-01-04 14:26:38.000000000 +0000 @@ -14,6 +14,25 @@ @SET_MAKE@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH +# +# This file is part of GPGME. +# +# GPGME is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# GPGME is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General +# Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + @@ -69,24 +88,27 @@ am__libgpgme_glib_la_SOURCES_DIST = gpgm wait.h op-support.c encrypt.c encrypt-sign.c decrypt.c \ decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \ keylist.c trust-item.c trustlist.c import.c export.c genkey.c \ - delete.c edit.c engine.h engine-backend.h engine.c rungpg.c \ - status-table.h engine-gpgsm.c sema.h priv-io.h ath.h \ - posix-util.c posix-sema.c posix-io.c w32-util.c w32-sema.c \ - debug.c debug.h gpgme.c version.c error.c ath.c w32-glib-io.c + delete.c edit.c getauditlog.c engine.h engine-backend.h \ + engine.c rungpg.c status-table.h engine-gpgsm.c \ + engine-gpgconf.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \ + posix-sema.c posix-io.c w32-util.c w32-sema.c debug.c debug.h \ + gpgme.c version.c error.c ath.c w32-glib-io.c @HAVE_GPGSM_TRUE@am__objects_1 = engine-gpgsm.lo -@HAVE_DOSISH_SYSTEM_FALSE@am__objects_2 = posix-util.lo posix-sema.lo \ +@HAVE_GPGCONF_TRUE@am__objects_2 = engine-gpgconf.lo +@HAVE_DOSISH_SYSTEM_FALSE@am__objects_3 = posix-util.lo posix-sema.lo \ @HAVE_DOSISH_SYSTEM_FALSE@ posix-io.lo -@HAVE_DOSISH_SYSTEM_TRUE@am__objects_2 = w32-util.lo w32-sema.lo -am__objects_3 = conversion.lo get-env.lo data.lo data-fd.lo \ +@HAVE_DOSISH_SYSTEM_TRUE@am__objects_3 = w32-util.lo w32-sema.lo +am__objects_4 = conversion.lo get-env.lo data.lo data-fd.lo \ data-stream.lo data-mem.lo data-user.lo data-compat.lo \ signers.lo sig-notation.lo wait.lo wait-global.lo \ wait-private.lo wait-user.lo op-support.lo encrypt.lo \ encrypt-sign.lo decrypt.lo decrypt-verify.lo verify.lo sign.lo \ passphrase.lo progress.lo key.lo keylist.lo trust-item.lo \ trustlist.lo import.lo export.lo genkey.lo delete.lo edit.lo \ - engine.lo rungpg.lo $(am__objects_1) $(am__objects_2) debug.lo \ - gpgme.lo version.lo error.lo -@BUILD_W32_GLIB_TRUE@am_libgpgme_glib_la_OBJECTS = $(am__objects_3) \ + getauditlog.lo engine.lo rungpg.lo $(am__objects_1) \ + $(am__objects_2) gpgconf.lo $(am__objects_3) debug.lo gpgme.lo \ + version.lo error.lo +@BUILD_W32_GLIB_TRUE@am_libgpgme_glib_la_OBJECTS = $(am__objects_4) \ @BUILD_W32_GLIB_TRUE@ ath.lo w32-glib-io.lo libgpgme_glib_la_OBJECTS = $(am_libgpgme_glib_la_OBJECTS) libgpgme_glib_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -100,13 +122,14 @@ am__libgpgme_pth_la_SOURCES_DIST = gpgme wait.h op-support.c encrypt.c encrypt-sign.c decrypt.c \ decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \ keylist.c trust-item.c trustlist.c import.c export.c genkey.c \ - delete.c edit.c engine.h engine-backend.h engine.c rungpg.c \ - status-table.h engine-gpgsm.c sema.h priv-io.h ath.h \ - posix-util.c posix-sema.c posix-io.c w32-util.c w32-sema.c \ - debug.c debug.h gpgme.c version.c error.c ath-pth.c w32-io.c -@HAVE_DOSISH_SYSTEM_TRUE@am__objects_4 = w32-io.lo -am_libgpgme_pth_la_OBJECTS = $(am__objects_3) ath-pth.lo \ - $(am__objects_4) + delete.c edit.c getauditlog.c engine.h engine-backend.h \ + engine.c rungpg.c status-table.h engine-gpgsm.c \ + engine-gpgconf.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \ + posix-sema.c posix-io.c w32-util.c w32-sema.c debug.c debug.h \ + gpgme.c version.c error.c ath-pth.c w32-io.c +@HAVE_DOSISH_SYSTEM_TRUE@am__objects_5 = w32-io.lo +am_libgpgme_pth_la_OBJECTS = $(am__objects_4) ath-pth.lo \ + $(am__objects_5) libgpgme_pth_la_OBJECTS = $(am_libgpgme_pth_la_OBJECTS) libgpgme_pth_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -119,18 +142,38 @@ am__libgpgme_pthread_la_SOURCES_DIST = g wait.h op-support.c encrypt.c encrypt-sign.c decrypt.c \ decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \ keylist.c trust-item.c trustlist.c import.c export.c genkey.c \ - delete.c edit.c engine.h engine-backend.h engine.c rungpg.c \ - status-table.h engine-gpgsm.c sema.h priv-io.h ath.h \ - posix-util.c posix-sema.c posix-io.c w32-util.c w32-sema.c \ - debug.c debug.h gpgme.c version.c error.c ath-pthread.c \ - w32-io.c -am_libgpgme_pthread_la_OBJECTS = $(am__objects_3) ath-pthread.lo \ - $(am__objects_4) + delete.c edit.c getauditlog.c engine.h engine-backend.h \ + engine.c rungpg.c status-table.h engine-gpgsm.c \ + engine-gpgconf.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \ + posix-sema.c posix-io.c w32-util.c w32-sema.c debug.c debug.h \ + gpgme.c version.c error.c ath-pthread.c w32-io.c +am_libgpgme_pthread_la_OBJECTS = $(am__objects_4) ath-pthread.lo \ + $(am__objects_5) libgpgme_pthread_la_OBJECTS = $(am_libgpgme_pthread_la_OBJECTS) libgpgme_pthread_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libgpgme_pthread_la_LDFLAGS) $(LDFLAGS) -o $@ @HAVE_PTHREAD_TRUE@am_libgpgme_pthread_la_rpath = -rpath $(libdir) +am__libgpgme_qt_la_SOURCES_DIST = gpgme.h util.h conversion.c \ + get-env.c context.h ops.h data.h data.c data-fd.c \ + data-stream.c data-mem.c data-user.c data-compat.c signers.c \ + sig-notation.c wait.c wait-global.c wait-private.c wait-user.c \ + wait.h op-support.c encrypt.c encrypt-sign.c decrypt.c \ + decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \ + keylist.c trust-item.c trustlist.c import.c export.c genkey.c \ + delete.c edit.c getauditlog.c engine.h engine-backend.h \ + engine.c rungpg.c status-table.h engine-gpgsm.c \ + engine-gpgconf.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \ + posix-sema.c posix-io.c w32-util.c w32-sema.c debug.c debug.h \ + gpgme.c version.c error.c ath.c w32-qt-io.cpp kdpipeiodevice.h \ + kdpipeiodevice.cpp kdpipeiodevice.moc +@BUILD_W32_QT_TRUE@am_libgpgme_qt_la_OBJECTS = $(am__objects_4) ath.lo \ +@BUILD_W32_QT_TRUE@ w32-qt-io.lo kdpipeiodevice.lo +libgpgme_qt_la_OBJECTS = $(am_libgpgme_qt_la_OBJECTS) +libgpgme_qt_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libgpgme_qt_la_LDFLAGS) $(LDFLAGS) -o $@ +@BUILD_W32_QT_TRUE@am_libgpgme_qt_la_rpath = -rpath $(libdir) am__libgpgme_la_SOURCES_DIST = gpgme.h util.h conversion.c get-env.c \ context.h ops.h data.h data.c data-fd.c data-stream.c \ data-mem.c data-user.c data-compat.c signers.c sig-notation.c \ @@ -138,11 +181,12 @@ am__libgpgme_la_SOURCES_DIST = gpgme.h u op-support.c encrypt.c encrypt-sign.c decrypt.c \ decrypt-verify.c verify.c sign.c passphrase.c progress.c key.c \ keylist.c trust-item.c trustlist.c import.c export.c genkey.c \ - delete.c edit.c engine.h engine-backend.h engine.c rungpg.c \ - status-table.h engine-gpgsm.c sema.h priv-io.h ath.h \ - posix-util.c posix-sema.c posix-io.c w32-util.c w32-sema.c \ - debug.c debug.h gpgme.c version.c error.c ath.c w32-io.c -am_libgpgme_la_OBJECTS = $(am__objects_3) ath.lo $(am__objects_4) + delete.c edit.c getauditlog.c engine.h engine-backend.h \ + engine.c rungpg.c status-table.h engine-gpgsm.c \ + engine-gpgconf.c gpgconf.c sema.h priv-io.h ath.h posix-util.c \ + posix-sema.c posix-io.c w32-util.c w32-sema.c debug.c debug.h \ + gpgme.c version.c error.c ath.c w32-io.c +am_libgpgme_la_OBJECTS = $(am__objects_4) ath.lo $(am__objects_5) libgpgme_la_OBJECTS = $(am_libgpgme_la_OBJECTS) libgpgme_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -161,11 +205,22 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ SOURCES = $(libgpgme_glib_la_SOURCES) $(libgpgme_pth_la_SOURCES) \ - $(libgpgme_pthread_la_SOURCES) $(libgpgme_la_SOURCES) + $(libgpgme_pthread_la_SOURCES) $(libgpgme_qt_la_SOURCES) \ + $(libgpgme_la_SOURCES) DIST_SOURCES = $(am__libgpgme_glib_la_SOURCES_DIST) \ $(am__libgpgme_pth_la_SOURCES_DIST) \ $(am__libgpgme_pthread_la_SOURCES_DIST) \ + $(am__libgpgme_qt_la_SOURCES_DIST) \ $(am__libgpgme_la_SOURCES_DIST) m4dataDATA_INSTALL = $(INSTALL_DATA) DATA = $(m4data_DATA) @@ -213,6 +268,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -254,6 +310,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ @@ -311,25 +369,10 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH -# -# This file is part of GPGME. -# -# GPGME is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of the -# License, or (at your option) any later version. -# -# GPGME is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General -# Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +# Note: moc_kdpipeiodevice should actually be a dependcy below. EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers \ - versioninfo.rc.in gpgme.def + versioninfo.rc.in gpgme.def moc_kdpipeiodevice.cpp BUILT_SOURCES = status-table.h MOSTLYCLEANFILES = status-table.h @@ -341,9 +384,11 @@ include_HEADERS = gpgme.h @HAVE_PTHREAD_TRUE@ltlib_gpgme_pthread = libgpgme-pthread.la @HAVE_PTH_FALSE@ltlib_gpgme_pth = @HAVE_PTH_TRUE@ltlib_gpgme_pth = libgpgme-pth.la -@BUILD_W32_GLIB_FALSE@ltlib_gpgme_extra = -@BUILD_W32_GLIB_TRUE@ltlib_gpgme_extra = libgpgme-glib.la -lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_extra) \ +@BUILD_W32_GLIB_FALSE@ltlib_gpgme_glib = +@BUILD_W32_GLIB_TRUE@ltlib_gpgme_glib = libgpgme-glib.la +@BUILD_W32_QT_FALSE@ltlib_gpgme_qt = +@BUILD_W32_QT_TRUE@ltlib_gpgme_qt = libgpgme-qt.la +lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \ $(ltlib_gpgme_pthread) $(ltlib_gpgme_pth) @HAVE_LD_VERSION_SCRIPT_FALSE@libgpgme_version_script_cmd = @@ -358,6 +403,8 @@ lib_LTLIBRARIES = libgpgme.la $(ltlib_gp @HAVE_DOSISH_SYSTEM_TRUE@system_components_not_extra = w32-io.c @HAVE_GPGSM_FALSE@gpgsm_components = @HAVE_GPGSM_TRUE@gpgsm_components = engine-gpgsm.c +@HAVE_GPGCONF_FALSE@gpgconf_components = +@HAVE_GPGCONF_TRUE@gpgconf_components = engine-gpgconf.c # These are the source files common to all library versions. We used # to build a non-installed library for that, but that does not work @@ -374,9 +421,10 @@ main_sources = \ encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c \ sign.c passphrase.c progress.c \ key.c keylist.c trust-item.c trustlist.c \ - import.c export.c genkey.c delete.c edit.c \ + import.c export.c genkey.c delete.c edit.c getauditlog.c \ engine.h engine-backend.h engine.c rungpg.c status-table.h \ - $(gpgsm_components) sema.h priv-io.h $(system_components) \ + $(gpgsm_components) $(gpgconf_components) gpgconf.c \ + sema.h priv-io.h $(system_components) \ debug.c debug.h gpgme.c version.c error.c libgpgme_la_SOURCES = $(main_sources) \ @@ -389,11 +437,24 @@ libgpgme_pth_la_SOURCES = $(main_sources ath.h ath-pth.c $(system_components_not_extra) @BUILD_W32_GLIB_TRUE@libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c +@BUILD_W32_QT_TRUE@libgpgme_qt_la_SOURCES = $(main_sources) ath.h ath.c w32-qt-io.cpp \ +@BUILD_W32_QT_TRUE@ kdpipeiodevice.h kdpipeiodevice.cpp kdpipeiodevice.moc + +# FIXME: Add extra depedency: moc_kdpipeiodevice.cpp + +# These are built sources (normally). +# moc_kdpipeiodevice.cpp: kdpipeiodevice.h +# $(MOC4) -o $@ $< +# +# kdpipeiodevice.moc: kdpipeiodevice.cpp +# $(MOC4) -o $@ $< # We use a global CFLAGS and CPPFLAGS setting for all library # versions, because then every object file is only compiled once. -AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ -AM_CFLAGS = @PTH_CFLAGS@ @GLIB_CFLAGS@ +AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ @PTH_CPPFLAGS@ \ + @QT4_CORE_CFLAGS@ + +AM_CFLAGS = @PTH_CFLAGS@ @GLIB_CFLAGS@ @QT4_CORE_CFLAGS@ @HAVE_W32_SYSTEM_TRUE@LTRCCOMPILE = $(LIBTOOL) --mode=compile $(RC) \ @HAVE_W32_SYSTEM_TRUE@ `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ @HAVE_W32_SYSTEM_TRUE@ sed -e 's/-I/--include-dir /g;s/-D/--define /g'` @@ -447,11 +508,21 @@ libgpgme_pth_la_LIBADD = $(assuan_libobj @BUILD_W32_GLIB_TRUE@libgpgme_glib_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \ @BUILD_W32_GLIB_TRUE@ @GPG_ERROR_LIBS@ @GLIB_LIBS@ @NETLIBS@ +@BUILD_W32_QT_TRUE@libgpgme_qt_la_LDFLAGS = $(gpgme_res_ldflag) $(no_undefined) \ +@BUILD_W32_QT_TRUE@ $(export_symbols) $(libgpgme_version_script_cmd) -version-info \ +@BUILD_W32_QT_TRUE@ @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ + +@BUILD_W32_QT_TRUE@libgpgme_qt_la_DEPENDENCIES = $(assuan_libobjs) \ +@BUILD_W32_QT_TRUE@ @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps) + +@BUILD_W32_QT_TRUE@libgpgme_qt_la_LIBADD = $(assuan_libobjs) @LTLIBOBJS@ \ +@BUILD_W32_QT_TRUE@ @GPG_ERROR_LIBS@ @QT4_CORE_LIBS@ @NETLIBS@ + all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .cpp .lo .o .obj .rc $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -518,6 +589,8 @@ libgpgme-pth.la: $(libgpgme_pth_la_OBJEC $(libgpgme_pth_la_LINK) $(am_libgpgme_pth_la_rpath) $(libgpgme_pth_la_OBJECTS) $(libgpgme_pth_la_LIBADD) $(LIBS) libgpgme-pthread.la: $(libgpgme_pthread_la_OBJECTS) $(libgpgme_pthread_la_DEPENDENCIES) $(libgpgme_pthread_la_LINK) $(am_libgpgme_pthread_la_rpath) $(libgpgme_pthread_la_OBJECTS) $(libgpgme_pthread_la_LIBADD) $(LIBS) +libgpgme-qt.la: $(libgpgme_qt_la_OBJECTS) $(libgpgme_qt_la_DEPENDENCIES) + $(libgpgme_qt_la_LINK) $(am_libgpgme_qt_la_rpath) $(libgpgme_qt_la_OBJECTS) $(libgpgme_qt_la_LIBADD) $(LIBS) libgpgme.la: $(libgpgme_la_OBJECTS) $(libgpgme_la_DEPENDENCIES) $(libgpgme_la_LINK) -rpath $(libdir) $(libgpgme_la_OBJECTS) $(libgpgme_la_LIBADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @@ -571,14 +644,18 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encrypt-sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encrypt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engine-gpgconf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engine-gpgsm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engine.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get-env.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getauditlog.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpgconf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpgme.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/import.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kdpipeiodevice.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keylist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op-support.Plo@am__quote@ @@ -597,6 +674,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-glib-io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-io.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-qt-io.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-sema.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w32-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait-global.Plo@am__quote@ @@ -625,6 +703,27 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + mostlyclean-libtool: -rm -f *.lo @@ -854,9 +953,10 @@ uninstall-am: uninstall-binSCRIPTS unins uninstall-binSCRIPTS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-local uninstall-m4dataDATA - # Copyright (C) 2000 Werner Koch (dd9jn) -@HAVE_W32_SYSTEM_TRUE@%.lo : %.rc +@HAVE_W32_SYSTEM_TRUE@SUFFIXES: .rc .lo + +@HAVE_W32_SYSTEM_TRUE@.rc.lo: @HAVE_W32_SYSTEM_TRUE@ $(LTRCCOMPILE) -i $< -o $@ @HAVE_W32_SYSTEM_TRUE@install-def-file: diff -urpNP gpgme-1.1.5/gpgme/conversion.c gpgme-1.1.6/gpgme/conversion.c --- gpgme-1.1.5/gpgme/conversion.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/conversion.c 2007-10-04 11:06:46.000000000 +0000 @@ -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. @@ -25,12 +25,14 @@ #include #include +/* Solaris 8 needs sys/types.h before time.h. */ +#include #include #include #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 +394,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; } diff -urpNP gpgme-1.1.5/gpgme/data-compat.c gpgme-1.1.6/gpgme/data-compat.c --- gpgme-1.1.5/gpgme/data-compat.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/data-compat.c 2007-10-04 11:06:48.000000000 +0000 @@ -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 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 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 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 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); - - if (no) - { - errno = no; - return -1; - } + int res = gpg_err_code_to_errno (err); - switch (gpg_err_code (err)) + if (!err) { - case GPG_ERR_EOF: - return 0; - case GPG_ERR_INV_VALUE: - errno = EINVAL; - return -1; - case GPG_ERR_NOT_SUPPORTED: - errno = ENOSYS; - return -1; - default: - /* FIXME: Yeah, well. */ - errno = EINVAL; - return -1; - } + switch (gpg_err_code (err)) + { + case GPG_ERR_EOF: + res = 0; + break; + case GPG_ERR_INV_VALUE: + res = EINVAL; + break; + case GPG_ERR_NOT_SUPPORTED: + res = ENOSYS; + break; + default: + /* FIXME: Yeah, well. */ + 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, - buffer, size, &amt); + 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,12 +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) - return EINVAL; + { + errno = EINVAL; + 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); } @@ -187,23 +210,33 @@ static struct _gpgme_data_cbs old_user_c /* 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); + 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); + + err = _gpgme_data_new (r_dh, &old_user_cbs); + if (err) - return err; + return TRACE_ERR (err); - (*dh)->data.old_user.cb = read_cb; - (*dh)->data.old_user.handle = read_cb_value; - return 0; + (*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); } diff -urpNP gpgme-1.1.5/gpgme/data-mem.c gpgme-1.1.6/gpgme/data-mem.c --- gpgme-1.1.5/gpgme/data-mem.c 2007-02-03 15:39:48.000000000 +0000 +++ gpgme-1.1.6/gpgme/data-mem.c 2007-10-04 11:06:48.000000000 +0000 @@ -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); + gpgme_error_t err; + TRACE_BEG (DEBUG_DATA, "gpgme_data_new", r_dh); + + err = _gpgme_data_new (r_dh, &mem_cbs); + if (err) - return err; + return TRACE_ERR (err); - return 0; + 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_da { 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_da 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,14 @@ gpgme_data_release_and_get_mem (gpgme_da gpgme_data_release (dh); + if (r_len) + { + TRACE_SUC2 ("buffer=%p, len=%u", str, *r_len); + } + else + { + TRACE_SUC1 ("buffer=%p", str); + } return str; } @@ -245,7 +273,8 @@ gpgme_data_release_and_get_mem (gpgme_da void gpgme_free (void *buffer) { + TRACE (DEBUG_DATA, "gpgme_free", buffer); + if (buffer) free (buffer); } - diff -urpNP gpgme-1.1.5/gpgme/data-user.c gpgme-1.1.6/gpgme/data-user.c --- gpgme-1.1.5/gpgme/data-user.c 2007-02-03 15:39:48.000000000 +0000 +++ gpgme-1.1.6/gpgme/data-user.c 2007-10-04 11:06:46.000000000 +0000 @@ -32,7 +32,10 @@ static ssize_t user_read (gpgme_data_t dh, void *buffer, size_t size) { if (!dh->data.user.cbs->read) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->read) (dh->data.user.handle, buffer, size); } @@ -42,7 +45,10 @@ static ssize_t user_write (gpgme_data_t dh, const void *buffer, size_t size) { if (!dh->data.user.cbs->write) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->write) (dh->data.user.handle, buffer, size); } @@ -52,7 +58,10 @@ static off_t user_seek (gpgme_data_t dh, off_t offset, int whence) { if (!dh->data.user.cbs->seek) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->seek) (dh->data.user.handle, offset, whence); } diff -urpNP gpgme-1.1.5/gpgme/data.c gpgme-1.1.6/gpgme/data.c --- gpgme-1.1.5/gpgme/data.c 2007-02-03 15:39:48.000000000 +0000 +++ gpgme-1.1.6/gpgme/data.c 2007-10-04 11:06:47.000000000 +0000 @@ -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 * 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 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 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 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_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 d { 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) - return NULL; + { + 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 *opaqu 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 *opaqu 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 *opaq { 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 *opaq 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); } diff -urpNP gpgme-1.1.5/gpgme/debug.c gpgme-1.1.6/gpgme/debug.c --- gpgme-1.1.5/gpgme/debug.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/debug.c 2007-10-04 11:06:46.000000000 +0000 @@ -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. @@ -16,8 +16,8 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. */ #if HAVE_CONFIG_H #include @@ -28,15 +28,21 @@ #include #include #include +#include #ifndef HAVE_DOSISH_SYSTEM - #include - #include - #include +# include +# include +# include #endif #include +#ifdef HAVE_ASSUAN_H +#include "assuan.h" +#endif + #include "util.h" #include "sema.h" +#include "debug.h" /* Lock to serialize initialization of the debug output subsystem and @@ -136,17 +142,38 @@ debug_init (void) } if (debug_level > 0) - fprintf (errfp, "gpgme_debug: level=%d\n", debug_level); + fprintf (errfp, "gpgme_debug: level=%d\n", debug_level); +#ifdef HAVE_ASSUAN_H + assuan_set_assuan_log_prefix ("gpgme-assuan"); + assuan_set_assuan_log_stream (errfp); + assuan_set_assuan_log_level (debug_level >= 0? debug_level:0); +#endif /* HAVE_ASSUAN_H*/ } UNLOCK (debug_lock); } + + +/* This should be called as soon as the locks are intialized. It is + required so that the assuan logging gets conncted to the gpgme log + stream as early as possible. */ +void +_gpgme_debug_subsystem_init (void) +{ + debug_init (); +} + + + /* Log the formatted string FORMAT at debug level LEVEL or higher. */ 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 +187,8 @@ _gpgme_debug (int level, const char *for putc ('\n', errfp); UNLOCK (debug_lock); fflush (errfp); + + errno = saved_errno; } @@ -219,3 +248,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); + } +} diff -urpNP gpgme-1.1.5/gpgme/debug.h gpgme-1.1.6/gpgme/debug.h --- gpgme-1.1.5/gpgme/debug.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/debug.h 2007-10-04 11:06:46.000000000 +0000 @@ -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 +/* 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) @@ -35,6 +50,9 @@ _gpgme_debug_srcname (const char *file) return s? s+1:file; } +/* Called early to initialize the logging. */ +void _gpgme_debug_subsystem_init (void); + /* Log the formatted string FORMAT at debug level LEVEL or higher. */ void _gpgme_debug (int level, const char *format, ...); @@ -49,80 +67,160 @@ void _gpgme_debug_add (void **helper, co stream. */ void _gpgme_debug_end (void **helper); -/* Indirect stringification, requires __STDC__ to work. */ -#define STRINGIFY(v) #v -#define XSTRINGIFY(v) STRINGIFY(v) - -#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) \ - _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) \ +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); + + +/* 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_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 */ diff -urpNP gpgme-1.1.5/gpgme/engine-backend.h gpgme-1.1.6/gpgme/engine-backend.h --- gpgme-1.1.5/gpgme/engine-backend.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/engine-backend.h 2008-01-04 14:17:15.000000000 +0000 @@ -94,7 +94,12 @@ struct engine_ops gpgme_error_t (*verify) (void *engine, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext); - + gpgme_error_t (*getauditlog) (void *engine, gpgme_data_t output, + unsigned int flags); + + gpgme_error_t (*conf_load) (void *engine, gpgme_conf_comp_t *conf_p); + gpgme_error_t (*conf_save) (void *engine, gpgme_conf_comp_t conf); + void (*set_io_cbs) (void *engine, gpgme_io_cbs_t io_cbs); void (*io_event) (void *engine, gpgme_event_io_t type, void *type_data); @@ -106,5 +111,8 @@ extern struct engine_ops _gpgme_engine_o #ifdef ENABLE_GPGSM extern struct engine_ops _gpgme_engine_ops_gpgsm; /* CMS. */ #endif +#ifdef ENABLE_GPGCONF +extern struct engine_ops _gpgme_engine_ops_gpgconf; /* gpg-conf. */ +#endif #endif /* ENGINE_BACKEND_H */ diff -urpNP gpgme-1.1.5/gpgme/engine-gpgconf.c gpgme-1.1.6/gpgme/engine-gpgconf.c --- gpgme-1.1.5/gpgme/engine-gpgconf.c 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/engine-gpgconf.c 2008-01-04 14:17:15.000000000 +0000 @@ -0,0 +1,877 @@ +// Check protocol. +// IMPLEMENT NO_ARG_DESC!!!! + +/* engine-gpgconf.c - gpg-conf engine. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include /* FIXME */ +#include + +#include "gpgme.h" +#include "util.h" +#include "ops.h" +#include "wait.h" +#include "priv-io.h" +#include "sema.h" + +#include "assuan.h" +#include "debug.h" + +#include "engine-backend.h" + + +struct engine_gpgconf +{ + char *file_name; + char *home_dir; +}; + +typedef struct engine_gpgconf *engine_gpgconf_t; + + +static char * +gpgconf_get_version (const char *file_name) +{ + return _gpgme_get_program_version (file_name ? file_name + : _gpgme_get_gpgconf_path ()); +} + + +static const char * +gpgconf_get_req_version (void) +{ + return NEED_GPGCONF_VERSION; +} + + +static void +gpgconf_release (void *engine) +{ + engine_gpgconf_t gpgconf = engine; + + if (!gpgconf) + return; + + if (gpgconf->file_name) + free (gpgconf->file_name); + if (gpgconf->home_dir) + free (gpgconf->home_dir); + + free (gpgconf); +} + + +static gpgme_error_t +gpgconf_new (void **engine, const char *file_name, const char *home_dir) +{ + gpgme_error_t err = 0; + engine_gpgconf_t gpgconf; + + gpgconf = calloc (1, sizeof *gpgconf); + if (!gpgconf) + return gpg_error_from_errno (errno); + + gpgconf->file_name = strdup (file_name ? file_name + : _gpgme_get_gpgconf_path ()); + if (!gpgconf->file_name) + err = gpg_error_from_syserror (); + + if (!err && home_dir) + { + gpgconf->home_dir = strdup (home_dir); + if (!gpgconf->home_dir) + err = gpg_error_from_syserror (); + } + + if (err) + gpgconf_release (gpgconf); + else + *engine = gpgconf; + + return err; +} + + +static void +release_arg (gpgme_conf_arg_t arg, gpgme_conf_type_t alt_type) +{ + while (arg) + { + gpgme_conf_arg_t next = arg->next; + + if (alt_type == GPGME_CONF_STRING) + free (arg->value.string); + free (arg); + arg = next; + } +} + + +static void +release_opt (gpgme_conf_opt_t opt) +{ + if (opt->name) + free (opt->name); + if (opt->description) + free (opt->description); + if (opt->argname) + free (opt->argname); + + release_arg (opt->default_value, opt->alt_type); + if (opt->default_description) + free (opt->default_description); + + release_arg (opt->no_arg_value, opt->alt_type); + release_arg (opt->value, opt->alt_type); + release_arg (opt->new_value, opt->alt_type); + + free (opt); +} + + +static void +release_comp (gpgme_conf_comp_t comp) +{ + gpgme_conf_opt_t opt; + + if (comp->name) + free (comp->name); + if (comp->description) + free (comp->description); + if (comp->program_name) + free (comp->program_name); + + opt = comp->options; + while (opt) + { + gpgme_conf_opt_t next = opt->next; + release_opt (opt); + opt = next; + } + + free (comp); +} + + +static void +gpgconf_config_release (gpgme_conf_comp_t conf) +{ + while (conf) + { + gpgme_conf_comp_t next = conf->next; + release_comp (conf); + conf = next; + } +} + + +static gpgme_error_t +gpgconf_read (void *engine, char *arg1, char *arg2, + gpgme_error_t (*cb) (void *hook, char *line), + void *hook) +{ + struct engine_gpgconf *gpgconf = engine; + gpgme_error_t err = 0; +#define LINELENGTH 1024 + char line[LINELENGTH] = ""; + int linelen = 0; + char *argv[] = { NULL /* file_name */, arg1, arg2, 0 }; + int rp[2]; + struct spawn_fd_item_s pfd[] = { {0, -1}, {-1, -1} }; + struct spawn_fd_item_s cfd[] = { {-1, 1 /* STDOUT_FILENO */}, {-1, -1} }; + int status; + int nread; + char *mark = NULL; + + /* FIXME: Deal with engine->home_dir. */ + + /* _gpgme_engine_new guarantees that this is not NULL. */ + argv[0] = gpgconf->file_name; + + if (_gpgme_io_pipe (rp, 1) < 0) + return gpg_error_from_syserror (); + + pfd[0].fd = rp[1]; + cfd[0].fd = rp[1]; + + status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd); + if (status < 0) + { + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + return gpg_error_from_syserror (); + } + + do + { + nread = _gpgme_io_read (rp[0], &line[linelen], LINELENGTH - linelen - 1); + if (nread > 0) + { + line[linelen + nread] = '\0'; + linelen += nread; + + while ((mark = strchr (line, '\n'))) + { + char *eol = mark; + + if (eol > &line[0] && *eol == '\r') + eol--; + *eol = '\0'; + + /* Got a full line. */ + err = (*cb) (hook, line); + if (err) + break; + + linelen -= mark - line; + memmove (line, eol + 1, linelen); + } + } + } + while (nread > 0 && linelen < LINELENGTH - 1); + + if (!err && nread < 0) + err = gpg_error_from_syserror (); + if (!err && nread > 0) + err = gpg_error (GPG_ERR_LINE_TOO_LONG); + + _gpgme_io_close (rp[0]); + + return err; +} + + +static gpgme_error_t +gpgconf_config_load_cb (void *hook, char *line) +{ + gpgme_conf_comp_t *comp_p = hook; + gpgme_conf_comp_t comp = *comp_p; +#define NR_FIELDS 16 + char *field[NR_FIELDS]; + int fields = 0; + + while (line && fields < NR_FIELDS) + { + field[fields++] = line; + line = strchr (line, ':'); + if (line) + *(line++) = '\0'; + } + + /* We require at least the first 3 fields. */ + if (fields < 2) + return gpg_error (GPG_ERR_INV_ENGINE); + + /* Find the pointer to the new component in the list. */ + while (comp && comp->next) + comp = comp->next; + if (comp) + comp_p = &comp->next; + + comp = calloc (1, sizeof (*comp)); + if (!comp) + return gpg_error_from_syserror (); + /* Prepare return value. */ + comp->_last_opt_p = &comp->options; + *comp_p = comp; + + comp->name = strdup (field[0]); + if (!comp->name) + return gpg_error_from_syserror (); + + comp->description = strdup (field[1]); + if (!comp->description) + return gpg_error_from_syserror (); + + if (fields >= 3) + { + comp->description = strdup (field[2]); + if (!comp->description) + return gpg_error_from_syserror (); + } + + return 0; +} + + +static gpgme_error_t +gpgconf_parse_option (gpgme_conf_opt_t opt, + gpgme_conf_arg_t *arg_p, char *line) +{ + gpgme_error_t err; + char *mark; + + if (!line[0]) + return 0; + + mark = strchr (line, ','); + if (mark) + *mark = '\0'; + + while (line) + { + gpgme_conf_arg_t arg = calloc (1, sizeof (*arg)); + if (!arg) + return gpg_error_from_syserror (); + *arg_p = arg; + arg_p = &arg->next; + + if (*line == '\0') + arg->no_arg = 1; + else + { + switch (opt->alt_type) + { + /* arg->value.count is an alias for arg->value.uint32. */ + case GPGME_CONF_NONE: + case GPGME_CONF_UINT32: + arg->value.uint32 = strtoul (line, NULL, 0); + break; + + case GPGME_CONF_INT32: + arg->value.uint32 = strtol (line, NULL, 0); + break; + + case GPGME_CONF_STRING: + case GPGME_CONF_PATHNAME: + case GPGME_CONF_LDAP_SERVER: + /* Skip quote character. */ + line++; + + err = _gpgme_decode_percent_string (line, &arg->value.string, + 0, 0); + if (err) + return err; + break; + } + } + + /* Find beginning of next value. */ + if (mark++ && *mark) + line = mark; + else + line = NULL; + } + + return 0; +} + + +static gpgme_error_t +gpgconf_config_load_cb2 (void *hook, char *line) +{ + gpgme_error_t err; + gpgme_conf_comp_t comp = hook; + gpgme_conf_opt_t *opt_p = comp->_last_opt_p; + gpgme_conf_opt_t opt; +#define NR_FIELDS 16 + char *field[NR_FIELDS]; + int fields = 0; + + while (line && fields < NR_FIELDS) + { + field[fields++] = line; + line = strchr (line, ':'); + if (line) + *(line++) = '\0'; + } + + /* We require at least the first 10 fields. */ + if (fields < 10) + return gpg_error (GPG_ERR_INV_ENGINE); + + opt = calloc (1, sizeof (*opt)); + if (!opt) + return gpg_error_from_syserror (); + + comp->_last_opt_p = &opt->next; + *opt_p = opt; + + if (field[0][0]) + { + opt->name = strdup (field[0]); + if (!opt->name) + return gpg_error_from_syserror (); + } + + opt->flags = strtoul (field[1], NULL, 0); + + opt->level = strtoul (field[2], NULL, 0); + + if (field[3][0]) + { + opt->description = strdup (field[3]); + if (!opt->description) + return gpg_error_from_syserror (); + } + + opt->type = strtoul (field[4], NULL, 0); + + opt->alt_type = strtoul (field[5], NULL, 0); + + if (field[6][0]) + { + opt->argname = strdup (field[6]); + if (!opt->argname) + return gpg_error_from_syserror (); + } + + if (opt->flags & GPGME_CONF_DEFAULT) + { + err = gpgconf_parse_option (opt, &opt->default_value, field[7]); + if (err) + return err; + } + else if ((opt->flags & GPGME_CONF_DEFAULT_DESC) && field[7][0]) + { + opt->default_description = strdup (field[7]); + if (!opt->default_description) + return gpg_error_from_syserror (); + } + + err = gpgconf_parse_option (opt, &opt->no_arg_value, field[8]); + if (err) + return err; + + err = gpgconf_parse_option (opt, &opt->value, field[9]); + if (err) + return err; + + return 0; +} + + +static gpgme_error_t +gpgconf_conf_load (void *engine, gpgme_conf_comp_t *comp_p) +{ + gpgme_error_t err; + gpgme_conf_comp_t comp = NULL; + gpgme_conf_comp_t cur_comp; + + *comp_p = NULL; + + err = gpgconf_read (engine, "--list-components", NULL, + gpgconf_config_load_cb, &comp); + if (err) + { + gpgconf_release (comp); + return err; + } + + cur_comp = comp; + while (!err && cur_comp) + { + err = gpgconf_read (engine, "--list-options", cur_comp->name, + gpgconf_config_load_cb2, cur_comp); + cur_comp = cur_comp->next; + } + + if (err) + { + gpgconf_release (comp); + return err; + } + + *comp_p = comp; + return 0; +} + + + +gpgme_error_t +_gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, void *value) +{ + gpgme_conf_arg_t arg; + + arg = calloc (1, sizeof (*arg)); + if (!arg) + return gpg_error_from_syserror (); + + if (!value) + arg->no_arg = 1; + else + { + switch (type) + { + case GPGME_CONF_NONE: + case GPGME_CONF_UINT32: + arg->value.uint32 = *((unsigned int *) value); + break; + + case GPGME_CONF_INT32: + arg->value.int32 = *((int *) value); + break; + + case GPGME_CONF_STRING: + case GPGME_CONF_PATHNAME: + case GPGME_CONF_LDAP_SERVER: + arg->value.string = strdup (value); + if (!arg->value.string) + { + free (arg); + return gpg_error_from_syserror (); + } + break; + + default: + free (arg); + return gpg_error (GPG_ERR_INV_VALUE); + } + } + + *arg_p = arg; + return 0; +} + + +void +_gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type) +{ + switch (type) + { + case GPGME_CONF_NONE: + case GPGME_CONF_UINT32: + case GPGME_CONF_INT32: + case GPGME_CONF_STRING: + default: + break; + + case GPGME_CONF_PATHNAME: + case GPGME_CONF_LDAP_SERVER: + type = GPGME_CONF_STRING; + break; + } + + release_arg (arg, type); +} + + +gpgme_error_t +_gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg) +{ + if (opt->new_value) + release_arg (opt->new_value, opt->alt_type); + + if (reset) + { + opt->new_value = NULL; + opt->change_value = 0; + } + else + { + opt->new_value = arg; + opt->change_value = 1; + } + return 0; +} + + +/* FIXME: Major problem: We don't get errors from gpgconf. */ + +static gpgme_error_t +gpgconf_write (void *engine, char *arg1, char *arg2, gpgme_data_t conf) +{ + struct engine_gpgconf *gpgconf = engine; + gpgme_error_t err = 0; +#define BUFLEN 1024 + char buf[BUFLEN]; + int buflen = 0; + char *argv[] = { NULL /* file_name */, arg1, arg2, 0 }; + int rp[2]; + struct spawn_fd_item_s pfd[] = { {1, -1}, {-1, -1} }; + struct spawn_fd_item_s cfd[] = { {-1, 0 /* STDIN_FILENO */}, {-1, -1} }; + int status; + int nwrite; + + /* FIXME: Deal with engine->home_dir. */ + + /* _gpgme_engine_new guarantees that this is not NULL. */ + argv[0] = gpgconf->file_name; + argv[0] = "/home/marcus/g10/install/bin/gpgconf"; + + if (_gpgme_io_pipe (rp, 0) < 0) + return gpg_error_from_syserror (); + + pfd[0].fd = rp[0]; + cfd[0].fd = rp[0]; + + status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd); + if (status < 0) + { + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + return gpg_error_from_syserror (); + } + + for (;;) + { + if (buflen == 0) + { + do + { + buflen = gpgme_data_read (conf, buf, BUFLEN); + } + while (buflen < 0 && errno == EAGAIN); + + if (buflen < 0) + { + err = gpg_error_from_syserror (); + _gpgme_io_close (rp[1]); + return err; + } + else if (buflen == 0) + { + /* All is written. */ + _gpgme_io_close (rp[1]); + return 0; + } + } + + do + { + nwrite = _gpgme_io_write (rp[1], buf, buflen); + } + while (nwrite < 0 && errno == EAGAIN); + + if (nwrite > 0) + { + buflen -= nwrite; + if (buflen > 0) + memmove (&buf[0], &buf[nwrite], buflen); + } + else if (nwrite < 0) + { + _gpgme_io_close (rp[1]); + return gpg_error_from_syserror (); + } + } + + return 0; +} + + +static gpgme_error_t +arg_to_data (gpgme_data_t conf, gpgme_conf_opt_t option, gpgme_conf_arg_t arg) +{ + gpgme_error_t err = 0; + int amt = 0; + char buf[16]; + + while (amt >= 0 && arg) + { + switch (option->alt_type) + { + case GPGME_CONF_NONE: + case GPGME_CONF_UINT32: + default: + snprintf (buf, sizeof (buf), "%u", arg->value.uint32); + buf[sizeof (buf) - 1] = '\0'; + amt = gpgme_data_write (conf, buf, strlen (buf)); + break; + + case GPGME_CONF_INT32: + snprintf (buf, sizeof (buf), "%i", arg->value.uint32); + buf[sizeof (buf) - 1] = '\0'; + amt = gpgme_data_write (conf, buf, strlen (buf)); + break; + + case GPGME_CONF_STRING: + case GPGME_CONF_PATHNAME: + case GPGME_CONF_LDAP_SERVER: + /* One quote character, and three times to allow + for percent escaping. */ + { + char *ptr = arg->value.string; + amt = gpgme_data_write (conf, "\"", 1); + if (amt < 0) + break; + + while (!err && *ptr) + { + switch (*ptr) + { + case '%': + amt = gpgme_data_write (conf, "%25", 3); + break; + + case ':': + amt = gpgme_data_write (conf, "%3a", 3); + break; + + case ',': + amt = gpgme_data_write (conf, "%2c", 3); + break; + + default: + amt = gpgme_data_write (conf, ptr, 1); + } + ptr++; + } + } + break; + } + + if (amt < 0) + break; + + arg = arg->next; + /* Comma separator. */ + if (arg) + amt = gpgme_data_write (conf, ",", 1); + } + + if (amt < 0) + return gpg_error_from_syserror (); + + return 0; +} + + +static gpgme_error_t +gpgconf_conf_save (void *engine, gpgme_conf_comp_t comp) +{ + gpgme_error_t err; + int amt = 0; + /* We use a data object to store the new configuration. */ + gpgme_data_t conf; + gpgme_conf_opt_t option; + int something_changed = 0; + + err = gpgme_data_new (&conf); + if (err) + return err; + + option = comp->options; + while (!err && amt >= 0 && option) + { + if (option->change_value) + { + unsigned int flags = 0; + char buf[16]; + + something_changed = 1; + + amt = gpgme_data_write (conf, option->name, strlen (option->name)); + if (amt >= 0) + amt = gpgme_data_write (conf, ":", 1); + if (amt < 0) + break; + + if (!option->new_value) + flags |= GPGME_CONF_DEFAULT; + snprintf (buf, sizeof (buf), "%u", flags); + buf[sizeof (buf) - 1] = '\0'; + + amt = gpgme_data_write (conf, buf, strlen (buf)); + if (amt >= 0) + amt = gpgme_data_write (conf, ":", 1); + if (amt < 0) + break; + + if (option->new_value) + { + err = arg_to_data (conf, option, option->new_value); + if (err) + break; + } + amt = gpgme_data_write (conf, "\n", 1); + } + option = option->next; + } + if (!err && amt < 0) + err = gpg_error_from_syserror (); + if (err || !something_changed) + goto bail; + + err = gpgme_data_seek (conf, 0, SEEK_SET); + if (err) + goto bail; + + err = gpgconf_write (engine, "--change-options", comp->name, conf); + bail: + gpgme_data_release (conf); + return err; +} + + +static void +gpgconf_set_io_cbs (void *engine, gpgme_io_cbs_t io_cbs) +{ + /* Nothing to do. */ +} + + +/* Currently, we do not use the engine interface for the various + operations. */ +void +_gpgme_conf_release (gpgme_conf_comp_t conf) +{ + gpgconf_config_release (conf); +} + + +struct engine_ops _gpgme_engine_ops_gpgconf = + { + /* Static functions. */ + _gpgme_get_gpgconf_path, + gpgconf_get_version, + gpgconf_get_req_version, + gpgconf_new, + + /* Member functions. */ + gpgconf_release, + NULL, /* reset */ + NULL, /* set_status_handler */ + NULL, /* set_command_handler */ + NULL, /* set_colon_line_handler */ + NULL, /* set_locale */ + NULL, /* decrypt */ + NULL, /* delete */ + NULL, /* edit */ + NULL, /* encrypt */ + NULL, /* encrypt_sign */ + NULL, /* export */ + NULL, /* export_ext */ + NULL, /* genkey */ + NULL, /* import */ + NULL, /* keylist */ + NULL, /* keylist_ext */ + NULL, /* sign */ + NULL, /* trustlist */ + NULL, /* verify */ + NULL, /* getauditlog */ + gpgconf_conf_load, + gpgconf_conf_save, + gpgconf_set_io_cbs, + NULL, /* io_event */ + NULL /* cancel */ + }; diff -urpNP gpgme-1.1.5/gpgme/engine-gpgsm.c gpgme-1.1.6/gpgme/engine-gpgsm.c --- gpgme-1.1.5/gpgme/engine-gpgsm.c 2007-07-08 15:46:47.000000000 +0000 +++ gpgme-1.1.6/gpgme/engine-gpgsm.c 2008-01-04 14:17:15.000000000 +0000 @@ -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. @@ -49,10 +49,13 @@ typedef struct { int fd; /* FD we talk about. */ - int server_fd; /* Server FD for this connection. */ + int server_fd;/* Server FD for this connection. */ int dir; /* Inbound/Outbound, maybe given implicit? */ void *data; /* Handler-specific data. */ void *tag; /* ID from the user for gpgme_remove_io_callback. */ + char server_fd_str[15]; /* Same as SERVER_FD but as a string. We + need this because _gpgme_io_fd2str can't + be used on a closed descriptor. */ } iocb_data_t; @@ -91,11 +94,18 @@ struct engine_gpgsm int any; /* any data line seen */ } colon; + gpgme_data_t inline_data; /* Used to collect D lines. */ + struct gpgme_io_cbs io_cbs; }; typedef struct engine_gpgsm *engine_gpgsm_t; + +static void gpgsm_io_event (void *engine, + gpgme_event_io_t type, void *type_data); + + static char * gpgsm_get_version (const char *file_name) @@ -346,14 +356,17 @@ gpgsm_new (void **engine, const char *fi gpgsm->input_cb.dir = 0; gpgsm->input_cb.tag = 0; gpgsm->input_cb.server_fd = -1; + *gpgsm->input_cb.server_fd_str = 0; gpgsm->output_cb.fd = -1; gpgsm->output_cb.dir = 1; gpgsm->output_cb.tag = 0; gpgsm->output_cb.server_fd = -1; + *gpgsm->output_cb.server_fd_str = 0; gpgsm->message_cb.fd = -1; gpgsm->message_cb.dir = 0; gpgsm->message_cb.tag = 0; gpgsm->message_cb.server_fd = -1; + *gpgsm->message_cb.server_fd_str = 0; gpgsm->status.fnc = 0; gpgsm->colon.fnc = 0; @@ -362,6 +375,8 @@ gpgsm_new (void **engine, const char *fi gpgsm->colon.attic.linelen = 0; gpgsm->colon.any = 0; + gpgsm->inline_data = NULL; + gpgsm->io_cbs.add = NULL; gpgsm->io_cbs.add_priv = NULL; gpgsm->io_cbs.remove = NULL; @@ -376,6 +391,9 @@ gpgsm_new (void **engine, const char *fi } gpgsm->input_cb.fd = fds[1]; gpgsm->input_cb.server_fd = fds[0]; + _gpgme_io_fd2str (gpgsm->input_cb.server_fd_str, + sizeof gpgsm->input_cb.server_fd_str, + gpgsm->input_cb.server_fd); if (_gpgme_io_pipe (fds, 1) < 0) { @@ -384,6 +402,9 @@ gpgsm_new (void **engine, const char *fi } gpgsm->output_cb.fd = fds[0]; gpgsm->output_cb.server_fd = fds[1]; + _gpgme_io_fd2str (gpgsm->output_cb.server_fd_str, + sizeof gpgsm->output_cb.server_fd_str, + gpgsm->output_cb.server_fd); if (_gpgme_io_pipe (fds, 0) < 0) { @@ -392,6 +413,9 @@ gpgsm_new (void **engine, const char *fi } gpgsm->message_cb.fd = fds[1]; gpgsm->message_cb.server_fd = fds[0]; + _gpgme_io_fd2str (gpgsm->message_cb.server_fd_str, + sizeof gpgsm->message_cb.server_fd_str, + gpgsm->message_cb.server_fd); child_fds[0] = gpgsm->input_cb.server_fd; child_fds[1] = gpgsm->output_cb.server_fd; @@ -495,6 +519,15 @@ gpgsm_new (void **engine, const char *fi } } + /* Ask gpgsm to enable the audit log support. */ + if (!err) + { + err = assuan_transact (gpgsm->assuan_ctx, "OPTION enable-audit-log=1", + NULL, NULL, NULL, NULL, NULL, NULL); + if (gpg_err_code (err) == GPG_ERR_UNKNOWN_OPTION) + err = 0; /* This is an optional feature of gpgsm. */ + } + #if !USE_DESCRIPTOR_PASSING if (!err && (_gpgme_io_set_close_notify (gpgsm->input_cb.fd, @@ -510,8 +543,9 @@ gpgsm_new (void **engine, const char *fi #endif leave: - /* Close the server ends of the pipes. Our ends are closed in - gpgsm_release(). */ + /* Close the server ends of the pipes (because of this, we must use + the stored server_fd_str in the function start). Our ends are + closed in gpgsm_release(). */ #if !USE_DESCRIPTOR_PASSING if (gpgsm->input_cb.server_fd != -1) _gpgme_io_close (gpgsm->input_cb.server_fd); @@ -667,7 +701,6 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_t char *which; iocb_data_t *iocb_data; int dir; - int fd; switch (fd_type) { @@ -713,16 +746,13 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_t goto leave_set_fd; } } -#endif - fd = iocb_data->server_fd; - -#if USE_DESCRIPTOR_PASSING - err = assuan_sendfd (gpgsm->assuan_ctx, fd); + err = assuan_sendfd (gpgsm->assuan_ctx, iocb_data->server_fd); if (err) goto leave_set_fd; - _gpgme_io_close (fd); + _gpgme_io_close (iocb_data->server_fd); + iocb_data->server_fd = -1; if (opt) snprintf (line, COMMANDLINELEN, "%s FD %s", which, opt); @@ -730,9 +760,11 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_t snprintf (line, COMMANDLINELEN, "%s FD", which); #else if (opt) - snprintf (line, COMMANDLINELEN, "%s FD=%i %s", which, fd, opt); + snprintf (line, COMMANDLINELEN, "%s FD=%s %s", + which, iocb_data->server_fd_str, opt); else - snprintf (line, COMMANDLINELEN, "%s FD=%i", which, fd); + snprintf (line, COMMANDLINELEN, "%s FD=%s", + which, iocb_data->server_fd_str); #endif err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL); @@ -742,9 +774,12 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_t if (err) { _gpgme_io_close (iocb_data->fd); - _gpgme_io_close (iocb_data->server_fd); iocb_data->fd = -1; - iocb_data->server_fd = -1; + if (iocb_data->server_fd != -1) + { + _gpgme_io_close (iocb_data->server_fd); + iocb_data->server_fd = -1; + } } #endif @@ -810,7 +845,8 @@ status_handler (void *opaque, int fd) /* Try our best to terminate the connection friendly. */ /* 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 @@ -821,8 +857,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", - fd, err? gpg_strerror (err):"ok"); + TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm, + "fd 0x%x: ERR line - mapped to: %s", + fd, err ? gpg_strerror (err) : "ok"); + /* Try our best to terminate the connection friendly. */ + // assuan_write_line (gpgsm->assuan_ctx, "BYE"); } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' @@ -842,9 +881,10 @@ status_handler (void *opaque, int fd) gpgsm->colon.any = 0; err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); } + TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm, + "fd 0x%x: OK line - final status: %s", + fd, err ? gpg_strerror (err) : "ok"); _gpgme_io_close (gpgsm->status_cb.fd); - DEBUG2 ("fd %d: OK line - final status: %s\n", - fd, err? gpg_strerror (err):"ok"); return err; } else if (linelen > 2 @@ -863,8 +903,7 @@ status_handler (void *opaque, int fd) char **aline = &gpgsm->colon.attic.line; int *alinelen = &gpgsm->colon.attic.linelen; - if (gpgsm->colon.attic.linesize - < *alinelen + linelen + 1) + if (gpgsm->colon.attic.linesize < *alinelen + linelen + 1) { char *newline = realloc (*aline, *alinelen + linelen + 1); if (!newline) @@ -917,7 +956,51 @@ 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 + && line[0] == 'D' && line[1] == ' ' + && gpgsm->inline_data) + { + char *src = line + 2; + char *end = line + linelen; + char *dst = src; + ssize_t nwritten; + + linelen = 0; + while (src < end) + { + if (*src == '%' && src + 2 < end) + { + /* Handle escaped characters. */ + ++src; + *dst++ = _gpgme_hextobyte (src); + src += 2; + } + else + *dst++ = *src++; + + linelen++; + } + + src = line + 2; + while (linelen > 0) + { + nwritten = gpgme_data_write (gpgsm->inline_data, src, linelen); + if (!nwritten || (nwritten < 0 && errno != EINTR) + || nwritten > linelen) + { + err = gpg_error_from_errno (errno); + break; + } + src += nwritten; + linelen -= nwritten; + } + + TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm, + "fd 0x%x: D inlinedata; final status: %s", fd, err? gpg_strerror (err):"ok"); } else if (linelen > 2 @@ -941,7 +1024,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"); } } @@ -956,15 +1040,17 @@ add_io_cb (engine_gpgsm_t gpgsm, iocb_da { gpgme_error_t err; + TRACE_BEG2 (DEBUG_ENGINE, "engine-gpgsm:add_io_cb", gpgsm, + "fd %d, dir %d", iocbd->fd, iocbd->dir); err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, iocbd->fd, iocbd->dir, handler, iocbd->data, &iocbd->tag); if (err) - return err; + return TRACE_ERR (err); if (!iocbd->dir) /* FIXME Kludge around poll() problem. */ err = _gpgme_io_set_nonblocking (iocbd->fd); - return err; + return TRACE_ERR (err); } @@ -983,19 +1069,24 @@ start (engine_gpgsm_t gpgsm, const char if (nfds < 1) return gpg_error (GPG_ERR_GENERAL); /* FIXME */ - /* We duplicate the file descriptor, so we can close it without - disturbing assuan. Alternatively, we could special case - status_fd and register/unregister it manually as needed, but this - increases code duplication and is more complicated as we can not - use the close notifications etc. */ - gpgsm->status_cb.fd = dup (fdlist[0]); + /* We "duplicate" the file descriptor, so we can close it here (we + can't close fdlist[0], as that is closed by libassuan, and + closing it here might cause libassuan to close some unrelated FD + later). Alternatively, we could special case status_fd and + register/unregister it manually as needed, but this increases + code duplication and is more complicated as we can not use the + close notifications etc. A third alternative would be to let + Assuan know that we closed the FD, but that complicates the + Assuan interface. */ + + gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]); if (gpgsm->status_cb.fd < 0) return gpg_error_from_syserror (); if (_gpgme_io_set_close_notify (gpgsm->status_cb.fd, close_notify_handler, gpgsm)) { - close (gpgsm->status_cb.fd); + _gpgme_io_close (gpgsm->status_cb.fd); gpgsm->status_cb.fd = -1; return gpg_error (GPG_ERR_GENERAL); } @@ -1012,7 +1103,7 @@ start (engine_gpgsm_t gpgsm, const char err = map_assuan_error (assuan_write_line (gpgsm->assuan_ctx, command)); if (!err) - (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, GPGME_EVENT_START, NULL); + gpgsm_io_event (gpgsm, GPGME_EVENT_START, NULL); return err; } @@ -1049,6 +1140,7 @@ gpgsm_decrypt (void *engine, gpgme_data_ if (err) return gpg_error (GPG_ERR_GENERAL); /* FIXME */ gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (engine, "DECRYPT"); return err; @@ -1114,6 +1206,7 @@ gpgsm_delete (void *engine, gpgme_key_t gpgsm_clear_fd (gpgsm, OUTPUT_FD); gpgsm_clear_fd (gpgsm, INPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, line); free (line); @@ -1203,6 +1296,7 @@ gpgsm_encrypt (void *engine, gpgme_key_t if (err) return err; gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = set_recipients (gpgsm, recp); @@ -1239,6 +1333,7 @@ gpgsm_export (void *engine, const char * return err; gpgsm_clear_fd (gpgsm, INPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, cmd); free (cmd); @@ -1330,6 +1425,7 @@ gpgsm_export_ext (void *engine, const ch return err; gpgsm_clear_fd (gpgsm, INPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, line); free (line); @@ -1356,6 +1452,7 @@ gpgsm_genkey (void *engine, gpgme_data_t if (err) return err; gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, "GENKEY"); return err; @@ -1377,6 +1474,7 @@ gpgsm_import (void *engine, gpgme_data_t return err; gpgsm_clear_fd (gpgsm, OUTPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, "IMPORT"); return err; @@ -1438,6 +1536,7 @@ gpgsm_keylist (void *engine, const char gpgsm_clear_fd (gpgsm, INPUT_FD); gpgsm_clear_fd (gpgsm, OUTPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, line); free (line); @@ -1560,6 +1659,7 @@ gpgsm_keylist_ext (void *engine, const c gpgsm_clear_fd (gpgsm, INPUT_FD); gpgsm_clear_fd (gpgsm, OUTPUT_FD); gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, line); free (line); @@ -1625,6 +1725,7 @@ gpgsm_sign (void *engine, gpgme_data_t i if (err) return err; gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; err = start (gpgsm, mode == GPGME_SIG_MODE_DETACH ? "SIGN --detached" : "SIGN"); @@ -1660,6 +1761,7 @@ gpgsm_verify (void *engine, gpgme_data_t err = gpgsm_set_fd (gpgsm, MESSAGE_FD, 0); gpgsm_clear_fd (gpgsm, OUTPUT_FD); } + gpgsm->inline_data = NULL; if (!err) err = start (gpgsm, "VERIFY"); @@ -1668,6 +1770,42 @@ gpgsm_verify (void *engine, gpgme_data_t } +/* Send the GETAUDITLOG command. The result is saved to a gpgme data + object. */ +static gpgme_error_t +gpgsm_getauditlog (void *engine, gpgme_data_t output, unsigned int flags) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err = 0; + + if (!gpgsm || !output) + return gpg_error (GPG_ERR_INV_VALUE); + +#if USE_DESCRIPTOR_PASSING + gpgsm->output_cb.data = output; + err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0); + if (err) + return err; + + gpgsm_clear_fd (gpgsm, INPUT_FD); + gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = NULL; +# define CMD "GETAUDITLOG" +#else + gpgsm_clear_fd (gpgsm, OUTPUT_FD); + gpgsm_clear_fd (gpgsm, INPUT_FD); + gpgsm_clear_fd (gpgsm, MESSAGE_FD); + gpgsm->inline_data = output; +# define CMD "GETAUDITLOG --data" +#endif + + err = start (gpgsm, (flags & GPGME_AUDITLOG_HTML)? CMD " --html" : CMD); + + return err; +} + + + static void gpgsm_set_status_handler (void *engine, engine_status_handler_t fnc, void *fnc_value) @@ -1705,6 +1843,9 @@ gpgsm_io_event (void *engine, gpgme_even { engine_gpgsm_t gpgsm = engine; + TRACE3 (DEBUG_ENGINE, "gpgme:gpgsm_io_event", gpgsm, + "event %p, type %d, type_data %p", + gpgsm->io_cbs.event, type, type_data); if (gpgsm->io_cbs.event) (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, type, type_data); } @@ -1743,6 +1884,9 @@ struct engine_ops _gpgme_engine_ops_gpgs gpgsm_sign, NULL, /* trustlist */ gpgsm_verify, + gpgsm_getauditlog, + NULL, /* conf_load */ + NULL, /* conf_save */ gpgsm_set_io_cbs, gpgsm_io_event, gpgsm_cancel diff -urpNP gpgme-1.1.5/gpgme/engine.c gpgme-1.1.6/gpgme/engine.c --- gpgme-1.1.5/gpgme/engine.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/engine.c 2008-01-04 14:17:15.000000000 +0000 @@ -47,7 +47,12 @@ static struct engine_ops *engine_ops[] = { &_gpgme_engine_ops_gpg, /* OpenPGP. */ #ifdef ENABLE_GPGSM - &_gpgme_engine_ops_gpgsm /* CMS. */ + &_gpgme_engine_ops_gpgsm, /* CMS. */ +#else + NULL, +#endif +#ifdef ENABLE_GPGCONF + &_gpgme_engine_ops_gpgconf /* gpg-conf. */ #else NULL #endif @@ -169,7 +174,8 @@ gpgme_get_engine_info (gpgme_engine_info { gpgme_engine_info_t *lastp = &engine_info; gpgme_protocol_t proto_list[] = { GPGME_PROTOCOL_OpenPGP, - GPGME_PROTOCOL_CMS }; + GPGME_PROTOCOL_CMS, + GPGME_PROTOCOL_GPGCONF }; unsigned int proto; for (proto = 0; proto < DIM (proto_list); proto++) @@ -710,6 +716,46 @@ _gpgme_engine_op_verify (engine_t engine } +gpgme_error_t +_gpgme_engine_op_getauditlog (engine_t engine, gpgme_data_t output, + unsigned int flags) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->getauditlog) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->getauditlog) (engine->engine, output, flags); +} + + +gpgme_error_t +_gpgme_engine_op_conf_load (engine_t engine, gpgme_conf_comp_t *conf_p) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->conf_load) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->conf_load) (engine->engine, conf_p); +} + + +gpgme_error_t +_gpgme_engine_op_conf_save (engine_t engine, gpgme_conf_comp_t conf) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->conf_save) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->conf_save) (engine->engine, conf); +} + + void _gpgme_engine_set_io_cbs (engine_t engine, gpgme_io_cbs_t io_cbs) { diff -urpNP gpgme-1.1.5/gpgme/engine.h gpgme-1.1.6/gpgme/engine.h --- gpgme-1.1.5/gpgme/engine.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/engine.h 2008-01-04 14:17:15.000000000 +0000 @@ -123,6 +123,15 @@ gpgme_error_t _gpgme_engine_op_verify (e gpgme_data_t signed_text, gpgme_data_t plaintext); +gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine, + gpgme_data_t output, + unsigned int flags); + +gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine, + gpgme_conf_comp_t *conf_p); +gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine, + gpgme_conf_comp_t conf); + void _gpgme_engine_set_io_cbs (engine_t engine, gpgme_io_cbs_t io_cbs); void _gpgme_engine_io_event (engine_t engine, diff -urpNP gpgme-1.1.5/gpgme/getauditlog.c gpgme-1.1.6/gpgme/getauditlog.c --- gpgme-1.1.5/gpgme/getauditlog.c 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/getauditlog.c 2007-11-23 15:24:05.000000000 +0000 @@ -0,0 +1,81 @@ +/* getauditlog.c - Retrieve the audit log. + Copyright (C) 2007 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, see . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +static gpgme_error_t +getauditlog_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + return 0; +} + + +static gpgme_error_t +getauditlog_start (gpgme_ctx_t ctx, int synchronous, + gpgme_data_t output, unsigned int flags) +{ + gpgme_error_t err; + + if (!output) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_reset (ctx, ((synchronous&255) | 256) ); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, + getauditlog_status_handler, ctx); + + return _gpgme_engine_op_getauditlog (ctx->engine, output, flags); +} + + + +/* Return the auditlog for the current session. This may be called + after a successful or failed operation. If no audit log is + available GPG_ERR_NO_DATA is returned. This is the asynchronous + variant. */ +gpgme_error_t +gpgme_op_getauditlog_start (gpgme_ctx_t ctx, + gpgme_data_t output, unsigned int flags) +{ + return getauditlog_start (ctx, 0, output, flags); +} + + +/* Return the auditlog for the current session. This may be called + after a successful or failed operation. If no audit log is + available GPG_ERR_NO_DATA is returned. This is the synchronous + variant. */ +gpgme_error_t +gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags) +{ + gpgme_error_t err = getauditlog_start (ctx, 1, output, flags); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + diff -urpNP gpgme-1.1.5/gpgme/gpgconf.c gpgme-1.1.6/gpgme/gpgconf.c --- gpgme-1.1.5/gpgme/gpgconf.c 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/gpgconf.c 2008-01-04 14:17:15.000000000 +0000 @@ -0,0 +1,134 @@ +/* gpgconf.c - GnuPG Made Easy. + Copyright (C) 2007 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" + +#include "ops.h" +#include "engine.h" + +#ifdef ENABLE_GPGCONF +/* engine-gpgconf.c. */ +gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, void *value); +void _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); +gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, + gpgme_conf_arg_t arg); +void _gpgme_conf_release (gpgme_conf_comp_t conf); +gpgme_error_t _gpgme_conf_load (void *engine, gpgme_conf_comp_t *conf_p); +gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp); + +#endif + + +/* Allocate a new gpgme_conf_arg_t. */ +gpgme_error_t +gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, void *value) +{ +#ifdef ENABLE_GPGCONF + return _gpgme_conf_arg_new (arg_p, type, value); +#else + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#endif +} + + +/* This also releases all chained argument structures! */ +void +gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type) +{ +#ifdef ENABLE_GPGCONF + return _gpgme_conf_arg_release (arg, type); +#endif +} + + +/* Register a change for the value of OPT to ARG. */ +gpgme_error_t +gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg) +{ +#ifdef ENABLE_GPGCONF + return _gpgme_conf_opt_change (opt, reset, arg); +#else + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#endif +} + + + +/* Public function to release a gpgme_conf_comp list. */ +void +gpgme_conf_release (gpgme_conf_comp_t conf) +{ +#ifdef ENABLE_GPGCONF + _gpgme_conf_release (conf); +#endif +} + + +/* Public function to release load a configuration list. No + asynchronous interface for now. */ +gpgme_error_t +gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p) +{ +#ifdef ENABLE_GPGCONF + gpgme_error_t err; + gpgme_protocol_t proto = ctx->protocol; + + ctx->protocol = GPGME_PROTOCOL_GPGCONF; + err = _gpgme_op_reset (ctx, 1); + if (err) + return err; + + err = _gpgme_engine_op_conf_load (ctx->engine, conf_p); + ctx->protocol = proto; + return err; +#else + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#endif +} + + +/* This function does not follow chained components! */ +gpgme_error_t +gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp) +{ +#ifdef ENABLE_GPGCONF + gpgme_error_t err; + gpgme_protocol_t proto = ctx->protocol; + + ctx->protocol = GPGME_PROTOCOL_GPGCONF; + err = _gpgme_op_reset (ctx, 1); + if (err) + return err; + + err = _gpgme_engine_op_conf_save (ctx->engine, comp); + ctx->protocol = proto; + return err; +#else + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#endif +} + + diff -urpNP gpgme-1.1.5/gpgme/gpgme.c gpgme-1.1.6/gpgme/gpgme.c --- gpgme-1.1.5/gpgme/gpgme.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/gpgme.c 2007-10-04 11:06:47.000000000 +0000 @@ -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,25 +109,29 @@ 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); gpgme_signers_clear (ctx); + gpgme_sig_notation_clear (ctx); if (ctx->signers) free (ctx->signers); if (ctx->lc_ctype) @@ -156,27 +163,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; } @@ -192,6 +208,9 @@ gpgme_get_protocol_name (gpgme_protocol_ case GPGME_PROTOCOL_CMS: return "CMS"; + case GPGME_PROTOCOL_UNKNOWN: + return "unknown"; + default: return NULL; } @@ -199,9 +218,11 @@ gpgme_get_protocol_name (gpgme_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 +230,8 @@ gpgme_set_armor (gpgme_ctx_t ctx, int ye 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 +241,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 +270,9 @@ gpgme_set_include_certs (gpgme_ctx_t ctx 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 +281,8 @@ gpgme_set_include_certs (gpgme_ctx_t ctx 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 +293,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 +305,8 @@ gpgme_set_keylist_mode (gpgme_ctx_t ctx, 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 +317,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 +330,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 +345,8 @@ gpgme_get_passphrase_cb (gpgme_ctx_t ctx 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 +358,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 +372,17 @@ void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs) { if (io_cbs) - ctx->io_cbs = *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 +396,11 @@ gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme 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 +414,9 @@ gpgme_set_locale (gpgme_ctx_t ctx, int c 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 +440,7 @@ gpgme_set_locale (gpgme_ctx_t ctx, int c 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 +469,7 @@ gpgme_set_locale (gpgme_ctx_t ctx, int c if (!ctx) UNLOCK (def_lc_lock); - return 0; + return TRACE_ERR (0); } @@ -417,6 +479,8 @@ gpgme_set_locale (gpgme_ctx_t ctx, int c 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 +491,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, - file_name, home_dir); + err = _gpgme_set_engine_info (ctx->engine_info, proto, + file_name, home_dir); + return TRACE_ERR (err); } @@ -443,6 +517,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 +545,13 @@ gpgme_sig_notation_add (gpgme_ctx_t ctx, 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) - 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 +561,14 @@ gpgme_sig_notation_add (gpgme_ctx_t ctx, err = _gpgme_sig_notation_create (¬ation, 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 +577,12 @@ gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx) { if (!ctx) - return NULL; + { + 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; } diff -urpNP gpgme-1.1.5/gpgme/gpgme.def gpgme-1.1.6/gpgme/gpgme.def --- gpgme-1.1.5/gpgme/gpgme.def 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/gpgme.def 2008-01-04 14:17:15.000000000 +0000 @@ -154,5 +154,17 @@ EXPORTS gpgme_free @120 gpgme_get_giochannel @121 + gpgme_get_fdptr @122 + + gpgme_op_getauditlog_start @123 + gpgme_op_getauditlog @124 + + gpgme_conf_release @125 + gpgme_conf_arg_new @126 + gpgme_conf_arg_release @127 + gpgme_conf_opt_change @128 + gpgme_op_conf_load @129 + gpgme_op_conf_save @130 + ; END diff -urpNP gpgme-1.1.5/gpgme/gpgme.h gpgme-1.1.6/gpgme/gpgme.h --- gpgme-1.1.5/gpgme/gpgme.h 2007-07-09 13:14:04.000000000 +0000 +++ gpgme-1.1.6/gpgme/gpgme.h 2008-01-04 14:27:06.000000000 +0000 @@ -1,6 +1,6 @@ /* gpgme.h - Public interface to 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. @@ -15,9 +15,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #ifndef GPGME_H #define GPGME_H @@ -40,6 +39,8 @@ # include #endif +#include + #ifdef __cplusplus extern "C" { #if 0 /* just to make Emacs auto-indent happy */ @@ -47,7 +48,6 @@ extern "C" { #endif #endif /* __cplusplus */ -#include /* Check for compiler features. */ @@ -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.5" +#define GPGME_VERSION "1.1.6" @@ -299,7 +299,9 @@ gpgme_validity_t; typedef enum { GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */ - GPGME_PROTOCOL_CMS = 1 + GPGME_PROTOCOL_CMS = 1, + GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */ + GPGME_PROTOCOL_UNKNOWN = 255 } gpgme_protocol_t; @@ -314,6 +316,11 @@ gpgme_protocol_t; typedef unsigned int gpgme_keylist_mode_t; +/* Flags for the audit log functions. */ +#define GPGME_AUDITLOG_HTML 1 +#define GPGME_AUDITLOG_WITH_HELP 128 + + /* Signature notations. */ /* The available signature notation flags. */ @@ -1323,8 +1330,11 @@ struct _gpgme_signature /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */ unsigned int pka_trust : 2; + /* Validity has been verified using the chain model. */ + unsigned int chain_model : 1; + /* Internal to GPGME, do not use. */ - int _unused : 29; + int _unused : 28; gpgme_validity_t validity; gpgme_error_t validity_reason; @@ -1635,6 +1645,173 @@ int gpgme_trust_item_get_int_attr (gpgme _GPGME_DEPRECATED; +/* Return the auditlog for the current session. This may be called + after a successful or failed operation. If no audit log is + available GPG_ERR_NO_DATA is returned. */ +gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output, + unsigned int flags); +gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, + unsigned int flags); + + +/* Interface to gpg-conf. */ + +/* The expert level at which a configuration option or group of + options should be displayed. See the gpg-conf documentation for + more details. */ +typedef enum + { + GPGME_CONF_BASIC = 0, + GPGME_CONF_ADVANCED = 1, + GPGME_CONF_EXPERT = 2, + GPGME_CONF_INVISIBLE = 3, + GPGME_CONF_INTERNAL = 4 + } +gpgme_conf_level_t; + + +/* The data type of a configuration option argument. See the gpg-conf + documentation for more details. */ +typedef enum + { + /* Basic types. */ + GPGME_CONF_NONE = 0, + GPGME_CONF_STRING = 1, + GPGME_CONF_INT32 = 2, + GPGME_CONF_UINT32 = 3, + + /* Complex types. */ + GPGME_CONF_PATHNAME = 32, + GPGME_CONF_LDAP_SERVER = 33 + } +gpgme_conf_type_t; + + +/* This represents a single argument for a configuration option. + Which of the members of value is used depends on the ALT_TYPE. */ +typedef struct gpgme_conf_arg +{ + struct gpgme_conf_arg *next; + /* True if the option appears without an (optional) argument. */ + unsigned int no_arg; + union + { + unsigned int count; + unsigned int uint32; + int int32; + char *string; + } value; +} *gpgme_conf_arg_t; + + +/* The flags of a configuration option. See the gpg-conf + documentation for details. */ +#define GPGME_CONF_GROUP (1 << 0) +#define GPGME_CONF_OPTIONAL (1 << 1) +#define GPGME_CONF_LIST (1 << 2) +#define GPGME_CONF_RUNTIME (1 << 3) +#define GPGME_CONF_DEFAULT (1 << 4) +#define GPGME_CONF_DEFAULT_DESC (1 << 5) +#define GPGME_CONF_NO_ARG_DESC (1 << 6) +#define GPGME_CONF_NO_CHANGE (1 << 7) + + +/* The representation of a single configuration option. See the + gpg-conf documentation for details. */ +typedef struct gpgme_conf_opt +{ + struct gpgme_conf_opt *next; + + /* The option name. */ + char *name; + + /* The flags for this option. */ + unsigned int flags; + + /* The level of this option. */ + gpgme_conf_level_t level; + + /* The localized description of this option. */ + char *description; + + /* The type and alternate type of this option. */ + gpgme_conf_type_t type; + gpgme_conf_type_t alt_type; + + /* The localized (short) name of the argument, if any. */ + char *argname; + + /* The default value. */ + gpgme_conf_arg_t default_value; + char *default_description; + + /* The default value if the option is not set. */ + gpgme_conf_arg_t no_arg_value; + char *no_arg_description; + + /* The current value if the option is set. */ + gpgme_conf_arg_t value; + + /* The new value, if any. NULL means reset to default. */ + int change_value; + gpgme_conf_arg_t new_value; + + /* Free for application use. */ + void *user_data; +} *gpgme_conf_opt_t; + + +/* The representation of a component that can be configured. See the + gpg-conf documentation for details. */ +typedef struct gpgme_conf_comp +{ + struct gpgme_conf_comp *next; + + /* Internal to GPGME, do not use! */ + gpgme_conf_opt_t *_last_opt_p; + + /* The component name. */ + char *name; + + /* A human-readable description for the component. */ + char *description; + + /* The program name (an absolute path to the program). */ + char *program_name; + + /* A linked list of options for this component. */ + struct gpgme_conf_opt *options; +} *gpgme_conf_comp_t; + + +/* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg + default" is prepared. If type is a string type, VALUE should point + to the string. Else, it should point to an unsigned or signed + integer respectively. */ +gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, void *value); + +/* This also releases all chained argument structures! */ +void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); + +/* Register a change for the value of OPT to ARG. If RESET is 1 (do + not use any values but 0 or 1), ARG is ignored and the option is + not changed (reverting a previous change). Otherwise, if ARG is + NULL, the option is cleared or reset to its default. */ +gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, + gpgme_conf_arg_t arg); + +/* Release a set of configurations. */ +void gpgme_conf_release (gpgme_conf_comp_t conf); + +/* Retrieve the current configurations. */ +gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p); + +/* Save the configuration of component comp. This function does not + follow chained components! */ +gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp); + + /* Various functions. */ /* Check that the library fulfills the version requirement. */ diff -urpNP gpgme-1.1.5/gpgme/kdpipeiodevice.cpp gpgme-1.1.6/gpgme/kdpipeiodevice.cpp --- gpgme-1.1.5/gpgme/kdpipeiodevice.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/kdpipeiodevice.cpp 2007-11-12 11:21:58.000000000 +0000 @@ -0,0 +1,940 @@ +/* + Copyright (C) 2007 Klarälvdalens Datakonsult AB + + KDPipeIODevice is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + KDPipeIODevice is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with KDPipeIODevice; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kdpipeiodevice.h" + +#include + +#include +#include +#include + +#ifdef Q_OS_WIN32 +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include +# include +#else +# include +# include +#endif + +using namespace _gpgme_; + +#ifndef KDAB_CHECK_THIS +# define KDAB_CHECK_CTOR (void)1 +# define KDAB_CHECK_DTOR KDAB_CHECK_CTOR +# define KDAB_CHECK_THIS KDAB_CHECK_CTOR +#endif + +#define LOCKED( d ) const QMutexLocker locker( &d->mutex ) +#define synchronized( d ) if ( int i = 0 ) {} else for ( const QMutexLocker locker( &d->mutex ) ; !i ; ++i ) + +const unsigned int BUFFER_SIZE = 4096; +const bool ALLOW_QIODEVICE_BUFFERING = true; + +// comment to get trace output: +//#define qDebug if(1){}else qDebug + +namespace { +class Reader : public QThread { + Q_OBJECT +public: + Reader( int fd, Qt::HANDLE handle ); + ~Reader(); + + qint64 readData( char * data, qint64 maxSize ); + + unsigned int bytesInBuffer() const { + return ( wptr + sizeof buffer - rptr ) % sizeof buffer ; + } + + bool bufferFull() const { + return bytesInBuffer() == sizeof buffer - 1; + } + + bool bufferEmpty() const { + return bytesInBuffer() == 0; + } + + bool bufferContains( char ch ) { + const unsigned int bib = bytesInBuffer(); + for ( unsigned int i = rptr ; i < rptr + bib ; ++i ) + if ( buffer[i%sizeof buffer] == ch ) + return true; + return false; + } + + void notifyReadyRead(); + +Q_SIGNALS: + void readyRead(); + +protected: + /* reimp */ void run(); + +private: + int fd; + Qt::HANDLE handle; +public: + QMutex mutex; + QWaitCondition waitForCancelCondition; + QWaitCondition bufferNotFullCondition; + QWaitCondition bufferNotEmptyCondition; + QWaitCondition hasStarted; + QWaitCondition readyReadSentCondition; + QWaitCondition blockedConsumerIsDoneCondition; + bool cancel; + bool eof; + bool error; + bool eofShortCut; + int errorCode; + bool consumerBlocksOnUs; + +private: + unsigned int rptr, wptr; + char buffer[BUFFER_SIZE+1]; // need to keep one byte free to detect empty state +}; + + +Reader::Reader( int fd_, Qt::HANDLE handle_ ) + : QThread(), + fd( fd_ ), + handle( handle_ ), + mutex(), + bufferNotFullCondition(), + bufferNotEmptyCondition(), + hasStarted(), + cancel( false ), + eof( false ), + error( false ), + eofShortCut( false ), + errorCode( 0 ), + consumerBlocksOnUs( false ), + rptr( 0 ), wptr( 0 ) +{ + +} + +Reader::~Reader() {} + + +class Writer : public QThread { + Q_OBJECT +public: + Writer( int fd, Qt::HANDLE handle ); + ~Writer(); + + qint64 writeData( const char * data, qint64 size ); + + unsigned int bytesInBuffer() const { return numBytesInBuffer; } + + bool bufferFull() const { + return numBytesInBuffer == sizeof buffer; + } + + bool bufferEmpty() const { + return numBytesInBuffer == 0; + } + +Q_SIGNALS: + void bytesWritten( qint64 ); + +protected: + /* reimp */ void run(); + +private: + int fd; + Qt::HANDLE handle; +public: + QMutex mutex; + QWaitCondition bufferEmptyCondition; + QWaitCondition bufferNotEmptyCondition; + QWaitCondition hasStarted; + bool cancel; + bool error; + int errorCode; +private: + unsigned int numBytesInBuffer; + char buffer[BUFFER_SIZE]; +}; +} + +Writer::Writer( int fd_, Qt::HANDLE handle_ ) + : QThread(), + fd( fd_ ), + handle( handle_ ), + mutex(), + bufferEmptyCondition(), + bufferNotEmptyCondition(), + hasStarted(), + cancel( false ), + error( false ), + errorCode( 0 ), + numBytesInBuffer( 0 ) +{ + +} + +Writer::~Writer() {} + + +class KDPipeIODevice::Private : public QObject { +Q_OBJECT + friend class ::KDPipeIODevice; + KDPipeIODevice * const q; +public: + explicit Private( KDPipeIODevice * qq ); + ~Private(); + + bool doOpen( int, Qt::HANDLE, OpenMode ); + bool startReaderThread(); + bool startWriterThread(); + void stopThreads(); + +public Q_SLOTS: + void emitReadyRead(); + +private: + int fd; + Qt::HANDLE handle; + Reader * reader; + Writer * writer; + bool triedToStartReader; + bool triedToStartWriter; +}; + +KDPipeIODevice::Private::Private( KDPipeIODevice * qq ) + : QObject( qq ), q( qq ), + fd( -1 ), + handle( 0 ), + reader( 0 ), + writer( 0 ), + triedToStartReader( false ), triedToStartWriter( false ) +{ + +} + +KDPipeIODevice::Private::~Private() { + qDebug( "KDPipeIODevice::~Private(): Destroying %p", q ); +} + +KDPipeIODevice::KDPipeIODevice( QObject * p ) + : QIODevice( p ), d( new Private( this ) ) +{ + KDAB_CHECK_CTOR; +} + +KDPipeIODevice::KDPipeIODevice( int fd, OpenMode mode, QObject * p ) + : QIODevice( p ), d( new Private( this ) ) +{ + KDAB_CHECK_CTOR; + open( fd, mode ); +} + +KDPipeIODevice::KDPipeIODevice( Qt::HANDLE handle, OpenMode mode, QObject * p ) + : QIODevice( p ), d( new Private( this ) ) +{ + KDAB_CHECK_CTOR; + open( handle, mode ); +} + +KDPipeIODevice::~KDPipeIODevice() { KDAB_CHECK_DTOR; + if ( isOpen() ) + close(); + delete d; d = 0; +} + + +bool KDPipeIODevice::open( int fd, OpenMode mode ) { KDAB_CHECK_THIS; + +#ifdef Q_OS_WIN32 + return d->doOpen( fd, (HANDLE)_get_osfhandle( fd ), mode ); +#else + return d->doOpen( fd, 0, mode ); +#endif + +} + +bool KDPipeIODevice::open( Qt::HANDLE h, OpenMode mode ) { KDAB_CHECK_THIS; + +#ifdef Q_OS_WIN32 + return d->doOpen( -1, h, mode ); +#else + Q_UNUSED( h ); + Q_UNUSED( mode ); + assert( !"KDPipeIODevice::open( Qt::HANDLE, OpenMode ) should never be called except on Windows." ); +#endif + +} + +bool KDPipeIODevice::Private::startReaderThread() +{ + if ( triedToStartReader ) + return true; + triedToStartReader = true; + if ( reader && !reader->isRunning() && !reader->isFinished() ) { + qDebug("KDPipeIODevice::Private::startReaderThread(): locking reader (CONSUMER THREAD)" ); + LOCKED( reader ); + qDebug("KDPipeIODevice::Private::startReaderThread(): locked reader (CONSUMER THREAD)" ); + reader->start( QThread::HighestPriority ); + qDebug("KDPipeIODevice::Private::startReaderThread(): waiting for hasStarted (CONSUMER THREAD)" ); + const bool hasStarted = reader->hasStarted.wait( &reader->mutex, 1000 ); + qDebug("KDPipeIODevice::Private::startReaderThread(): returned from hasStarted (CONSUMER THREAD)" ); + + return hasStarted; + } + return true; +} + +bool KDPipeIODevice::Private::startWriterThread() +{ + if ( triedToStartWriter ) + return true; + triedToStartWriter = true; + if ( writer && !writer->isRunning() && !writer->isFinished() ) { + LOCKED( writer ); + + writer->start( QThread::HighestPriority ); + if ( !writer->hasStarted.wait( &writer->mutex, 1000 ) ) + return false; + } + return true; +} + +void KDPipeIODevice::Private::emitReadyRead() +{ + static int s_counter = 0; + const int counter = s_counter++; + QPointer thisPointer( this ); + qDebug( "KDPipeIODevice::Private::emitReadyRead %p, %d", this, counter ); + + emit q->readyRead(); + + if ( !thisPointer ) + return; + qDebug( "KDPipeIODevice::Private::emitReadyRead %p, %d: locking reader (CONSUMER THREAD)", this, counter ); + synchronized( reader ) { + qDebug( "KDPipeIODevice::Private::emitReadyRead %p, %d: locked reader (CONSUMER THREAD)", this, counter ); + reader->readyReadSentCondition.wakeAll(); + } + qDebug( "KDPipeIODevice::Private::emitReadyRead %p leaving %d", this, counter ); + +} + +bool KDPipeIODevice::Private::doOpen( int fd_, Qt::HANDLE handle_, OpenMode mode_ ) { + + if ( q->isOpen() ) + return false; + +#ifdef Q_OS_WIN32 + if ( !handle_ ) + return false; +#else + if ( fd_ < 0 ) + return false; +#endif + + if ( !(mode_ & ReadWrite) ) + return false; // need to have at least read -or- write + + + std::auto_ptr reader_; + std::auto_ptr writer_; + + if ( mode_ & ReadOnly ) { + reader_.reset( new Reader( fd_, handle_ ) ); + qDebug( "KDPipeIODevice::doOpen (%p): created reader (%p) for fd %d", this, reader_.get(), fd_ ); + connect( reader_.get(), SIGNAL(readyRead()), this, SLOT(emitReadyRead()), +Qt::QueuedConnection ); + } + if ( mode_ & WriteOnly ) { + writer_.reset( new Writer( fd_, handle_ ) ); + qDebug( "KDPipeIODevice::doOpen (%p): created writer (%p) for fd %d", this, writer_.get(), fd_ ); + connect( writer_.get(), SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)), +Qt::QueuedConnection ); + } + + // commit to *this: + fd = fd_; + handle = handle_; + reader = reader_.release(); + writer = writer_.release(); + + q->setOpenMode( mode_|Unbuffered ); + return true; +} + +int KDPipeIODevice::descriptor() const { KDAB_CHECK_THIS; + return d->fd; +} + + +Qt::HANDLE KDPipeIODevice::handle() const { KDAB_CHECK_THIS; + return d->handle; +} + +qint64 KDPipeIODevice::bytesAvailable() const { KDAB_CHECK_THIS; + const qint64 base = QIODevice::bytesAvailable(); + if ( !d->triedToStartReader ) { + d->startReaderThread(); + return base; + } + if ( d->reader ) + synchronized( d->reader ) { + const qint64 inBuffer = d->reader->bytesInBuffer(); + return base + inBuffer; + } + return base; +} + +qint64 KDPipeIODevice::bytesToWrite() const { KDAB_CHECK_THIS; + d->startWriterThread(); + const qint64 base = QIODevice::bytesToWrite(); + if ( d->writer ) + synchronized( d->writer ) return base + d->writer->bytesInBuffer(); + return base; +} + +bool KDPipeIODevice::canReadLine() const { KDAB_CHECK_THIS; + d->startReaderThread(); + if ( QIODevice::canReadLine() ) + return true; + if ( d->reader ) + synchronized( d->reader ) return d->reader->bufferContains( '\n' ); + return true; +} + +bool KDPipeIODevice::isSequential() const { + return true; +} + +bool KDPipeIODevice::atEnd() const { KDAB_CHECK_THIS; + d->startReaderThread(); + if ( !QIODevice::atEnd() ) { + qDebug( "%p: KDPipeIODevice::atEnd returns false since QIODevice::atEnd does (with bytesAvailable=%ld)", this, static_cast(bytesAvailable()) ); + return false; + } + if ( !isOpen() ) + return true; + if ( d->reader->eofShortCut ) + return true; + LOCKED( d->reader ); + const bool eof = ( d->reader->error || d->reader->eof ) && d->reader->bufferEmpty(); + if ( !eof ) { + if ( !d->reader->error && !d->reader->eof ) + qDebug( "%p: KDPipeIODevice::atEnd returns false since !reader->error && !reader->eof", this ); + if ( !d->reader->bufferEmpty() ) + qDebug( "%p: KDPipeIODevice::atEnd returns false since !reader->bufferEmpty()", this ); + } + return eof; +} + +bool KDPipeIODevice::waitForBytesWritten( int msecs ) { KDAB_CHECK_THIS; + d->startWriterThread(); + Writer * const w = d->writer; + if ( !w ) + return true; + LOCKED( w ); + qDebug( "KDPipeIODevice::waitForBytesWritten (%p,w=%p): entered locked area", this, w +); + return w->bufferEmpty() || w->error || w->bufferEmptyCondition.wait( &w->mutex, msecs ) ; +} + +bool KDPipeIODevice::waitForReadyRead( int msecs ) { KDAB_CHECK_THIS; + qDebug( "KDPipeIODEvice::waitForReadyRead()(%p)", this); + d->startReaderThread(); + if ( ALLOW_QIODEVICE_BUFFERING ) { + if ( bytesAvailable() > 0 ) + return true; + } + Reader * const r = d->reader; + if ( !r || r->eofShortCut ) + return true; + LOCKED( r ); + if ( r->bytesInBuffer() != 0 || r->eof || r->error ) + return true; + assert( false ); + return r->bufferNotEmptyCondition.wait( &r->mutex, msecs ) ; +} + +template +class TemporaryValue { +public: + TemporaryValue( T& var_, const T& tv ) : var( var_ ), oldValue( var_ ) { var = tv; } + ~TemporaryValue() { var = oldValue; } +private: + T& var; + const T oldValue; +}; + + +bool KDPipeIODevice::readWouldBlock() const +{ + d->startReaderThread(); + LOCKED( d->reader ); + return d->reader->bufferEmpty() && !d->reader->eof && !d->reader->error; +} + +bool KDPipeIODevice::writeWouldBlock() const +{ + d->startWriterThread(); + LOCKED( d->writer ); + return !d->writer->bufferEmpty() && !d->writer->error; +} + + +qint64 KDPipeIODevice::readData( char * data, qint64 maxSize ) { KDAB_CHECK_THIS; + qDebug( "%p: KDPipeIODevice::readData: data=%p, maxSize=%lld", this, data, maxSize ); + d->startReaderThread(); + Reader * const r = d->reader; + + assert( r ); + + + //assert( r->isRunning() ); // wrong (might be eof, error) + assert( data || maxSize == 0 ); + assert( maxSize >= 0 ); + + if ( r->eofShortCut ) { + qDebug( "%p: KDPipeIODevice::readData: hit eofShortCut, returning 0", this ); + return 0; + } + + if ( maxSize < 0 ) + maxSize = 0; + + if ( ALLOW_QIODEVICE_BUFFERING ) { + if ( bytesAvailable() > 0 ) + maxSize = std::min( maxSize, bytesAvailable() ); // don't block + } + qDebug( "%p: KDPipeIODevice::readData: try to lock reader (CONSUMER THREAD)", this ); + LOCKED( r ); + qDebug( "%p: KDPipeIODevice::readData: locked reader (CONSUMER THREAD)", this ); + + r->readyReadSentCondition.wakeAll(); + if ( /* maxSize > 0 && */ r->bufferEmpty() && !r->error && !r->eof ) { // ### block on maxSize == 0? + qDebug( "%p: KDPipeIODevice::readData: waiting for bufferNotEmptyCondition (CONSUMER THREAD)", this ); + const TemporaryValue tmp( d->reader->consumerBlocksOnUs, true ); + r->bufferNotEmptyCondition.wait( &r->mutex ); + r->blockedConsumerIsDoneCondition.wakeAll(); + qDebug( "%p: KDPipeIODevice::readData: woke up from bufferNotEmptyCondition (CONSUMER THREAD)", this ); + } + + if ( r->bufferEmpty() ) { + qDebug( "%p: KDPipeIODevice::readData: got empty buffer, signal eof", this ); + // woken with an empty buffer must mean either EOF or error: + assert( r->eof || r->error ); + r->eofShortCut = true; + return r->eof ? 0 : -1 ; + } + + qDebug( "%p: KDPipeIODevice::readData: got bufferNotEmptyCondition, trying to read %lld bytes", this, maxSize ); + const qint64 bytesRead = r->readData( data, maxSize ); + qDebug( "%p: KDPipeIODevice::readData: read %lld bytes", this, bytesRead ); + qDebug( "%p (fd=%d): KDPipeIODevice::readData: %s", this, d->fd, data ); + + return bytesRead; +} + +qint64 Reader::readData( char * data, qint64 maxSize ) { + qint64 numRead = rptr < wptr ? wptr - rptr : sizeof buffer - rptr ; + if ( numRead > maxSize ) + numRead = maxSize; + + qDebug( "%p: KDPipeIODevice::readData: data=%p, maxSize=%lld; rptr=%u, wptr=%u (bytesInBuffer=%u); -> numRead=%lld", this, + data, maxSize, rptr, wptr, bytesInBuffer(), numRead ); + + std::memcpy( data, buffer + rptr, numRead ); + + rptr = ( rptr + numRead ) % sizeof buffer ; + + if ( !bufferFull() ) { + qDebug( "%p: KDPipeIODevice::readData: signal bufferNotFullCondition", this ); + bufferNotFullCondition.wakeAll(); + } + + return numRead; +} + +qint64 KDPipeIODevice::writeData( const char * data, qint64 size ) { KDAB_CHECK_THIS; + d->startWriterThread(); + Writer * const w = d->writer; + + assert( w ); + assert( w->error || w->isRunning() ); + assert( data || size == 0 ); + assert( size >= 0 ); + + LOCKED( w ); + + while ( !w->error && !w->bufferEmpty() ) { + qDebug( "%p: KDPipeIODevice::writeData: wait for empty buffer", this ); + w->bufferEmptyCondition.wait( &w->mutex ); + qDebug( "%p: KDPipeIODevice::writeData: empty buffer signaled", this ); + + } + if ( w->error ) + return -1; + + assert( w->bufferEmpty() ); + + return w->writeData( data, size ); +} + +qint64 Writer::writeData( const char * data, qint64 size ) { + assert( bufferEmpty() ); + + if ( size > static_cast( sizeof buffer ) ) + size = sizeof buffer; + + std::memcpy( buffer, data, size ); + + numBytesInBuffer = size; + + if ( !bufferEmpty() ) { + bufferNotEmptyCondition.wakeAll(); + } + return size; +} + +void KDPipeIODevice::Private::stopThreads() +{ + if ( triedToStartWriter ) + { + if ( writer && q->bytesToWrite() > 0 ) + q->waitForBytesWritten( -1 ); + + assert( q->bytesToWrite() == 0 ); + } + if ( Reader * & r = reader ) { + disconnect( r, SIGNAL( readyRead() ), this, SLOT( emitReadyRead() ) ); + synchronized( r ) { + // tell thread to cancel: + r->cancel = true; + // and wake it, so it can terminate: + r->waitForCancelCondition.wakeAll(); + r->bufferNotFullCondition.wakeAll(); + r->readyReadSentCondition.wakeAll(); + } + } + if ( Writer * & w = writer ) { + synchronized( w ) { + // tell thread to cancel: + w->cancel = true; + // and wake it, so it can terminate: + w->bufferNotEmptyCondition.wakeAll(); + } + } +} + +void KDPipeIODevice::close() { KDAB_CHECK_THIS; + qDebug( "KDPipeIODevice::close(%p)", this ); + if ( !isOpen() ) + return; + + // tell clients we're about to close: + emit aboutToClose(); + d->stopThreads(); + +#define waitAndDelete( t ) if ( t ) { t->wait(); QThread* const t2 = t; t = 0; delete t2; } + qDebug( "KPipeIODevice::close(%p): wait and closing writer %p", this, d->writer ); + waitAndDelete( d->writer ); + qDebug( "KPipeIODevice::close(%p): wait and closing reader %p", this, d->reader ); + if ( d->reader ) { + LOCKED( d->reader ); + d->reader->readyReadSentCondition.wakeAll(); + } + waitAndDelete( d->reader ); +#undef waitAndDelete +#ifdef Q_OS_WIN32 + if ( d->fd != -1 ) + _close( d->fd ); + else + CloseHandle( d->handle ); +#else + ::close( d->fd ); +#endif + + setOpenMode( NotOpen ); + d->fd = -1; + d->handle = 0; +} + +void Reader::run() { + + LOCKED( this ); + + // too bad QThread doesn't have that itself; a signal isn't enough + hasStarted.wakeAll(); + + qDebug( "%p: Reader::run: started", this ); + + while ( true ) { + if ( !cancel && ( eof || error ) ) { + //notify the client until the buffer is empty and then once + //again so he receives eof/error. After that, wait for him + //to cancel + const bool wasEmpty = bufferEmpty(); + qDebug( "%p: Reader::run: received eof(%d) or error(%d), waking everyone", this, eof, error ); + notifyReadyRead(); + if ( !cancel && wasEmpty ) + waitForCancelCondition.wait( &mutex ); + } else if ( !cancel && !bufferFull() && !bufferEmpty() ) { + qDebug( "%p: Reader::run: buffer no longer empty, waking everyone", this ); + notifyReadyRead(); + } + + while ( !cancel && !error && bufferFull() ) { + notifyReadyRead(); + if ( bufferFull() ) { + qDebug( "%p: Reader::run: buffer is full, going to sleep", this ); + bufferNotFullCondition.wait( &mutex ); + } + } + + if ( cancel ) { + qDebug( "%p: Reader::run: detected cancel", this ); + goto leave; + } + + if ( !eof && !error ) { + if ( rptr == wptr ) // optimize for larger chunks in case the buffer is empty + rptr = wptr = 0; + + unsigned int numBytes = ( rptr + sizeof buffer - wptr - 1 ) % sizeof buffer; + if ( numBytes > sizeof buffer - wptr ) + numBytes = sizeof buffer - wptr; + + qDebug( "%p: Reader::run: rptr=%d, wptr=%d -> numBytes=%d", this, rptr, wptr, numBytes ); + + assert( numBytes > 0 ); + + qDebug( "%p: Reader::run: trying to read %d bytes", this, numBytes ); +#ifdef Q_OS_WIN32 + mutex.unlock(); + DWORD numRead; + const bool ok = ReadFile( handle, buffer + wptr, numBytes, &numRead, 0 ); + mutex.lock(); + if ( ok ) { + if ( numRead == 0 ) { + qDebug( "%p: Reader::run: got eof (numRead==0)", this ); + eof = true; + } + } else { // !ok + errorCode = static_cast( GetLastError() ); + if ( errorCode == ERROR_BROKEN_PIPE ) { + assert( numRead == 0 ); + qDebug( "%p: Reader::run: got eof (broken pipe)", this ); + eof = true; + } else { + assert( numRead == 0 ); + qDebug( "%p: Reader::run: got error: %s (%d)", this, strerror( errorCode ), errorCode ); + error = true; + } + } +#else + qint64 numRead; + mutex.unlock(); + do { + numRead = ::read( fd, buffer + wptr, numBytes ); + } while ( numRead == -1 && errno == EINTR ); + mutex.lock(); + + if ( numRead < 0 ) { + errorCode = errno; + error = true; + qDebug( "%p: Reader::run: got error: %d", this, errorCode ); + } else if ( numRead == 0 ) { + qDebug( "%p: Reader::run: eof detected", this ); + eof = true; + } +#endif + qDebug( "%p: Reader::run: read %ld bytes", this, static_cast(numRead) ); + qDebug( "%p: Reader::run(fd=%d): %s", this, fd, buffer ); + + if ( numRead > 0 ) { + qDebug( "%p: Reader::run: buffer before: rptr=%4d, wptr=%4d", this, rptr, wptr ); + wptr = ( wptr + numRead ) % sizeof buffer; + qDebug( "%p: Reader::run: buffer after: rptr=%4d, wptr=%4d", this, rptr, wptr ); + } + } + } + leave: + qDebug( "%p: Reader::run: terminated", this ); +} + +void Reader::notifyReadyRead() +{ + qDebug( "notifyReadyRead: %d bytes available", bytesInBuffer() ); + assert( !cancel ); + + if ( consumerBlocksOnUs ) { + bufferNotEmptyCondition.wakeAll(); + blockedConsumerIsDoneCondition.wait( &mutex ); + return; + } + qDebug( "notifyReadyRead: emit signal" ); + emit readyRead(); + readyReadSentCondition.wait( &mutex ); + qDebug( "notifyReadyRead: returning from waiting, leave" ); +} + +void Writer::run() { + + LOCKED( this ); + + // too bad QThread doesn't have that itself; a signal isn't enough + hasStarted.wakeAll(); + + qDebug( "%p: Writer::run: started", this ); + + while ( true ) { + + while ( !cancel && bufferEmpty() ) { + qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this ); + bufferEmptyCondition.wakeAll(); + emit bytesWritten( 0 ); + qDebug( "%p: Writer::run: buffer is empty, going to sleep", this ); + bufferNotEmptyCondition.wait( &mutex ); + qDebug( "%p: Writer::run: woke up", this ); + } + + if ( cancel ) { + qDebug( "%p: Writer::run: detected cancel", this ); + goto leave; + } + + assert( numBytesInBuffer > 0 ); + + qDebug( "%p: Writer::run: Trying to write %u bytes", this, numBytesInBuffer ); + qint64 totalWritten = 0; + do { + mutex.unlock(); +#ifdef Q_OS_WIN32 + DWORD numWritten; + qDebug( "%p (fd=%d): Writer::run: buffer before WriteFile (numBytes=%lld): %s:", this, fd, numBytesInBuffer, buffer ); + qDebug( "%p (fd=%d): Writer::run: Going into WriteFile", this, fd ); + if ( !WriteFile( handle, buffer + totalWritten, numBytesInBuffer - totalWritten, &numWritten, 0 ) ) { + mutex.lock(); + errorCode = static_cast( GetLastError() ); + qDebug( "%p: Writer::run: got error code: %d", this, errorCode ); + error = true; + goto leave; + } +#else + qint64 numWritten; + do { + numWritten = ::write( fd, buffer + totalWritten, numBytesInBuffer - totalWritten ); + } while ( numWritten == -1 && errno == EINTR ); + + if ( numWritten < 0 ) { + mutex.lock(); + errorCode = errno; + qDebug( "%p: Writer::run: got error code: %d", this, errorCode ); + error = true; + goto leave; + } +#endif + qDebug( "%p (fd=%d): Writer::run: buffer after WriteFile (numBytes=%u): %s:", this, fd, numBytesInBuffer, buffer ); + totalWritten += numWritten; + mutex.lock(); + } while ( totalWritten < numBytesInBuffer ); + + qDebug( "%p: Writer::run: wrote %lld bytes", this, totalWritten ); + + numBytesInBuffer = 0; + + qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this ); + bufferEmptyCondition.wakeAll(); + emit bytesWritten( totalWritten ); + } + leave: + qDebug( "%p: Writer::run: terminating", this ); + numBytesInBuffer = 0; + qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this ); + bufferEmptyCondition.wakeAll(); + emit bytesWritten( 0 ); +} + +// static +std::pair KDPipeIODevice::makePairOfConnectedPipes() { + KDPipeIODevice * read = 0; + KDPipeIODevice * write = 0; +#ifdef Q_OS_WIN32 + HANDLE rh; + HANDLE wh; + SECURITY_ATTRIBUTES sa; + memset( &sa, 0, sizeof(sa) ); + sa.nLength = sizeof(sa); + sa.bInheritHandle = TRUE; + if ( CreatePipe( &rh, &wh, &sa, BUFFER_SIZE ) ) { + read = new KDPipeIODevice; + read->open( rh, ReadOnly ); + write = new KDPipeIODevice; + write->open( wh, WriteOnly ); + } +#else + int fds[2]; + if ( pipe( fds ) == 0 ) { + read = new KDPipeIODevice; + read->open( fds[0], ReadOnly ); + write = new KDPipeIODevice; + write->open( fds[1], WriteOnly ); + } +#endif + return std::make_pair( read, write ); +} + +#ifdef KDAB_DEFINE_CHECKS +KDAB_DEFINE_CHECKS( KDPipeIODevice ) { + if ( !isOpen() ) { + assert( openMode() == NotOpen ); + assert( !d->reader ); + assert( !d->writer ); +#ifdef Q_OS_WIN32 + assert( !d->handle ); +#else + assert( d->fd < 0 ); +#endif + } else { + assert( openMode() != NotOpen ); + assert( openMode() & ReadWrite ); + if ( openMode() & ReadOnly ) { + assert( d->reader ); + synchronized( d->reader ) + assert( d->reader->eof || d->reader->error || d->reader->isRunning() ); + } + if ( openMode() & WriteOnly ) { + assert( d->writer ); + synchronized( d->writer ) + assert( d->writer->error || d->writer->isRunning() ); + } +#ifdef Q_OS_WIN32 + assert( d->handle ); +#else + assert( d->fd >= 0 ); +#endif + } +} +#endif // KDAB_DEFINE_CHECKS + +#include "moc_kdpipeiodevice.cpp" +#include "kdpipeiodevice.moc" diff -urpNP gpgme-1.1.5/gpgme/kdpipeiodevice.h gpgme-1.1.6/gpgme/kdpipeiodevice.h --- gpgme-1.1.5/gpgme/kdpipeiodevice.h 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/kdpipeiodevice.h 2007-10-04 11:07:16.000000000 +0000 @@ -0,0 +1,73 @@ +/* + Copyright (C) 2007 Klarälvdalens Datakonsult AB + + KDPipeIODevice is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + KDPipeIODevice is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with KDPipeIODevice; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __KDTOOLSCORE_KDPIPEIODEVICE_H__ +#define __KDTOOLSCORE_KDPIPEIODEVICE_H__ + +#include + +#include + +//#include "checker.h" + +namespace _gpgme_ { + +class KDPipeIODevice : public QIODevice { + Q_OBJECT + //KDAB_MAKE_CHECKABLE( KDPipeIODevice ) +public: + explicit KDPipeIODevice( QObject * parent=0 ); + explicit KDPipeIODevice( int fd, OpenMode=ReadOnly, QObject * parent=0 ); + explicit KDPipeIODevice( Qt::HANDLE handle, OpenMode=ReadOnly, QObject * parent=0 ); + ~KDPipeIODevice(); + + static std::pair makePairOfConnectedPipes(); + + bool open( int fd, OpenMode mode=ReadOnly ); + bool open( Qt::HANDLE handle, OpenMode mode=ReadOnly ); + + Qt::HANDLE handle() const; + int descriptor() const; + + bool readWouldBlock() const; + bool writeWouldBlock() const; + + /* reimp */ qint64 bytesAvailable() const; + /* reimp */ qint64 bytesToWrite() const; + /* reimp */ bool canReadLine() const; + /* reimp */ void close(); + /* reimp */ bool isSequential() const; + /* reimp */ bool atEnd() const; + + /* reimp */ bool waitForBytesWritten( int msecs ); + /* reimp */ bool waitForReadyRead( int msecs ); + +protected: + /* reimp */ qint64 readData( char * data, qint64 maxSize ); + /* reimp */ qint64 writeData( const char * data, qint64 maxSize ); + +private: + class Private; + Private * d; +}; + +} /* namespace _gpgme_ */ + +#endif /* __KDTOOLSCORE_KDPIPEIODEVICE_H__ */ + diff -urpNP gpgme-1.1.5/gpgme/kdpipeiodevice.moc gpgme-1.1.6/gpgme/kdpipeiodevice.moc --- gpgme-1.1.5/gpgme/kdpipeiodevice.moc 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/kdpipeiodevice.moc 2007-10-04 11:07:16.000000000 +0000 @@ -0,0 +1,183 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'kdpipeiodevice.cpp' +** +** Created: Tue Oct 2 19:30:13 2007 +** by: The Qt Meta Object Compiler version 59 (Qt 4.3.1) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'kdpipeiodevice.cpp' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 59 +#error "This file was generated using the moc from 4.3.1. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +static const uint qt_meta_data_Reader[] = { + + // content: + 1, // revision + 0, // classname + 0, 0, // classinfo + 1, 10, // methods + 0, 0, // properties + 0, 0, // enums/sets + + // signals: signature, parameters, type, tag, flags + 8, 7, 7, 7, 0x05, + + 0 // eod +}; + +static const char qt_meta_stringdata_Reader[] = { + "Reader\0\0readyRead()\0" +}; + +const QMetaObject Reader::staticMetaObject = { + { &QThread::staticMetaObject, qt_meta_stringdata_Reader, + qt_meta_data_Reader, 0 } +}; + +const QMetaObject *Reader::metaObject() const +{ + return &staticMetaObject; +} + +void *Reader::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_Reader)) + return static_cast(const_cast< Reader*>(this)); + return QThread::qt_metacast(_clname); +} + +int Reader::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QThread::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: readyRead(); break; + } + _id -= 1; + } + return _id; +} + +// SIGNAL 0 +void Reader::readyRead() +{ + QMetaObject::activate(this, &staticMetaObject, 0, 0); +} +static const uint qt_meta_data_Writer[] = { + + // content: + 1, // revision + 0, // classname + 0, 0, // classinfo + 1, 10, // methods + 0, 0, // properties + 0, 0, // enums/sets + + // signals: signature, parameters, type, tag, flags + 8, 7, 7, 7, 0x05, + + 0 // eod +}; + +static const char qt_meta_stringdata_Writer[] = { + "Writer\0\0bytesWritten(qint64)\0" +}; + +const QMetaObject Writer::staticMetaObject = { + { &QThread::staticMetaObject, qt_meta_stringdata_Writer, + qt_meta_data_Writer, 0 } +}; + +const QMetaObject *Writer::metaObject() const +{ + return &staticMetaObject; +} + +void *Writer::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_Writer)) + return static_cast(const_cast< Writer*>(this)); + return QThread::qt_metacast(_clname); +} + +int Writer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QThread::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: bytesWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break; + } + _id -= 1; + } + return _id; +} + +// SIGNAL 0 +void Writer::bytesWritten(qint64 _t1) +{ + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 0, _a); +} +static const uint qt_meta_data_KDPipeIODevice__Private[] = { + + // content: + 1, // revision + 0, // classname + 0, 0, // classinfo + 1, 10, // methods + 0, 0, // properties + 0, 0, // enums/sets + + // slots: signature, parameters, type, tag, flags + 25, 24, 24, 24, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_KDPipeIODevice__Private[] = { + "KDPipeIODevice::Private\0\0emitReadyRead()\0" +}; + +const QMetaObject KDPipeIODevice::Private::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_KDPipeIODevice__Private, + qt_meta_data_KDPipeIODevice__Private, 0 } +}; + +const QMetaObject *KDPipeIODevice::Private::metaObject() const +{ + return &staticMetaObject; +} + +void *KDPipeIODevice::Private::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_KDPipeIODevice__Private)) + return static_cast(const_cast< Private*>(this)); + return QObject::qt_metacast(_clname); +} + +int KDPipeIODevice::Private::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: emitReadyRead(); break; + } + _id -= 1; + } + return _id; +} diff -urpNP gpgme-1.1.5/gpgme/keylist.c gpgme-1.1.6/gpgme/keylist.c --- gpgme-1.1.5/gpgme/keylist.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/keylist.c 2007-10-04 11:06:46.000000000 +0000 @@ -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. @@ -25,6 +25,8 @@ #include #include #include +/* Solaris 8 needs sys/types.h before time.h. */ +#include #include #include #include @@ -393,8 +395,8 @@ keylist_colon_handler (void *priv, char 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) { diff -urpNP gpgme-1.1.5/gpgme/libgpgme.vers gpgme-1.1.6/gpgme/libgpgme.vers --- gpgme-1.1.5/gpgme/libgpgme.vers 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/libgpgme.vers 2008-01-04 14:17:15.000000000 +0000 @@ -36,6 +36,16 @@ GPGME_1.1 { gpgme_sig_notation_get; gpgme_free; + + gpgme_op_getauditlog_start; + gpgme_op_getauditlog; + + gpgme_conf_release; + gpgme_conf_arg_new; + gpgme_conf_arg_release; + gpgme_conf_opt_change; + gpgme_op_conf_load; + gpgme_op_conf_save; }; diff -urpNP gpgme-1.1.5/gpgme/moc_kdpipeiodevice.cpp gpgme-1.1.6/gpgme/moc_kdpipeiodevice.cpp --- gpgme-1.1.5/gpgme/moc_kdpipeiodevice.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/moc_kdpipeiodevice.cpp 2007-10-04 11:06:48.000000000 +0000 @@ -0,0 +1,60 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'kdpipeiodevice.h' +** +** Created: Mon Aug 27 15:17:18 2007 +** by: The Qt Meta Object Compiler version 59 (Qt 4.3.0) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "kdpipeiodevice.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'kdpipeiodevice.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 59 +#error "This file was generated using the moc from 4.3.0. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +static const uint qt_meta_data_KDPipeIODevice[] = { + + // content: + 1, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + + 0 // eod +}; + +static const char qt_meta_stringdata_KDPipeIODevice[] = { + "KDPipeIODevice\0" +}; + +const QMetaObject KDPipeIODevice::staticMetaObject = { + { &QIODevice::staticMetaObject, qt_meta_stringdata_KDPipeIODevice, + qt_meta_data_KDPipeIODevice, 0 } +}; + +const QMetaObject *KDPipeIODevice::metaObject() const +{ + return &staticMetaObject; +} + +void *KDPipeIODevice::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_KDPipeIODevice)) + return static_cast(const_cast< KDPipeIODevice*>(this)); + return QIODevice::qt_metacast(_clname); +} + +int KDPipeIODevice::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QIODevice::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} diff -urpNP gpgme-1.1.5/gpgme/op-support.c gpgme-1.1.6/gpgme/op-support.c --- gpgme-1.1.5/gpgme/op-support.c 2007-01-17 15:55:32.000000000 +0000 +++ gpgme-1.1.6/gpgme/op-support.c 2008-01-04 14:17:15.000000000 +0000 @@ -1,5 +1,5 @@ -/* op-support.c - Copyright (C) 2002, 2003, 2004 g10 Code GmbH +/* op-support.c - Supporting functions. + Copyright (C) 2002, 2003, 2004, 2007 g10 Code GmbH This file is part of GPGME. @@ -14,9 +14,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + License along with this program; if not, see . + */ #if HAVE_CONFIG_H #include @@ -63,16 +62,24 @@ _gpgme_op_data_lookup (gpgme_ctx_t ctx, /* type is: 0: asynchronous operation (use global or user event loop). 1: synchronous operation (always use private event loop). 2: asynchronous private operation (use private or user - event loop). */ + event loop). + 256: Modification flag to suppress the engine reset. +*/ gpgme_error_t _gpgme_op_reset (gpgme_ctx_t ctx, int type) { gpgme_error_t err = 0; struct gpgme_io_cbs io_cbs; + int no_reset = (type & 256); + int reuse_engine = 0; + + type &= 255; _gpgme_release_result (ctx); - if (ctx->engine) + if (ctx->engine && no_reset) + reuse_engine = 1; + else if (ctx->engine) { /* Attempt to reset an existing engine. */ @@ -100,18 +107,22 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int ty return err; } - err = _gpgme_engine_set_locale (ctx->engine, LC_CTYPE, ctx->lc_ctype); + if (!reuse_engine) + { + err = _gpgme_engine_set_locale (ctx->engine, LC_CTYPE, ctx->lc_ctype); #ifdef LC_MESSAGES - if (!err) - err = _gpgme_engine_set_locale (ctx->engine, - LC_MESSAGES, ctx->lc_messages); + if (!err) + err = _gpgme_engine_set_locale (ctx->engine, + LC_MESSAGES, ctx->lc_messages); #endif - - if (err) - { - _gpgme_engine_release (ctx->engine); - ctx->engine = NULL; - return err; + if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED) + err = 0; + if (err) + { + _gpgme_engine_release (ctx->engine); + ctx->engine = NULL; + return err; + } } if (type == 1 || (type == 2 && !ctx->io_cbs.add)) @@ -214,6 +225,10 @@ _gpgme_parse_inv_recp (char *args, gpgme case 10: inv_key->reason = gpg_error (GPG_ERR_PUBKEY_NOT_TRUSTED); break; + + case 11: + inv_key->reason = gpg_error (GPG_ERR_MISSING_CERT); + break; } while (*tail == ' ') diff -urpNP gpgme-1.1.5/gpgme/posix-io.c gpgme-1.1.6/gpgme/posix-io.c --- gpgme-1.1.5/gpgme/posix-io.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/posix-io.c 2007-10-04 11:06:46.000000000 +0000 @@ -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 #include #include +#include #include "util.h" #include "priv-io.h" @@ -69,48 +70,44 @@ _gpgme_io_fd2str (char *buf, int buflen, static struct { - void (*handler) (int,void*); + _gpgme_close_notify_handler_t handler; 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 inhe { 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 ? "reading" : "writing"); 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,42 +133,61 @@ _gpgme_io_pipe (int filedes[2], int inhe 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); } int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_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); } @@ -175,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); } @@ -216,12 +239,21 @@ _gpgme_io_spawn (const char *path, char { 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) { /* Intermediate child to prevent zombie processes. */ @@ -244,7 +276,12 @@ _gpgme_io_spawn (const char *path, char 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) @@ -260,7 +297,12 @@ _gpgme_io_spawn (const char *path, char 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. */ @@ -268,16 +310,24 @@ _gpgme_io_spawn (const char *path, char { if (dup2 (fd, 0) == -1) { - DEBUG1("dup2(/dev/null, 0) failed: %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(/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", - strerror (errno)); +#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); @@ -286,7 +336,11 @@ _gpgme_io_spawn (const char *path, char 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) @@ -294,34 +348,37 @@ _gpgme_io_spawn (const char *path, char else _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); @@ -329,21 +386,20 @@ _gpgme_io_select (struct io_select_fd_s 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); - else if (fds[i].for_read) + 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) @@ -352,14 +408,14 @@ _gpgme_io_select (struct io_select_fd_s 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 { @@ -368,27 +424,22 @@ _gpgme_io_select (struct io_select_fd_s } 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) @@ -410,7 +461,7 @@ _gpgme_io_select (struct io_select_fd_s } } } - return count; + return TRACE_SYSRES (count); } @@ -420,6 +471,8 @@ _gpgme_io_recvmsg (int fd, struct msghdr 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; @@ -429,15 +482,14 @@ _gpgme_io_recvmsg (int fd, struct msghdr 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; @@ -446,23 +498,23 @@ _gpgme_io_recvmsg (int fd, struct msghdr 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; @@ -472,13 +524,12 @@ _gpgme_io_sendmsg (int fd, const struct 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; } @@ -488,10 +539,12 @@ _gpgme_io_sendmsg (int fd, const struct 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); } +int +_gpgme_io_dup (int fd) +{ + return dup (fd); +} diff -urpNP gpgme-1.1.5/gpgme/posix-sema.c gpgme-1.1.6/gpgme/posix-sema.c --- gpgme-1.1.5/gpgme/posix-sema.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/posix-sema.c 2007-10-04 11:06:47.000000000 +0000 @@ -1,6 +1,6 @@ /* posix-sema.c Copyright (C) 2001 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2004 g10 Code GmbH + Copyright (C) 2001, 2002, 2004, 2007 g10 Code GmbH This file is part of GPGME. @@ -45,18 +45,18 @@ _gpgme_sema_subsystem_init () void _gpgme_sema_cs_enter (struct critsect_s *s) { - _gpgme_ath_mutex_lock (&s->private); + _gpgme_ath_mutex_lock (&s->priv); } void _gpgme_sema_cs_leave (struct critsect_s *s) { - _gpgme_ath_mutex_unlock (&s->private); + _gpgme_ath_mutex_unlock (&s->priv); } void _gpgme_sema_cs_destroy (struct critsect_s *s) { - _gpgme_ath_mutex_destroy (&s->private); - s->private = NULL; + _gpgme_ath_mutex_destroy (&s->priv); + s->priv = NULL; } diff -urpNP gpgme-1.1.5/gpgme/posix-util.c gpgme-1.1.6/gpgme/posix-util.c --- gpgme-1.1.5/gpgme/posix-util.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/posix-util.c 2008-01-04 14:17:15.000000000 +0000 @@ -49,6 +49,16 @@ _gpgme_get_gpgsm_path (void) #endif } +const char * +_gpgme_get_gpgconf_path (void) +{ +#ifdef GPGCONF_PATH + return GPGCONF_PATH; +#else + return NULL; +#endif +} + /* See w32-util.c */ int _gpgme_get_conf_int (const char *key, int *value) diff -urpNP gpgme-1.1.5/gpgme/priv-io.h gpgme-1.1.6/gpgme/priv-io.h --- gpgme-1.1.5/gpgme/priv-io.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/priv-io.h 2007-10-04 11:06:48.000000000 +0000 @@ -37,7 +37,6 @@ struct io_select_fd_s int for_read; int for_write; int signaled; - int frozen; void *opaque; }; @@ -47,7 +46,8 @@ int _gpgme_io_read (int fd, void *buffer int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_pipe (int filedes[2], int inherit_idx); int _gpgme_io_close (int fd); -int _gpgme_io_set_close_notify (int fd, void (*handler) (int, void *), +typedef void (*_gpgme_close_notify_handler_t) (int,void*); +int _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, void *value); int _gpgme_io_set_nonblocking (int fd); @@ -64,4 +64,13 @@ int _gpgme_io_select (struct io_select_f line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd); +/* Duplicate a file descriptor. This is more restrictive than dup(): + it assumes that the resulting file descriptors are essentially + co-equal (for example, no private offset), which is true for pipes + and sockets (but not files) under Unix with the standard dup() + function. Basically, this function is used to reference count the + status output file descriptor shared between GPGME and libassuan + (in engine-gpgsm.c). */ +int _gpgme_io_dup (int fd); + #endif /* IO_H */ diff -urpNP gpgme-1.1.5/gpgme/rungpg.c gpgme-1.1.6/gpgme/rungpg.c --- gpgme-1.1.5/gpgme/rungpg.c 2007-04-30 17:46:53.000000000 +0000 +++ gpgme-1.1.6/gpgme/rungpg.c 2008-01-04 14:17:15.000000000 +0000 @@ -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. @@ -136,6 +136,9 @@ gpg_io_event (void *engine, gpgme_event_ { engine_gpg_t gpg = engine; + TRACE3 (DEBUG_ENGINE, "gpgme:gpg_io_event", gpg, + "event %p, type %d, type_data %p", + gpg->io_cbs.event, type, type_data); if (gpg->io_cbs.event) (*gpg->io_cbs.event) (gpg->io_cbs.event_priv, type, type_data); } @@ -463,6 +466,8 @@ gpg_new (void **engine, const char *file goto leave; rc = _gpgme_getenv ("DISPLAY", &dft_display); + if (rc) + goto leave; if (dft_display) { rc = add_arg (gpg, "--display"); @@ -471,8 +476,6 @@ gpg_new (void **engine, const char *file free (dft_display); } - if (rc) - goto leave; if (isatty (1)) { @@ -483,18 +486,26 @@ gpg_new (void **engine, const char *file rc = gpg_error_from_errno (errno); else { - rc = add_arg (gpg, "--ttyname"); - if (!rc) - rc = add_arg (gpg, dft_ttyname); - if (!rc) + if (dft_ttyname) + { + rc = add_arg (gpg, "--ttyname"); + if (!rc) + rc = add_arg (gpg, dft_ttyname); + } + else + rc = 0; + if (!rc) { rc = _gpgme_getenv ("TERM", &dft_ttytype); - if (!rc) + if (rc) goto leave; - - rc = add_arg (gpg, "--ttytype"); - if (!rc) - rc = add_arg (gpg, dft_ttytype); + + if (dft_ttytype) + { + rc = add_arg (gpg, "--ttytype"); + if (!rc) + rc = add_arg (gpg, dft_ttytype); + } free (dft_ttytype); } @@ -1002,7 +1013,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, @@ -1035,7 +1047,6 @@ read_status (engine_gpg_t gpg) gpg->fd_data_map[gpg->cmd.linked_idx].fd; fds.for_read = 1; fds.for_write = 0; - fds.frozen = 0; fds.opaque = NULL; do { @@ -1254,6 +1265,7 @@ start (engine_gpg_t gpg) /* build the fd list for the child */ n = 0; + /* The status fd is never dup'ed, so do not include it in the list. */ if (gpg->colon.fnc) { fd_child_list[n].fd = gpg->colon.fd[1]; @@ -1344,7 +1356,7 @@ start (engine_gpg_t gpg) } } - (*gpg->io_cbs.event) (gpg->io_cbs.event_priv, GPGME_EVENT_START, NULL); + gpg_io_event (gpg, GPGME_EVENT_START, NULL); /* fixme: check what data we can release here */ return 0; @@ -2108,6 +2120,9 @@ struct engine_ops _gpgme_engine_ops_gpg gpg_sign, gpg_trustlist, gpg_verify, + NULL, /* getauditlog */ + NULL, /* conf_load */ + NULL, /* conf_save */ gpg_set_io_cbs, gpg_io_event, gpg_cancel diff -urpNP gpgme-1.1.5/gpgme/sema.h gpgme-1.1.6/gpgme/sema.h --- gpgme-1.1.5/gpgme/sema.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/sema.h 2007-10-04 11:06:48.000000000 +0000 @@ -1,6 +1,6 @@ /* sema.h - Definitions for semaphores. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2003, 2004 g10 Code GmbH + Copyright (C) 2001, 2003, 2004, 2007 g10 Code GmbH This file is part of GPGME. @@ -25,7 +25,7 @@ struct critsect_s { const char *name; - void *private; + void *priv; }; #define DEFINE_GLOBAL_LOCK(name) \ @@ -39,7 +39,7 @@ struct critsect_s do \ { \ (a).name = #a; \ - (a).private = NULL; \ + (a).priv = NULL; \ } \ while (0) #define DESTROY_LOCK(name) _gpgme_sema_cs_destroy (&(name)) diff -urpNP gpgme-1.1.5/gpgme/sign.c gpgme-1.1.6/gpgme/sign.c --- gpgme-1.1.5/gpgme/sign.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/sign.c 2007-10-04 11:06:46.000000000 +0000 @@ -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) - return NULL; + { + 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); } diff -urpNP gpgme-1.1.5/gpgme/util.h gpgme-1.1.6/gpgme/util.h --- gpgme-1.1.5/gpgme/util.h 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/util.h 2008-01-04 14:17:15.000000000 +0000 @@ -31,6 +31,7 @@ /*-- {posix,w32}-util.c --*/ const char *_gpgme_get_gpg_path (void); const char *_gpgme_get_gpgsm_path (void); +const char *_gpgme_get_gpgconf_path (void); int _gpgme_get_conf_int (const char *key, int *value); diff -urpNP gpgme-1.1.5/gpgme/verify.c gpgme-1.1.6/gpgme/verify.c --- gpgme-1.1.5/gpgme/verify.c 2007-03-09 13:10:20.000000000 +0000 +++ gpgme-1.1.6/gpgme/verify.c 2007-10-04 11:06:47.000000000 +0000 @@ -541,10 +541,21 @@ parse_trust (gpgme_signature_t sig, gpgm break; } + sig->validity_reason = 0; + sig->chain_model = 0; if (*args) - sig->validity_reason = _gpgme_map_gnupg_error (args); - else - sig->validity_reason = 0; + { + sig->validity_reason = _gpgme_map_gnupg_error (args); + while (*args && *args != ' ') + args++; + if (*args) + { + while (*args == ' ') + args++; + if (!strncmp (args, "chain", 2) && (args[2] == ' ' || !args[2])) + sig->chain_model = 1; + } + } return 0; } diff -urpNP gpgme-1.1.5/gpgme/version.c gpgme-1.1.6/gpgme/version.c --- gpgme-1.1.5/gpgme/version.c 2007-01-17 15:55:32.000000000 +0000 +++ gpgme-1.1.6/gpgme/version.c 2007-10-04 11:06:47.000000000 +0000 @@ -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. @@ -25,9 +25,13 @@ #include #include #include +#ifdef HAVE_W32_SYSTEM +#include +#endif #include "gpgme.h" #include "priv-io.h" +#include "debug.h" /* For _gpgme_sema_subsystem_init (). */ #include "sema.h" @@ -41,7 +45,7 @@ must be done once at startup. We can not guarantee this using a lock, though, because the semaphore subsystem needs to be initialized itself before it can be used. So we expect that the - user performs the necessary syncrhonization. */ + user performs the necessary synchronization. */ static void do_subsystem_inits (void) { @@ -51,10 +55,20 @@ do_subsystem_inits (void) return; _gpgme_sema_subsystem_init (); - _gpgme_io_subsystem_init (); #ifdef HAVE_ASSUAN_H + assuan_set_assuan_log_level (0); assuan_set_assuan_err_source (GPG_ERR_SOURCE_GPGME); -#endif +#endif /*HAVE_ASSUAN_H*/ + _gpgme_debug_subsystem_init (); +#if defined(HAVE_W32_SYSTEM) && defined(HAVE_ASSUAN_H) + _gpgme_io_subsystem_init (); + /* We need to make sure that the sockets are initialized. */ + { + WSADATA wsadat; + + WSAStartup (0x202, &wsadat); + } +#endif /*HAVE_W32_SYSTEM && HAVE_ASSUAN_H*/ done = 1; } @@ -159,6 +173,14 @@ const char * gpgme_check_version (const char *req_version) { do_subsystem_inits (); + + /* Catch-22: We need to get at least the debug subsystem ready + before using the tarce facility. If we won't the tarce would + automagically initialize the debug system with out the locks + being initialized and missing the assuan log level setting. */ + TRACE2 (DEBUG_INIT, "gpgme_check_version: ", 0, + "req_version=%s, VERSION=%s", req_version, VERSION); + return _gpgme_compare_versions (VERSION, req_version) ? VERSION : NULL; } diff -urpNP gpgme-1.1.5/gpgme/w32-glib-io.c gpgme-1.1.6/gpgme/w32-glib-io.c --- gpgme-1.1.5/gpgme/w32-glib-io.c 2007-02-03 15:39:48.000000000 +0000 +++ gpgme-1.1.6/gpgme/w32-glib-io.c 2007-10-04 11:06:48.000000000 +0000 @@ -78,7 +78,27 @@ #define MAX_SLAFD 256 -GIOChannel *giochannel_table[MAX_SLAFD]; +static struct +{ + GIOChannel *chan; + /* The boolean PRIMARY is true if this file descriptor caused the + allocation of CHAN. Only then should CHAN be destroyed when this + FD is closed. This, together with the fact that dup'ed file + descriptors are closed before the file descriptors from which + they are dup'ed are closed, ensures that CHAN is always valid, + and shared among all file descriptors refering to the same + underlying object. + + The logic behind this is that there is only one reason for us to + dup file descriptors anyway: to allow simpler book-keeping of + file descriptors shared between GPGME and libassuan, which both + want to close something. Using the same channel for these + duplicates works just fine (and in fact, using different channels + does not work because the W32 backend in glib does not support + that: One would end up with several competing reader/writer + threads. */ + int primary; +} giochannel_table[MAX_SLAFD]; static GIOChannel * @@ -87,30 +107,42 @@ find_channel (int fd, int create) if (fd < 0 || fd >= MAX_SLAFD) return NULL; - if (create && !giochannel_table[fd]) + if (create && !giochannel_table[fd].chan) { - giochannel_table[fd] = g_io_channel_win32_new_fd (fd); - g_io_channel_set_encoding (giochannel_table[fd], NULL, NULL); - g_io_channel_set_buffered (giochannel_table[fd], FALSE); + giochannel_table[fd].chan = g_io_channel_win32_new_fd (fd); + giochannel_table[fd].primary = 1; + g_io_channel_set_encoding (giochannel_table[fd].chan, NULL, NULL); + g_io_channel_set_buffered (giochannel_table[fd].chan, FALSE); } - return giochannel_table[fd]; + return giochannel_table[fd].chan; } -/* Look up the giochannel for "file descriptor" FD. */ -GIOChannel * + +/* Compatibility interface. Obsolete. */ +void * gpgme_get_giochannel (int fd) { return find_channel (fd, 0); } +/* Look up the giochannel for "file descriptor" FD. */ +void * +gpgme_get_fdptr (int fd) +{ + return find_channel (fd, 0); +} + + /* Write the printable version of FD to the buffer BUF of length BUFLEN. The printable version is the representation on the command line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd) { + TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_fd2str", fd, "fd=%d", fd); + TRACE_SUC1 ("syshd=%p", _get_osfhandle (fd)); return snprintf (buf, buflen, "%ld", (long) _get_osfhandle (fd)); } @@ -123,10 +155,11 @@ _gpgme_io_subsystem_init (void) static struct { - void (*handler) (int,void*); + _gpgme_close_notify_handler_t handler; void *value; } notify_table[MAX_SLAFD]; + int _gpgme_io_read (int fd, void *buffer, size_t count) { @@ -134,17 +167,17 @@ _gpgme_io_read (int fd, void *buffer, si 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; @@ -152,7 +185,7 @@ _gpgme_io_read (int fd, void *buffer, si 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); } } @@ -161,17 +194,15 @@ _gpgme_io_read (int fd, void *buffer, si 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); } @@ -182,14 +213,14 @@ _gpgme_io_write (int fd, const void *buf 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; } @@ -201,9 +232,9 @@ _gpgme_io_write (int fd, const void *buf nwritten = -1; saved_errno = EIO; } - DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten); errno = saved_errno; - return nwritten; + + return TRACE_SYSRES (nwritten); } @@ -211,10 +242,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 ? "reading" : "writing"); #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) @@ -228,7 +262,7 @@ _gpgme_io_pipe (int filedes[2], int inhe if (new_read < 0) { _close (filedes[1]); - return -1; + return TRACE_SYSRES (-1); } } else if (inherit_idx == 1) @@ -242,7 +276,7 @@ _gpgme_io_pipe (int filedes[2], int inhe if (new_write < 0) { _close (filedes[0]); - return -1; + return TRACE_SYSRES (-1); } } @@ -251,34 +285,32 @@ _gpgme_io_pipe (int filedes[2], int inhe 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; } 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); @@ -287,32 +319,41 @@ _gpgme_io_close (int fd) } /* Then do the close. */ - chan = giochannel_table[fd]; - if (chan) + if (giochannel_table[fd].chan) { - g_io_channel_shutdown (chan, 1, NULL); - g_io_channel_unref (chan); - giochannel_table[fd] = NULL; + if (giochannel_table[fd].primary) + g_io_channel_shutdown (giochannel_table[fd].chan, 1, NULL); + else + _close (fd); + + g_io_channel_unref (giochannel_table[fd].chan); + giochannel_table[fd].chan = NULL; } else _close (fd); - + TRACE_SUC (); return 0; } int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_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); } @@ -322,12 +363,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, @@ -335,14 +377,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); } @@ -350,7 +396,6 @@ static char * build_commandline (char **argv) { int i; - int j; int n = 0; char *buf; char *p; @@ -403,158 +448,186 @@ build_commandline (char **argv) int -_gpgme_io_spawn ( const char *path, char **argv, - struct spawn_fd_item_s *fd_child_list, - struct spawn_fd_item_s *fd_parent_list ) -{ - SECURITY_ATTRIBUTES sec_attr; - PROCESS_INFORMATION pi = { - NULL, /* returns process handle */ - 0, /* returns primary thread handle */ - 0, /* returns pid */ - 0 /* returns tid */ +_gpgme_io_spawn (const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list) +{ + SECURITY_ATTRIBUTES sec_attr; + PROCESS_INFORMATION pi = + { + NULL, /* returns process handle */ + 0, /* returns primary thread handle */ + 0, /* returns pid */ + 0 /* returns tid */ }; - STARTUPINFO si; - char *envblock = NULL; - int cr_flags = CREATE_DEFAULT_ERROR_MODE - | GetPriorityClass (GetCurrentProcess ()); - int i; - char *arg_string; - int duped_stdin = 0; - int duped_stderr = 0; - HANDLE hnul = INVALID_HANDLE_VALUE; - /* FIXME. */ - int debug_me = 0; - - memset (&sec_attr, 0, sizeof sec_attr); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - arg_string = build_commandline (argv); - if (!arg_string ) - return -1; - - memset (&si, 0, sizeof si); - si.cb = sizeof (si); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = debug_me? SW_SHOW : SW_HIDE; - si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); - 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 ) { - si.hStdInput = (HANDLE) _get_osfhandle (fd_child_list[i].fd); - DEBUG2 ("using %d (%p) for stdin", fd_child_list[i].fd, - _get_osfhandle (fd_child_list[i].fd)); - duped_stdin=1; + STARTUPINFO si; + char *envblock = NULL; + int cr_flags = CREATE_DEFAULT_ERROR_MODE + | GetPriorityClass (GetCurrentProcess ()); + int i; + char *arg_string; + int duped_stdin = 0; + int duped_stderr = 0; + 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; + sec_attr.bInheritHandle = FALSE; + + arg_string = build_commandline (argv); + if (!arg_string) + return TRACE_SYSRES (-1); + + memset (&si, 0, sizeof si); + si.cb = sizeof (si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = debug_me? SW_SHOW : SW_HIDE; + si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); + 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) + { + si.hStdInput = (HANDLE) _get_osfhandle (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 ) { - si.hStdOutput = (HANDLE) _get_osfhandle (fd_child_list[i].fd); - DEBUG2 ("using %d (%p) for stdout", fd_child_list[i].fd, - _get_osfhandle (fd_child_list[i].fd)); + else if (fd_child_list[i].dup_to == 1) + { + si.hStdOutput = (HANDLE) _get_osfhandle (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) + { + si.hStdError = (HANDLE) _get_osfhandle (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; } - 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, - _get_osfhandle (fd_child_list[i].fd)); - duped_stderr = 1; + } + + if (!duped_stdin || !duped_stderr) + { + SECURITY_ATTRIBUTES sa; + + memset (&sa, 0, sizeof sa); + sa.nLength = sizeof sa; + sa.bInheritHandle = TRUE; + hnul = CreateFile ("nul", + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + &sa, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hnul == INVALID_HANDLE_VALUE) + { + TRACE_LOG1 ("CreateFile (\"nul\") failed: ec=%d", + (int) GetLastError ()); + free (arg_string); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } + /* Make sure that the process has a connected stdin. */ + if (!duped_stdin) + { + si.hStdInput = hnul; + TRACE_LOG1 ("using 0x%x for dummy stdin", (int) hnul); + } + /* We normally don't want all the normal output. */ + if (!duped_stderr) + { + si.hStdError = hnul; + TRACE_LOG1 ("using %d for dummy stderr", (int)hnul); + } } + + cr_flags |= CREATE_SUSPENDED; + cr_flags |= DETACHED_PROCESS; + if (!CreateProcessA (path, + arg_string, + &sec_attr, /* process security attributes */ + &sec_attr, /* thread security attributes */ + TRUE, /* inherit handles */ + cr_flags, /* creation flags */ + envblock, /* environment */ + NULL, /* use current drive/directory */ + &si, /* startup information */ + &pi)) /* returns process information */ + { + TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ()); + free (arg_string); + /* 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 (!CloseHandle (hnul)) + 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); + + 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) + TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ()); + + if (!CloseHandle (pi.hThread)) + TRACE_LOG1 ("CloseHandle of thread failed: ec=%d", + (int) GetLastError ()); - if( !duped_stdin || !duped_stderr ) { - SECURITY_ATTRIBUTES sa; + TRACE_SUC1 ("process=%p", pi.hProcess); - memset (&sa, 0, sizeof sa ); - sa.nLength = sizeof sa; - sa.bInheritHandle = TRUE; - hnul = CreateFile ( "nul", - GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - &sa, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL ); - if ( hnul == INVALID_HANDLE_VALUE ) { - DEBUG1 ("can't open `nul': ec=%d\n", (int)GetLastError ()); - free (arg_string); - return -1; - } - /* Make sure that the process has a connected stdin */ - if ( !duped_stdin ) { - si.hStdInput = hnul; - DEBUG1 ("using %d for dummy stdin", (int)hnul ); - } - /* We normally don't want all the normal output */ - if ( !duped_stderr ) { - si.hStdError = hnul; - DEBUG1 ("using %d for dummy stderr", (int)hnul ); - } - } + /* We don't need to wait for the process. */ + CloseHandle (pi.hProcess); - DEBUG2 ("CreateProcess, path=`%s' args=`%s'", path, arg_string); - cr_flags |= CREATE_SUSPENDED; - if ( !CreateProcessA (path, - arg_string, - &sec_attr, /* process security attributes */ - &sec_attr, /* thread security attributes */ - TRUE, /* inherit handles */ - cr_flags, /* creation flags */ - envblock, /* environment */ - NULL, /* use current drive/directory */ - &si, /* startup information */ - &pi /* returns process information */ - ) ) { - DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ()); - free (arg_string); - return -1; - } - - /* Close the /dev/nul handle if used. */ - if (hnul != INVALID_HANDLE_VALUE ) { - if ( !CloseHandle ( hnul ) ) - DEBUG1 ("CloseHandle(hnul) failed: ec=%d\n", (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", - pi.hProcess, pi.hThread, - (int) pi.dwProcessId, (int) pi.dwThreadId); - - if ( ResumeThread ( pi.hThread ) < 0 ) { - DEBUG1 ("ResumeThread failed: ec=%d\n", (int)GetLastError ()); - } - - if ( !CloseHandle (pi.hThread) ) { - DEBUG1 ("CloseHandle of thread failed: ec=%d\n", - (int)GetLastError ()); - } - - 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) { - int npollfds; + int npollfds; GPollFD *pollfds; - int *pollfds_map; - int i, j; - int any, n, count; - int timeout = 1000; /* Use a 1s timeout. */ + int *pollfds_map; + 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; @@ -570,37 +643,43 @@ _gpgme_io_select (struct io_select_fd_s } npollfds = 0; - DEBUG_BEGIN (dbg_help, 3, "gpgme:select on [ "); + TRACE_SEQ (dbg_help, "select on [ "); any = 0; for (i = 0; i < nfds; i++) { + GIOChannel *chan = NULL; + if (fds[i].fd == -1) continue; - if (fds[i].frozen) - DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd); + + if ((fds[i].for_read || fds[i].for_write) + && !(chan = find_channel (fds[i].fd, 0))) + { + TRACE_ADD1 (dbg_help, "[BAD0x%x ", fds[i].fd); + TRACE_END (dbg_help, "]"); + assert (!"see log file"); + } else if (fds[i].for_read ) { - GIOChannel *chan = find_channel (fds[i].fd, 0); - assert (chan); + 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; } else if (fds[i].for_write) { - GIOChannel *chan = find_channel (fds[i].fd, 0); - assert (chan); + 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; @@ -612,22 +691,21 @@ _gpgme_io_select (struct io_select_fd_s 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. */ @@ -658,5 +736,36 @@ _gpgme_io_select (struct io_select_fd_s leave: free (pollfds); free (pollfds_map); - return count; + return TRACE_SYSRES (count); +} + + +int +_gpgme_io_dup (int fd) +{ + int newfd; + GIOChannel *chan; + + TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_dup", fd, "dup (%d)", fd); + + newfd = _dup (fd); + if (newfd == -1) + return TRACE_SYSRES (-1); + if (newfd < 0 || newfd >= MAX_SLAFD) + { + /* New FD won't fit into our table. */ + _close (newfd); + errno = EIO; + return TRACE_SYSRES (-1); + } + assert (giochannel_table[newfd].chan == NULL); + + chan = find_channel (fd, 0); + assert (chan); + + g_io_channel_ref (chan); + giochannel_table[newfd].chan = chan; + giochannel_table[newfd].primary = 0; + + return TRACE_SYSRES (newfd); } diff -urpNP gpgme-1.1.5/gpgme/w32-io.c gpgme-1.1.6/gpgme/w32-io.c --- gpgme-1.1.5/gpgme/w32-io.c 2007-02-03 15:39:48.000000000 +0000 +++ gpgme-1.1.6/gpgme/w32-io.c 2007-10-04 11:06:48.000000000 +0000 @@ -1,6 +1,6 @@ /* w32-io.c - W32 API I/O 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. @@ -55,70 +55,81 @@ #define MAX_READERS 20 #define MAX_WRITERS 20 -static struct { - int inuse; - int fd; - void (*handler)(int,void*); - void *value; +static struct +{ + int inuse; + int fd; + _gpgme_close_notify_handler_t handler; + void *value; } notify_table[256]; DEFINE_STATIC_LOCK (notify_table_lock); -struct reader_context_s { - HANDLE file_hd; - HANDLE thread_hd; - DECLARE_LOCK (mutex); - - int stop_me; - int eof; - int eof_shortcut; - int error; - int error_code; - - HANDLE have_data_ev; /* manually reset */ - HANDLE have_space_ev; /* auto reset */ - HANDLE stopped; - size_t readpos, writepos; - char buffer[READBUF_SIZE]; +struct reader_context_s +{ + HANDLE file_hd; + HANDLE thread_hd; + int refcount; + + DECLARE_LOCK (mutex); + + int stop_me; + int eof; + int eof_shortcut; + int error; + int error_code; + + /* This is manually reset. */ + HANDLE have_data_ev; + /* This is automatically reset. */ + HANDLE have_space_ev; + HANDLE stopped; + size_t readpos, writepos; + char buffer[READBUF_SIZE]; }; -static struct { - volatile int used; - int fd; - struct reader_context_s *context; +static struct +{ + volatile int used; + int fd; + struct reader_context_s *context; } reader_table[MAX_READERS]; static int reader_table_size= MAX_READERS; DEFINE_STATIC_LOCK (reader_table_lock); -struct writer_context_s { - HANDLE file_hd; - HANDLE thread_hd; - DECLARE_LOCK (mutex); - - int stop_me; - int error; - int error_code; - - HANDLE have_data; /* manually reset */ - HANDLE is_empty; - HANDLE stopped; - size_t nbytes; - char buffer[WRITEBUF_SIZE]; +struct writer_context_s +{ + HANDLE file_hd; + HANDLE thread_hd; + int refcount; + + DECLARE_LOCK (mutex); + + int stop_me; + int error; + int error_code; + + /* This is manually reset. */ + HANDLE have_data; + HANDLE is_empty; + HANDLE stopped; + size_t nbytes; + char buffer[WRITEBUF_SIZE]; }; -static struct { - volatile int used; - int fd; - struct writer_context_s *context; +static struct +{ + volatile int used; + int fd; + struct writer_context_s *context; } writer_table[MAX_WRITERS]; static int writer_table_size= MAX_WRITERS; DEFINE_STATIC_LOCK (writer_table_lock); - static int get_desired_thread_priority (void) { @@ -127,674 +138,814 @@ get_desired_thread_priority (void) if (!_gpgme_get_conf_int ("IOThreadPriority", &value)) { value = THREAD_PRIORITY_HIGHEST; - DEBUG1 ("** Using standard IOThreadPriority of %d\n", value); + TRACE1 (DEBUG_SYSIO, "gpgme:get_desired_thread_priority", 0, + "%d (default)", value); } else - DEBUG1 ("** Configured IOThreadPriority is %d\n", value); - + { + TRACE1 (DEBUG_SYSIO, "gpgme:get_desired_thread_priority", 0, + "%d (configured)", value); + } return value; } static HANDLE -set_synchronize (HANDLE h) +set_synchronize (HANDLE hd) { - HANDLE tmp; - - /* For NT we have to set the sync flag. It seems that the only - * way to do it is by duplicating the handle. Tsss.. */ - if (!DuplicateHandle( GetCurrentProcess(), h, - GetCurrentProcess(), &tmp, - EVENT_MODIFY_STATE|SYNCHRONIZE, FALSE, 0 ) ) { - DEBUG1 ("** Set SYNCRONIZE failed: ec=%d\n", (int)GetLastError()); - } - else { - CloseHandle (h); - h = tmp; + HANDLE new_hd; + + /* For NT we have to set the sync flag. It seems that the only way + to do it is by duplicating the handle. Tsss... */ + if (!DuplicateHandle (GetCurrentProcess (), hd, + GetCurrentProcess (), &new_hd, + EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, 0)) + { + TRACE1 (DEBUG_SYSIO, "gpgme:set_synchronize", hd, + "DuplicateHandle failed: ec=%d", (int) GetLastError ()); + /* FIXME: Should translate the error code. */ + errno = EIO; + return INVALID_HANDLE_VALUE; } - return h; -} + CloseHandle (hd); + return new_hd; +} static DWORD CALLBACK reader (void *arg) { - struct reader_context_s *c = arg; - int nbytes; - DWORD nread; - - DEBUG2 ("reader thread %p for file %p started", c->thread_hd, c->file_hd ); - for (;;) { - LOCK (c->mutex); - /* leave a 1 byte gap so that we can see whether it is empty or full*/ - if ((c->writepos + 1) % READBUF_SIZE == c->readpos) { - /* wait for space */ - if (!ResetEvent (c->have_space_ev) ) - DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - DEBUG1 ("reader thread %p: waiting for space ...", c->thread_hd ); - WaitForSingleObject (c->have_space_ev, INFINITE); - DEBUG1 ("reader thread %p: got space", c->thread_hd ); - LOCK (c->mutex); + struct reader_context_s *ctx = arg; + int nbytes; + DWORD nread; + TRACE_BEG1 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd, + "thread=%p", ctx->thread_hd); + + for (;;) + { + LOCK (ctx->mutex); + /* Leave a 1 byte gap so that we can see whether it is empty or + full. */ + if ((ctx->writepos + 1) % READBUF_SIZE == ctx->readpos) + { + /* Wait for space. */ + if (!ResetEvent (ctx->have_space_ev)) + TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + TRACE_LOG ("waiting for space"); + WaitForSingleObject (ctx->have_space_ev, INFINITE); + TRACE_LOG ("got space"); + LOCK (ctx->mutex); } - if ( c->stop_me ) { - UNLOCK (c->mutex); - break; + if (ctx->stop_me) + { + UNLOCK (ctx->mutex); + break; } - nbytes = (c->readpos + READBUF_SIZE - c->writepos-1) % READBUF_SIZE; - if ( nbytes > READBUF_SIZE - c->writepos ) - nbytes = READBUF_SIZE - c->writepos; - UNLOCK (c->mutex); - - DEBUG2 ("reader thread %p: reading %d bytes", c->thread_hd, nbytes ); - if ( !ReadFile ( c->file_hd, - c->buffer+c->writepos, nbytes, &nread, NULL) ) { - c->error_code = (int)GetLastError (); - if (c->error_code == ERROR_BROKEN_PIPE ) { - c->eof=1; - DEBUG1 ("reader thread %p: got eof (broken pipe)", - c->thread_hd ); + nbytes = (ctx->readpos + READBUF_SIZE + - ctx->writepos - 1) % READBUF_SIZE; + if (nbytes > READBUF_SIZE - ctx->writepos) + nbytes = READBUF_SIZE - ctx->writepos; + UNLOCK (ctx->mutex); + + TRACE_LOG1 ("reading %d bytes", nbytes); + if (!ReadFile (ctx->file_hd, + ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) + { + ctx->error_code = (int) GetLastError (); + if (ctx->error_code == ERROR_BROKEN_PIPE) + { + ctx->eof = 1; + TRACE_LOG ("got EOF (broken pipe)"); } - else { - c->error = 1; - DEBUG2 ("reader thread %p: read error: ec=%d", - c->thread_hd, c->error_code ); + else + { + ctx->error = 1; + TRACE_LOG1 ("read error: ec=%d", ctx->error_code); } - break; + break; } - if ( !nread ) { - c->eof = 1; - DEBUG1 ("reader thread %p: got eof", c->thread_hd ); - break; + if (!nread) + { + ctx->eof = 1; + TRACE_LOG ("got eof"); + break; } - DEBUG2 ("reader thread %p: got %d bytes", c->thread_hd, (int)nread ); + TRACE_LOG1 ("got %u bytes", nread); - LOCK (c->mutex); - if (c->stop_me) { - UNLOCK (c->mutex); - break; + LOCK (ctx->mutex); + if (ctx->stop_me) + { + UNLOCK (ctx->mutex); + break; } - c->writepos = (c->writepos + nread) % READBUF_SIZE; - if ( !SetEvent (c->have_data_ev) ) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - } - /* indicate that we have an error or eof */ - if ( !SetEvent (c->have_data_ev) ) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - DEBUG1 ("reader thread %p ended", c->thread_hd ); - SetEvent (c->stopped); - - return 0; + ctx->writepos = (ctx->writepos + nread) % READBUF_SIZE; + if (!SetEvent (ctx->have_data_ev)) + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + } + /* Indicate that we have an error or EOF. */ + if (!SetEvent (ctx->have_data_ev)) + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + SetEvent (ctx->stopped); + + return TRACE_SUC (); } static struct reader_context_s * create_reader (HANDLE fd) { - struct reader_context_s *c; - SECURITY_ATTRIBUTES sec_attr; - DWORD tid; - - DEBUG1 ("creating new read thread for file handle %p", fd ); - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - c = calloc (1, sizeof *c ); - if (!c) - return NULL; - - c->file_hd = fd; - c->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL); - c->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL); - c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); - if (!c->have_data_ev || !c->have_space_ev || !c->stopped ) { - DEBUG1 ("** CreateEvent failed: ec=%d\n", (int)GetLastError ()); - if (c->have_data_ev) - CloseHandle (c->have_data_ev); - if (c->have_space_ev) - CloseHandle (c->have_space_ev); - if (c->stopped) - CloseHandle (c->stopped); - free (c); - return NULL; - } - - c->have_data_ev = set_synchronize (c->have_data_ev); - INIT_LOCK (c->mutex); - - c->thread_hd = CreateThread (&sec_attr, 0, reader, c, 0, &tid ); - if (!c->thread_hd) { - DEBUG1 ("** failed to create reader thread: ec=%d\n", - (int)GetLastError ()); - DESTROY_LOCK (c->mutex); - if (c->have_data_ev) - CloseHandle (c->have_data_ev); - if (c->have_space_ev) - CloseHandle (c->have_space_ev); - if (c->stopped) - CloseHandle (c->stopped); - free (c); - return NULL; + struct reader_context_s *ctx; + SECURITY_ATTRIBUTES sec_attr; + DWORD tid; + + TRACE_BEG (DEBUG_SYSIO, "gpgme:create_reader", fd); + + memset (&sec_attr, 0, sizeof sec_attr); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + ctx = calloc (1, sizeof *ctx); + if (!ctx) + { + TRACE_SYSERR (errno); + return NULL; + } + + ctx->file_hd = fd; + ctx->refcount = 1; + ctx->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (ctx->have_data_ev) + ctx->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL); + if (ctx->have_space_ev) + ctx->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (!ctx->have_data_ev || !ctx->have_space_ev || !ctx->stopped) + { + TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ()); + if (ctx->have_data_ev) + CloseHandle (ctx->have_data_ev); + if (ctx->have_space_ev) + CloseHandle (ctx->have_space_ev); + if (ctx->stopped) + CloseHandle (ctx->stopped); + free (ctx); + /* FIXME: Translate the error code. */ + TRACE_SYSERR (EIO); + return NULL; + } + + ctx->have_data_ev = set_synchronize (ctx->have_data_ev); + INIT_LOCK (ctx->mutex); + + ctx->thread_hd = CreateThread (&sec_attr, 0, reader, ctx, 0, &tid); + if (!ctx->thread_hd) + { + TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); + DESTROY_LOCK (ctx->mutex); + if (ctx->have_data_ev) + CloseHandle (ctx->have_data_ev); + if (ctx->have_space_ev) + CloseHandle (ctx->have_space_ev); + if (ctx->stopped) + CloseHandle (ctx->stopped); + free (ctx); + TRACE_SYSERR (EIO); + return NULL; } - else { + else + { /* We set the priority of the thread higher because we know that - it only runs for a short time. This greatly helps to increase - the performance of the I/O. */ - SetThreadPriority (c->thread_hd, get_desired_thread_priority ()); + it only runs for a short time. This greatly helps to + increase the performance of the I/O. */ + SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ()); } - return c; + TRACE_SUC (); + return ctx; } + static void -destroy_reader (struct reader_context_s *c) +destroy_reader (struct reader_context_s *ctx) { - LOCK (c->mutex); - c->stop_me = 1; - if (c->have_space_ev) - SetEvent (c->have_space_ev); - UNLOCK (c->mutex); - - DEBUG1 ("waiting for thread %p termination ...", c->thread_hd ); - WaitForSingleObject (c->stopped, INFINITE); - DEBUG1 ("thread %p has terminated", c->thread_hd ); + LOCK (ctx->mutex); + ctx->refcount--; + if (ctx->refcount != 0) + { + UNLOCK (ctx->mutex); + return; + } + ctx->stop_me = 1; + if (ctx->have_space_ev) + SetEvent (ctx->have_space_ev); + UNLOCK (ctx->mutex); + + TRACE1 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd, + "waiting for termination of thread %p", ctx->thread_hd); + WaitForSingleObject (ctx->stopped, INFINITE); + TRACE1 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd, + "thread %p has terminated", ctx->thread_hd); - if (c->stopped) - CloseHandle (c->stopped); - if (c->have_data_ev) - CloseHandle (c->have_data_ev); - if (c->have_space_ev) - CloseHandle (c->have_space_ev); - CloseHandle (c->thread_hd); - DESTROY_LOCK (c->mutex); - free (c); + if (ctx->stopped) + CloseHandle (ctx->stopped); + if (ctx->have_data_ev) + CloseHandle (ctx->have_data_ev); + if (ctx->have_space_ev) + CloseHandle (ctx->have_space_ev); + CloseHandle (ctx->thread_hd); + DESTROY_LOCK (ctx->mutex); + free (ctx); } -/* - * Find a reader context or create a new one - * Note that the reader context will last until a io_close. - */ +/* Find a reader context or create a new one. Note that the reader + context will last until a _gpgme_io_close. */ static struct reader_context_s * find_reader (int fd, int start_it) { - int i; + struct reader_context_s *rd = NULL; + int i; - for (i=0; i < reader_table_size ; i++ ) { - if ( reader_table[i].used && reader_table[i].fd == fd ) - return reader_table[i].context; - } - if (!start_it) - return NULL; - - LOCK (reader_table_lock); - for (i=0; i < reader_table_size; i++ ) { - if (!reader_table[i].used) { - reader_table[i].fd = fd; - reader_table[i].context = create_reader (fd_to_handle (fd)); - reader_table[i].used = 1; - UNLOCK (reader_table_lock); - return reader_table[i].context; - } + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + if (reader_table[i].used && reader_table[i].fd == fd) + rd = reader_table[i].context; + + if (rd || !start_it) + { + UNLOCK (reader_table_lock); + return rd; } - UNLOCK (reader_table_lock); - return NULL; + + for (i = 0; i < reader_table_size; i++) + if (!reader_table[i].used) + break; + + if (i != reader_table_size) + { + rd = create_reader (fd_to_handle (fd)); + reader_table[i].fd = fd; + reader_table[i].context = rd; + reader_table[i].used = 1; + } + + UNLOCK (reader_table_lock); + return rd; } static void kill_reader (int fd) { - int i; + int i; - LOCK (reader_table_lock); - for (i=0; i < reader_table_size; i++ ) { - if (reader_table[i].used && reader_table[i].fd == fd ) { - destroy_reader (reader_table[i].context); - reader_table[i].context = NULL; - reader_table[i].used = 0; - break; - } + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + { + if (reader_table[i].used && reader_table[i].fd == fd) + { + destroy_reader (reader_table[i].context); + reader_table[i].context = NULL; + reader_table[i].used = 0; + break; + } } - UNLOCK (reader_table_lock); + UNLOCK (reader_table_lock); } - int -_gpgme_io_read ( int fd, void *buffer, size_t count ) +_gpgme_io_read (int fd, void *buffer, size_t count) { - int nread; - struct reader_context_s *c = find_reader (fd,1); + int nread; + struct reader_context_s *ctx; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd, + "buffer=%p, count=%u", buffer, count); + + ctx = find_reader (fd, 1); + if (!ctx) + { + errno = EBADF; + return TRACE_SYSRES (-1); + } + if (ctx->eof_shortcut) + return TRACE_SYSRES (0); - DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int)count ); - if ( !c ) { - DEBUG0 ( "no reader thread\n"); - return -1; - } - if (c->eof_shortcut) { - DEBUG1 ("fd %d: EOF (again)", fd ); - return 0; - } - - LOCK (c->mutex); - if (c->readpos == c->writepos && !c->error) { /*no data avail*/ - UNLOCK (c->mutex); - DEBUG2 ("fd %d: waiting for data from thread %p", fd, c->thread_hd); - WaitForSingleObject (c->have_data_ev, INFINITE); - DEBUG2 ("fd %d: data from thread %p available", fd, c->thread_hd); - LOCK (c->mutex); + LOCK (ctx->mutex); + if (ctx->readpos == ctx->writepos && !ctx->error) + { + /* No data available. */ + UNLOCK (ctx->mutex); + TRACE_LOG1 ("waiting for data from thread %p", ctx->thread_hd); + WaitForSingleObject (ctx->have_data_ev, INFINITE); + TRACE_LOG1 ("data from thread %p available", ctx->thread_hd); + LOCK (ctx->mutex); } - - if (c->readpos == c->writepos || c->error) { - UNLOCK (c->mutex); - c->eof_shortcut = 1; - if (c->eof) { - DEBUG1 ("fd %d: EOF", fd ); - return 0; - } - if (!c->error) { - DEBUG1 ("fd %d: EOF but eof flag not set", fd ); - return 0; - } - DEBUG1 ("fd %d: read error", fd ); - return -1; + + if (ctx->readpos == ctx->writepos || ctx->error) + { + UNLOCK (ctx->mutex); + ctx->eof_shortcut = 1; + if (ctx->eof) + return TRACE_SYSRES (0); + if (!ctx->error) + { + TRACE_LOG ("EOF but ctx->eof flag not set"); + return 0; + } + errno = ctx->error_code; + return TRACE_SYSRES (-1); } - - nread = c->readpos < c->writepos? c->writepos - c->readpos - : READBUF_SIZE - c->readpos; - if (nread > count) - nread = count; - memcpy (buffer, c->buffer+c->readpos, nread); - c->readpos = (c->readpos + nread) % READBUF_SIZE; - if (c->readpos == c->writepos && !c->eof) { - if ( !ResetEvent (c->have_data_ev) ) - DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); - } - if (!SetEvent (c->have_space_ev)) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - - DEBUG2 ("fd %d: got %d bytes\n", fd, nread ); - if (nread > 0) - _gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer); - - return nread; -} -/* - * The writer does use a simple buffering strategy so that we are - * informed about write errors as soon as possible (i.e. with the the - * next call to the write function - */ + + nread = ctx->readpos < ctx->writepos + ? ctx->writepos - ctx->readpos + : READBUF_SIZE - ctx->readpos; + if (nread > count) + nread = count; + memcpy (buffer, ctx->buffer + ctx->readpos, nread); + ctx->readpos = (ctx->readpos + nread) % READBUF_SIZE; + if (ctx->readpos == ctx->writepos && !ctx->eof) + { + if (!ResetEvent (ctx->have_data_ev)) + { + TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + } + if (!SetEvent (ctx->have_space_ev)) + { + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + UNLOCK (ctx->mutex); + + TRACE_LOGBUF (buffer, nread); + return TRACE_SYSRES (nread); +} + + +/* The writer does use a simple buffering strategy so that we are + informed about write errors as soon as possible (i. e. with the the + next call to the write function. */ static DWORD CALLBACK writer (void *arg) { - struct writer_context_s *c = arg; - DWORD nwritten; + struct writer_context_s *ctx = arg; + DWORD nwritten; + TRACE_BEG1 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd, + "thread=%p", ctx->thread_hd); - DEBUG2 ("writer thread %p for file %p started", c->thread_hd, c->file_hd ); - for (;;) { - LOCK (c->mutex); - if ( c->stop_me ) { - UNLOCK (c->mutex); - break; + for (;;) + { + LOCK (ctx->mutex); + if (ctx->stop_me) + { + UNLOCK (ctx->mutex); + break; } - if ( !c->nbytes ) { - if (!SetEvent (c->is_empty)) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - if (!ResetEvent (c->have_data) ) - DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - DEBUG1 ("writer thread %p: idle ...", c->thread_hd ); - WaitForSingleObject (c->have_data, INFINITE); - DEBUG1 ("writer thread %p: got data to send", c->thread_hd ); - LOCK (c->mutex); + if (!ctx->nbytes) + { + if (!SetEvent (ctx->is_empty)) + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + if (!ResetEvent (ctx->have_data)) + TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + TRACE_LOG ("idle"); + WaitForSingleObject (ctx->have_data, INFINITE); + TRACE_LOG ("got data to send"); + LOCK (ctx->mutex); } - if ( c->stop_me ) { - UNLOCK (c->mutex); - break; - } - UNLOCK (c->mutex); - - DEBUG2 ("writer thread %p: writing %d bytes", - c->thread_hd, c->nbytes ); - if ( c->nbytes && !WriteFile ( c->file_hd, c->buffer, c->nbytes, - &nwritten, NULL)) { - c->error_code = (int)GetLastError (); - c->error = 1; - DEBUG2 ("writer thread %p: write error: ec=%d", - c->thread_hd, c->error_code ); - break; + if (ctx->stop_me) + { + UNLOCK (ctx->mutex); + break; } - DEBUG2 ("writer thread %p: wrote %d bytes", - c->thread_hd, (int)nwritten ); + UNLOCK (ctx->mutex); - LOCK (c->mutex); - c->nbytes -= nwritten; - UNLOCK (c->mutex); - } - /* indicate that we have an error */ - if ( !SetEvent (c->is_empty) ) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - DEBUG1 ("writer thread %p ended", c->thread_hd ); - SetEvent (c->stopped); + TRACE_LOG1 ("writing %d bytes", ctx->nbytes); + /* Note that CTX->nbytes is not zero at this point, because + _gpgme_io_write always writes at least 1 byte before waking + us up, unless CTX->stop_me is true, which we catch above. */ + if (!WriteFile (ctx->file_hd, ctx->buffer, + ctx->nbytes, &nwritten, NULL)) + { + ctx->error_code = (int) GetLastError (); + ctx->error = 1; + TRACE_LOG1 ("write error: ec=%d", ctx->error_code); + break; + } + TRACE_LOG1 ("wrote %d bytes", (int) nwritten); + + LOCK (ctx->mutex); + ctx->nbytes -= nwritten; + UNLOCK (ctx->mutex); + } + /* Indicate that we have an error. */ + if (!SetEvent (ctx->is_empty)) + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + SetEvent (ctx->stopped); - return 0; + return TRACE_SUC (); } static struct writer_context_s * create_writer (HANDLE fd) { - struct writer_context_s *c; - SECURITY_ATTRIBUTES sec_attr; - DWORD tid; - - DEBUG1 ("creating new write thread for file handle %p", fd ); - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - c = calloc (1, sizeof *c ); - if (!c) - return NULL; - - c->file_hd = fd; - c->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL); - c->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL); - c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); - if (!c->have_data || !c->is_empty || !c->stopped ) { - DEBUG1 ("** CreateEvent failed: ec=%d\n", (int)GetLastError ()); - if (c->have_data) - CloseHandle (c->have_data); - if (c->is_empty) - CloseHandle (c->is_empty); - if (c->stopped) - CloseHandle (c->stopped); - free (c); - return NULL; - } - - c->is_empty = set_synchronize (c->is_empty); - INIT_LOCK (c->mutex); - - c->thread_hd = CreateThread (&sec_attr, 0, writer, c, 0, &tid ); - if (!c->thread_hd) { - DEBUG1 ("** failed to create writer thread: ec=%d\n", - (int)GetLastError ()); - DESTROY_LOCK (c->mutex); - if (c->have_data) - CloseHandle (c->have_data); - if (c->is_empty) - CloseHandle (c->is_empty); - if (c->stopped) - CloseHandle (c->stopped); - free (c); - return NULL; + struct writer_context_s *ctx; + SECURITY_ATTRIBUTES sec_attr; + DWORD tid; + + TRACE_BEG (DEBUG_SYSIO, "gpgme:create_writer", fd); + + memset (&sec_attr, 0, sizeof sec_attr); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + ctx = calloc (1, sizeof *ctx); + if (!ctx) + { + TRACE_SYSERR (errno); + return NULL; + } + + ctx->file_hd = fd; + ctx->refcount = 1; + ctx->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (ctx->have_data) + ctx->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL); + if (ctx->is_empty) + ctx->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (!ctx->have_data || !ctx->is_empty || !ctx->stopped) + { + TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ()); + if (ctx->have_data) + CloseHandle (ctx->have_data); + if (ctx->is_empty) + CloseHandle (ctx->is_empty); + if (ctx->stopped) + CloseHandle (ctx->stopped); + free (ctx); + /* FIXME: Translate the error code. */ + TRACE_SYSERR (EIO); + return NULL; + } + + ctx->is_empty = set_synchronize (ctx->is_empty); + INIT_LOCK (ctx->mutex); + + ctx->thread_hd = CreateThread (&sec_attr, 0, writer, ctx, 0, &tid ); + if (!ctx->thread_hd) + { + TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); + DESTROY_LOCK (ctx->mutex); + if (ctx->have_data) + CloseHandle (ctx->have_data); + if (ctx->is_empty) + CloseHandle (ctx->is_empty); + if (ctx->stopped) + CloseHandle (ctx->stopped); + free (ctx); + TRACE_SYSERR (EIO); + return NULL; } - else { - /* We set the priority of the thread higher because we know that - it only runs for a short time. This greatly helps to increase - the performance of the I/O. */ - SetThreadPriority (c->thread_hd, get_desired_thread_priority ()); + else + { + /* We set the priority of the thread higher because we know + that it only runs for a short time. This greatly helps to + increase the performance of the I/O. */ + SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ()); } - return c; + TRACE_SUC (); + return ctx; } static void -destroy_writer (struct writer_context_s *c) +destroy_writer (struct writer_context_s *ctx) { - LOCK (c->mutex); - c->stop_me = 1; - if (c->have_data) - SetEvent (c->have_data); - UNLOCK (c->mutex); - - DEBUG1 ("waiting for thread %p termination ...", c->thread_hd ); - WaitForSingleObject (c->stopped, INFINITE); - DEBUG1 ("thread %p has terminated", c->thread_hd ); - - if (c->stopped) - CloseHandle (c->stopped); - if (c->have_data) - CloseHandle (c->have_data); - if (c->is_empty) - CloseHandle (c->is_empty); - CloseHandle (c->thread_hd); - DESTROY_LOCK (c->mutex); - free (c); + LOCK (ctx->mutex); + ctx->refcount--; + if (ctx->refcount != 0) + { + UNLOCK (ctx->mutex); + return; + } + ctx->stop_me = 1; + if (ctx->have_data) + SetEvent (ctx->have_data); + UNLOCK (ctx->mutex); + + TRACE1 (DEBUG_SYSIO, "gpgme:destroy_writer", ctx->file_hd, + "waiting for termination of thread %p", ctx->thread_hd); + WaitForSingleObject (ctx->stopped, INFINITE); + TRACE1 (DEBUG_SYSIO, "gpgme:destroy_writer", ctx->file_hd, + "thread %p has terminated", ctx->thread_hd); + + if (ctx->stopped) + CloseHandle (ctx->stopped); + if (ctx->have_data) + CloseHandle (ctx->have_data); + if (ctx->is_empty) + CloseHandle (ctx->is_empty); + CloseHandle (ctx->thread_hd); + DESTROY_LOCK (ctx->mutex); + free (ctx); } -/* - * Find a writer context or create a new one - * Note that the writer context will last until a io_close. - */ +/* Find a writer context or create a new one. Note that the writer + context will last until a _gpgme_io_close. */ static struct writer_context_s * find_writer (int fd, int start_it) { - int i; + struct writer_context_s *wt = NULL; + int i; - for (i=0; i < writer_table_size ; i++ ) { - if ( writer_table[i].used && writer_table[i].fd == fd ) - return writer_table[i].context; - } - if (!start_it) - return NULL; - - LOCK (writer_table_lock); - for (i=0; i < writer_table_size; i++ ) { - if (!writer_table[i].used) { - writer_table[i].fd = fd; - writer_table[i].context = create_writer (fd_to_handle (fd)); - writer_table[i].used = 1; - UNLOCK (writer_table_lock); - return writer_table[i].context; - } + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + if (writer_table[i].used && writer_table[i].fd == fd) + wt = writer_table[i].context; + + if (wt || !start_it) + { + UNLOCK (writer_table_lock); + return wt; } - UNLOCK (writer_table_lock); - return NULL; + + for (i = 0; i < writer_table_size; i++) + if (!writer_table[i].used) + break; + + if (i != writer_table_size) + { + wt = create_writer (fd_to_handle (fd)); + writer_table[i].fd = fd; + writer_table[i].context = wt; + writer_table[i].used = 1; + } + + UNLOCK (writer_table_lock); + return wt; } static void kill_writer (int fd) { - int i; + int i; - LOCK (writer_table_lock); - for (i=0; i < writer_table_size; i++ ) { - if (writer_table[i].used && writer_table[i].fd == fd ) { - destroy_writer (writer_table[i].context); - writer_table[i].context = NULL; - writer_table[i].used = 0; - break; - } + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + { + if (writer_table[i].used && writer_table[i].fd == fd) + { + destroy_writer (writer_table[i].context); + writer_table[i].context = NULL; + writer_table[i].used = 0; + break; + } } - UNLOCK (writer_table_lock); + UNLOCK (writer_table_lock); } - - int -_gpgme_io_write ( int fd, const void *buffer, size_t count ) +_gpgme_io_write (int fd, const void *buffer, size_t count) { - struct writer_context_s *c = find_writer (fd,1); + struct writer_context_s *ctx; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd, + "buffer=%p, count=%u", buffer, count); + TRACE_LOGBUF (buffer, count); + + if (count == 0) + return TRACE_SYSRES (0); + + ctx = find_writer (fd, 1); + if (!ctx) + return TRACE_SYSRES (-1); + + LOCK (ctx->mutex); + if (!ctx->error && ctx->nbytes) + { + /* Bytes are pending for send. */ - DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int)count ); - _gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer); - if ( !c ) { - DEBUG0 ( "no writer thread\n"); - return -1; - } - - LOCK (c->mutex); - if ( c->nbytes ) { /* bytes are pending for send */ - /* Reset the is_empty event. Better safe than sorry. */ - if (!ResetEvent (c->is_empty)) - DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - DEBUG2 ("fd %d: waiting for empty buffer in thread %p", - fd, c->thread_hd); - WaitForSingleObject (c->is_empty, INFINITE); - DEBUG2 ("fd %d: thread %p buffer is empty", fd, c->thread_hd); - LOCK (c->mutex); + /* Reset the is_empty event. Better safe than sorry. */ + if (!ResetEvent (ctx->is_empty)) + { + TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + UNLOCK (ctx->mutex); + TRACE_LOG1 ("waiting for empty buffer in thread %p", ctx->thread_hd); + WaitForSingleObject (ctx->is_empty, INFINITE); + TRACE_LOG1 ("thread %p buffer is empty", ctx->thread_hd); + LOCK (ctx->mutex); } - - if ( c->error) { - UNLOCK (c->mutex); - DEBUG1 ("fd %d: write error", fd ); - return -1; - } - - /* If no error occured, the number of bytes in the buffer must be - zero. */ - assert (!c->nbytes); - - if (count > WRITEBUF_SIZE) - count = WRITEBUF_SIZE; - memcpy (c->buffer, buffer, count); - c->nbytes = count; - - /* We have to reset the is_empty event early, because it is also - used by the select() implementation to probe the channel. */ - if (!ResetEvent (c->is_empty)) - DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); - if (!SetEvent (c->have_data)) - DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); - UNLOCK (c->mutex); - - DEBUG2 ("fd %d: copied %d bytes\n", - fd, (int)count ); - return (int)count; + + if (ctx->error) + { + UNLOCK (ctx->mutex); + if (ctx->error_code == ERROR_NO_DATA) + errno = EPIPE; + else + errno = EIO; + return TRACE_SYSRES (-1); + } + + /* If no error occured, the number of bytes in the buffer must be + zero. */ + assert (!ctx->nbytes); + + if (count > WRITEBUF_SIZE) + count = WRITEBUF_SIZE; + memcpy (ctx->buffer, buffer, count); + ctx->nbytes = count; + + /* We have to reset the is_empty event early, because it is also + used by the select() implementation to probe the channel. */ + if (!ResetEvent (ctx->is_empty)) + { + TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + if (!SetEvent (ctx->have_data)) + { + TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); + UNLOCK (ctx->mutex); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + UNLOCK (ctx->mutex); + + return TRACE_SYSRES ((int) count); } int -_gpgme_io_pipe ( int filedes[2], int inherit_idx ) +_gpgme_io_pipe (int filedes[2], int inherit_idx) { - HANDLE r, w; - SECURITY_ATTRIBUTES sec_attr; + HANDLE rh; + HANDLE wh; + SECURITY_ATTRIBUTES sec_attr; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, + "inherit_idx=%i (GPGME uses it for %s)", + inherit_idx, inherit_idx ? "reading" : "writing"); + + memset (&sec_attr, 0, sizeof (sec_attr)); + sec_attr.nLength = sizeof (sec_attr); + sec_attr.bInheritHandle = FALSE; + + if (!CreatePipe (&rh, &wh, &sec_attr, PIPEBUF_SIZE)) + { + TRACE_LOG1 ("CreatePipe failed: ec=%d", (int) GetLastError ()); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - if (!CreatePipe ( &r, &w, &sec_attr, PIPEBUF_SIZE)) - return -1; - /* Make one end inheritable. */ - if ( inherit_idx == 0 ) { - HANDLE h; - if (!DuplicateHandle( GetCurrentProcess(), r, - GetCurrentProcess(), &h, 0, - TRUE, DUPLICATE_SAME_ACCESS ) ) { - DEBUG1 ("DuplicateHandle failed: ec=%d\n", (int)GetLastError()); - CloseHandle (r); - CloseHandle (w); - return -1; + /* Make one end inheritable. */ + if (inherit_idx == 0) + { + HANDLE hd; + if (!DuplicateHandle (GetCurrentProcess(), rh, + GetCurrentProcess(), &hd, 0, + TRUE, DUPLICATE_SAME_ACCESS)) + { + TRACE_LOG1 ("DuplicateHandle failed: ec=%d", + (int) GetLastError ()); + CloseHandle (rh); + CloseHandle (wh); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - CloseHandle (r); - r = h; + CloseHandle (rh); + rh = hd; } - else if ( inherit_idx == 1 ) { - HANDLE h; - if (!DuplicateHandle( GetCurrentProcess(), w, - GetCurrentProcess(), &h, 0, - TRUE, DUPLICATE_SAME_ACCESS ) ) { - DEBUG1 ("DuplicateHandle failed: ec=%d\n", (int)GetLastError()); - CloseHandle (r); - CloseHandle (w); - return -1; + else if (inherit_idx == 1) + { + HANDLE hd; + if (!DuplicateHandle( GetCurrentProcess(), wh, + GetCurrentProcess(), &hd, 0, + TRUE, DUPLICATE_SAME_ACCESS)) + { + TRACE_LOG1 ("DuplicateHandle failed: ec=%d", + (int) GetLastError ()); + CloseHandle (rh); + CloseHandle (wh); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - CloseHandle (w); - w = h; + CloseHandle (wh); + wh = hd; } - - filedes[0] = handle_to_fd (r); - filedes[1] = handle_to_fd (w); - DEBUG5 ("CreatePipe %p %p %d %d inherit=%d\n", r, w, - filedes[0], filedes[1], inherit_idx ); - return 0; + + filedes[0] = handle_to_fd (rh); + filedes[1] = handle_to_fd (wh); + return TRACE_SUC2 ("read=%p, write=%p", rh, wh); } + int -_gpgme_io_close ( int fd ) +_gpgme_io_close (int fd) { - int i; - void (*handler)(int, void*) = NULL; - void *value = NULL; - - if ( fd == -1 ) - return -1; - - DEBUG1 ("** closing handle for fd %d\n", fd); - kill_reader (fd); - kill_writer (fd); - LOCK (notify_table_lock); - for ( i=0; i < DIM (notify_table); i++ ) { - if (notify_table[i].inuse && notify_table[i].fd == fd) { - handler = notify_table[i].handler; - value = notify_table[i].value; - notify_table[i].handler = NULL; - notify_table[i].value = NULL; - notify_table[i].inuse = 0; - break; - } + int i; + _gpgme_close_notify_handler_t handler = NULL; + void *value = NULL; + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd); + + if (fd == -1) + { + errno = EBADF; + return TRACE_SYSRES (-1); } - UNLOCK (notify_table_lock); - if (handler) - handler (fd, value); - if ( !CloseHandle (fd_to_handle (fd)) ) { - DEBUG2 ("CloseHandle for fd %d failed: ec=%d\n", - fd, (int)GetLastError ()); - return -1; + kill_reader (fd); + kill_writer (fd); + LOCK (notify_table_lock); + for (i = 0; i < DIM (notify_table); i++) + { + if (notify_table[i].inuse && notify_table[i].fd == fd) + { + handler = notify_table[i].handler; + value = notify_table[i].value; + notify_table[i].handler = NULL; + notify_table[i].value = NULL; + notify_table[i].inuse = 0; + break; + } + } + UNLOCK (notify_table_lock); + if (handler) + handler (fd, value); + + if (!CloseHandle (fd_to_handle (fd))) + { + TRACE_LOG1 ("CloseHandle failed: ec=%d", (int) GetLastError ()); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - return 0; + return TRACE_SYSRES (0); } + int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, + void *value) { - int i; + int i; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd, + "close_handler=%p/%p", handler, value); - assert (fd != -1); + assert (fd != -1); - LOCK (notify_table_lock); - for (i=0; i < DIM (notify_table); i++ ) { - if ( notify_table[i].inuse && notify_table[i].fd == fd ) - break; - } - if ( i == DIM (notify_table) ) { - for (i=0; i < DIM (notify_table); i++ ) { - if ( !notify_table[i].inuse ) - break; - } - } - if ( i == DIM (notify_table) ) { - UNLOCK (notify_table_lock); - return -1; - } - notify_table[i].fd = fd; - notify_table[i].handler = handler; - notify_table[i].value = value; - notify_table[i].inuse = 1; - UNLOCK (notify_table_lock); - DEBUG2 ("set notification for fd %d (idx=%d)", fd, i ); - return 0; + LOCK (notify_table_lock); + for (i=0; i < DIM (notify_table); i++) + if (notify_table[i].inuse && notify_table[i].fd == fd) + break; + if (i == DIM (notify_table)) + for (i = 0; i < DIM (notify_table); i++) + if (!notify_table[i].inuse) + break; + if (i == DIM (notify_table)) + { + UNLOCK (notify_table_lock); + errno = EINVAL; + return TRACE_SYSRES (-1); + } + notify_table[i].fd = fd; + notify_table[i].handler = handler; + notify_table[i].value = value; + notify_table[i].inuse = 1; + UNLOCK (notify_table_lock); + return TRACE_SYSRES (0); } int -_gpgme_io_set_nonblocking ( int fd ) +_gpgme_io_set_nonblocking (int fd) { - return 0; + TRACE (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd); + return 0; } @@ -802,7 +953,6 @@ static char * build_commandline (char **argv) { int i; - int j; int n = 0; char *buf; char *p; @@ -855,279 +1005,330 @@ build_commandline (char **argv) int -_gpgme_io_spawn ( const char *path, char **argv, - struct spawn_fd_item_s *fd_child_list, - struct spawn_fd_item_s *fd_parent_list ) -{ - SECURITY_ATTRIBUTES sec_attr; - PROCESS_INFORMATION pi = { - NULL, /* returns process handle */ - 0, /* returns primary thread handle */ - 0, /* returns pid */ - 0 /* returns tid */ +_gpgme_io_spawn (const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list) +{ + SECURITY_ATTRIBUTES sec_attr; + PROCESS_INFORMATION pi = + { + NULL, /* returns process handle */ + 0, /* returns primary thread handle */ + 0, /* returns pid */ + 0 /* returns tid */ }; - STARTUPINFO si; - char *envblock = NULL; - int cr_flags = CREATE_DEFAULT_ERROR_MODE - | GetPriorityClass (GetCurrentProcess ()); - int i; - char *arg_string; - int duped_stdin = 0; - int duped_stderr = 0; - HANDLE hnul = INVALID_HANDLE_VALUE; - /* FIXME. */ - int debug_me = 0; - - memset (&sec_attr, 0, sizeof sec_attr ); - sec_attr.nLength = sizeof sec_attr; - sec_attr.bInheritHandle = FALSE; - - arg_string = build_commandline ( argv ); - if (!arg_string ) - return -1; - - memset (&si, 0, sizeof si); - si.cb = sizeof (si); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = debug_me? SW_SHOW : SW_HIDE; - si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); - 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 ) { - si.hStdInput = fd_to_handle (fd_child_list[i].fd); - DEBUG1 ("using %d for stdin", fd_child_list[i].fd ); - duped_stdin=1; + STARTUPINFO si; + char *envblock = NULL; + int cr_flags = CREATE_DEFAULT_ERROR_MODE + | GetPriorityClass (GetCurrentProcess ()); + int i; + char *arg_string; + int duped_stdin = 0; + int duped_stderr = 0; + 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; + sec_attr.bInheritHandle = FALSE; + + arg_string = build_commandline (argv); + if (!arg_string) + return TRACE_SYSRES (-1); + + memset (&si, 0, sizeof si); + si.cb = sizeof (si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = debug_me ? SW_SHOW : SW_HIDE; + si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); + 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) + { + si.hStdInput = fd_to_handle (fd_child_list[i].fd); + TRACE_LOG1 ("using 0x%x for stdin", fd_child_list[i].fd); + duped_stdin = 1; } - else if (fd_child_list[i].dup_to == 1 ) { - si.hStdOutput = fd_to_handle (fd_child_list[i].fd); - DEBUG1 ("using %d for stdout", fd_child_list[i].fd ); + else if (fd_child_list[i].dup_to == 1) + { + si.hStdOutput = fd_to_handle (fd_child_list[i].fd); + TRACE_LOG1 ("using 0x%x for stdout", fd_child_list[i].fd); } - else if (fd_child_list[i].dup_to == 2 ) { - si.hStdError = fd_to_handle (fd_child_list[i].fd); - DEBUG1 ("using %d for stderr", fd_child_list[i].fd ); - duped_stderr = 1; + else if (fd_child_list[i].dup_to == 2) + { + si.hStdError = fd_to_handle (fd_child_list[i].fd); + TRACE_LOG1 ("using 0x%x for stderr", fd_child_list[i].fd); + duped_stderr = 1; } } - - if( !duped_stdin || !duped_stderr ) { - SECURITY_ATTRIBUTES sa; - - memset (&sa, 0, sizeof sa ); - sa.nLength = sizeof sa; - sa.bInheritHandle = TRUE; - hnul = CreateFile ( "nul", - GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - &sa, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL ); - if ( hnul == INVALID_HANDLE_VALUE ) { - DEBUG1 ("can't open `nul': ec=%d\n", (int)GetLastError ()); - free (arg_string); - return -1; + + if (!duped_stdin || !duped_stderr) + { + SECURITY_ATTRIBUTES sa; + + memset (&sa, 0, sizeof sa); + sa.nLength = sizeof sa; + sa.bInheritHandle = TRUE; + hnul = CreateFile ("nul", + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + &sa, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hnul == INVALID_HANDLE_VALUE) + { + TRACE_LOG1 ("CreateFile (\"nul\") failed: ec=%d", + (int) GetLastError ()); + free (arg_string); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - /* Make sure that the process has a connected stdin */ - if ( !duped_stdin ) { - si.hStdInput = hnul; - DEBUG1 ("using %d for dummy stdin", (int)hnul ); + /* Make sure that the process has a connected stdin. */ + if (!duped_stdin) + { + si.hStdInput = hnul; + TRACE_LOG1 ("using 0x%x for dummy stdin", (int) hnul); } - /* We normally don't want all the normal output */ - if ( !duped_stderr ) { - si.hStdError = hnul; - DEBUG1 ("using %d for dummy stderr", (int)hnul ); + /* We normally don't want all the normal output. */ + if (!duped_stderr) + { + si.hStdError = hnul; + TRACE_LOG1 ("using 0x%x for dummy stderr", (int) hnul); } } + + cr_flags |= CREATE_SUSPENDED; + cr_flags |= DETACHED_PROCESS; + if (!CreateProcessA (path, + arg_string, + &sec_attr, /* process security attributes */ + &sec_attr, /* thread security attributes */ + TRUE, /* inherit handles */ + cr_flags, /* creation flags */ + envblock, /* environment */ + NULL, /* use current drive/directory */ + &si, /* startup information */ + &pi)) /* returns process information */ + { + TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ()); + free (arg_string); + /* 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 (!CloseHandle (hnul)) + 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); + + 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) + TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ()); + + if (!CloseHandle (pi.hThread)) + TRACE_LOG1 ("CloseHandle of thread failed: ec=%d", + (int) GetLastError ()); + + TRACE_SUC1 ("process=%p", pi.hProcess); + + /* We don't need to wait for the process. */ + CloseHandle (pi.hProcess); - DEBUG2 ("CreateProcess, path=`%s' args=`%s'", path, arg_string); - cr_flags |= CREATE_SUSPENDED; - if ( !CreateProcessA (path, - arg_string, - &sec_attr, /* process security attributes */ - &sec_attr, /* thread security attributes */ - TRUE, /* inherit handles */ - cr_flags, /* creation flags */ - envblock, /* environment */ - NULL, /* use current drive/directory */ - &si, /* startup information */ - &pi /* returns process information */ - ) ) { - DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ()); - free (arg_string); - return -1; - } - - /* Close the /dev/nul handle if used. */ - if (hnul != INVALID_HANDLE_VALUE ) { - if ( !CloseHandle ( hnul ) ) - DEBUG1 ("CloseHandle(hnul) failed: ec=%d\n", (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", - pi.hProcess, pi.hThread, - (int) pi.dwProcessId, (int) pi.dwThreadId); - - if ( ResumeThread ( pi.hThread ) < 0 ) { - DEBUG1 ("ResumeThread failed: ec=%d\n", (int)GetLastError ()); - } - - if ( !CloseHandle (pi.hThread) ) { - DEBUG1 ("CloseHandle of thread failed: ec=%d\n", - (int)GetLastError ()); - } - - return handle_to_pid (pi.hProcess); + 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 ) +_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) { - HANDLE waitbuf[MAXIMUM_WAIT_OBJECTS]; - int waitidx[MAXIMUM_WAIT_OBJECTS]; - int code, nwait; - int i, any; - int count; - void *dbg_help; + HANDLE waitbuf[MAXIMUM_WAIT_OBJECTS]; + int waitidx[MAXIMUM_WAIT_OBJECTS]; + int code; + int nwait; + int i; + int any; + int count; + void *dbg_help; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds, + "nfds=%u, nonblock=%u", nfds, nonblock); restart: - DEBUG_BEGIN (dbg_help, 3, "select on [ "); - any = 0; - nwait = 0; - count = 0; - for ( i=0; i < nfds; i++ ) { - if ( fds[i].fd == -1 ) - continue; - fds[i].signaled = 0; - if ( fds[i].for_read || fds[i].for_write ) { - if ( fds[i].frozen ) { - DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd ); - } - else if ( fds[i].for_read ) { - struct reader_context_s *c = find_reader (fds[i].fd,1); - - if (!c) { - DEBUG1 ("oops: no reader thread for fd %d", fds[i].fd); - } - else { - if ( nwait >= DIM (waitbuf) ) { - DEBUG_END (dbg_help, "oops ]"); - DEBUG0 ("Too many objects for WFMO!" ); - return -1; + TRACE_SEQ (dbg_help, "select on [ "); + any = 0; + nwait = 0; + count = 0; + for (i=0; i < nfds; i++) + { + if (fds[i].fd == -1) + continue; + fds[i].signaled = 0; + if (fds[i].for_read || fds[i].for_write) + { + if (fds[i].for_read) + { + struct reader_context_s *ctx = find_reader (fds[i].fd,1); + + if (!ctx) + TRACE_LOG1 ("error: no reader for FD 0x%x (ignored)", + fds[i].fd); + else + { + if (nwait >= DIM (waitbuf)) + { + TRACE_END (dbg_help, "oops ]"); + TRACE_LOG ("Too many objects for WFMO!"); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - waitidx[nwait] = i; - waitbuf[nwait++] = c->have_data_ev; + waitidx[nwait] = i; + waitbuf[nwait++] = ctx->have_data_ev; } - DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd ); - any = 1; + TRACE_ADD1 (dbg_help, "r0x%x ", fds[i].fd); + any = 1; } - else if ( fds[i].for_write ) { - struct writer_context_s *c = find_writer (fds[i].fd,1); - - if (!c) { - DEBUG1 ("oops: no writer thread for fd %d", fds[i].fd); - } - else { - if ( nwait >= DIM (waitbuf) ) { - DEBUG_END (dbg_help, "oops ]"); - DEBUG0 ("Too many objects for WFMO!" ); - return -1; + else if (fds[i].for_write) + { + struct writer_context_s *ctx = find_writer (fds[i].fd,1); + + if (!ctx) + TRACE_LOG1 ("error: no writer for FD 0x%x (ignored)", + fds[i].fd); + else + { + if (nwait >= DIM (waitbuf)) + { + TRACE_END (dbg_help, "oops ]"); + TRACE_LOG ("Too many objects for WFMO!"); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); } - waitidx[nwait] = i; - waitbuf[nwait++] = c->is_empty; + waitidx[nwait] = i; + waitbuf[nwait++] = ctx->is_empty; } - DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd ); - any = 1; + TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd); + any = 1; } } } - DEBUG_END (dbg_help, "]"); - if (!any) - return 0; - - code = WaitForMultipleObjects ( nwait, waitbuf, 0, nonblock ? 0 : 1000); - if ( code >= WAIT_OBJECT_0 && code < WAIT_OBJECT_0 + nwait ) { - /* This WFMO is a really silly function: It does return either - * the index of the signaled object or if 2 objects have been - * signalled at the same time, the index of the object with the - * lowest object is returned - so and how do we find out - * how many objects have been signaled???. - * The only solution I can imagine is to test each object starting - * with the returned index individually - how dull. - */ - any = 0; - for (i=code - WAIT_OBJECT_0; i < nwait; i++ ) { - if (WaitForSingleObject (waitbuf[i], 0) == WAIT_OBJECT_0) { - assert (waitidx[i] >=0 && waitidx[i] < nfds); - fds[waitidx[i]].signaled = 1; - any = 1; - count++; - } - } - if (!any) { - DEBUG0 ("Oops: No signaled objects found after WFMO"); - count = -1; - } + TRACE_END (dbg_help, "]"); + if (!any) + return TRACE_SYSRES (0); + + code = WaitForMultipleObjects (nwait, waitbuf, 0, nonblock ? 0 : 1000); + if (code >= WAIT_OBJECT_0 && code < WAIT_OBJECT_0 + nwait) + { + /* This WFMO is a really silly function: It does return either + the index of the signaled object or if 2 objects have been + signalled at the same time, the index of the object with the + lowest object is returned - so and how do we find out how + many objects have been signaled???. The only solution I can + imagine is to test each object starting with the returned + index individually - how dull. */ + any = 0; + for (i = code - WAIT_OBJECT_0; i < nwait; i++) + { + if (WaitForSingleObject (waitbuf[i], 0) == WAIT_OBJECT_0) + { + assert (waitidx[i] >=0 && waitidx[i] < nfds); + fds[waitidx[i]].signaled = 1; + any = 1; + count++; + } + } + if (!any) + { + TRACE_LOG ("no signaled objects found after WFMO"); + count = -1; + } } - else if ( code == WAIT_TIMEOUT ) { - DEBUG0 ("WFMO timed out\n" ); - } - else if (code == WAIT_FAILED ) { - int le = (int)GetLastError (); - if ( le == ERROR_INVALID_HANDLE ) { - int k, j = handle_to_fd (waitbuf[i]); - - DEBUG1 ("WFMO invalid handle %d removed\n", j); - for (k=0 ; k < nfds; k++ ) { - if ( fds[k].fd == j ) { - fds[k].for_read = fds[k].for_write = 0; - goto restart; + else if (code == WAIT_TIMEOUT) + TRACE_LOG ("WFMO timed out"); + else if (code == WAIT_FAILED) + { + int le = (int) GetLastError (); + if (le == ERROR_INVALID_HANDLE) + { + int k; + int j = handle_to_fd (waitbuf[i]); + + TRACE_LOG1 ("WFMO invalid handle %d removed", j); + for (k = 0 ; k < nfds; k++) + { + if (fds[k].fd == j) + { + fds[k].for_read = fds[k].for_write = 0; + goto restart; } } - DEBUG0 (" oops, or not???\n"); + TRACE_LOG (" oops, or not???"); } - DEBUG1 ("WFMO failed: %d\n", le ); - count = -1; + TRACE_LOG1 ("WFMO failed: %d", le); + count = -1; } - else { - DEBUG1 ("WFMO returned %d\n", code ); - count = -1; - } - - if ( count ) { - DEBUG_BEGIN (dbg_help, 3, " signaled [ "); - for ( i=0; i < nfds; i++ ) { - if ( fds[i].fd == -1 ) - continue; - if ( (fds[i].for_read || fds[i].for_write) && fds[i].signaled ) { - DEBUG_ADD2 (dbg_help, "%c%d ", - fds[i].for_read? 'r':'w',fds[i].fd ); - } + else + { + TRACE_LOG1 ("WFMO returned %d", code); + count = -1; + } + + if (count > 0) + { + TRACE_SEQ (dbg_help, "select OK [ "); + for (i = 0; i < nfds; i++) + { + if (fds[i].fd == -1) + continue; + if ((fds[i].for_read || fds[i].for_write) && fds[i].signaled) + TRACE_ADD2 (dbg_help, "%c0x%x ", + fds[i].for_read ? 'r' : 'w', fds[i].fd); } - DEBUG_END (dbg_help, "]"); + TRACE_END (dbg_help, "]"); } - - return count; + + if (count < 0) + { + /* FIXME: Should determine a proper error code. */ + errno = EIO; + } + + return TRACE_SYSRES (count); } + void _gpgme_io_subsystem_init (void) { - + /* Nothing to do. */ } @@ -1140,13 +1341,83 @@ _gpgme_io_fd2str (char *buf, int buflen, return snprintf (buf, buflen, "%d", fd); } + +int +_gpgme_io_dup (int fd) +{ + HANDLE handle = fd_to_handle (fd); + HANDLE new_handle = fd_to_handle (fd); + int i; + struct reader_context_s *rd_ctx; + struct writer_context_s *wt_ctx; + + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_dup", fd); + + if (!DuplicateHandle (GetCurrentProcess(), handle, + GetCurrentProcess(), &new_handle, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + { + TRACE_LOG1 ("DuplicateHandle failed: ec=%d\n", (int) GetLastError ()); + /* FIXME: Translate error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + + rd_ctx = find_reader (fd, 1); + if (rd_ctx) + { + /* No need for locking, as the only races are against the reader + thread itself, which doesn't touch refcount. */ + rd_ctx->refcount++; + + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + if (!reader_table[i].used) + break; + /* FIXME. */ + assert (i != reader_table_size); + reader_table[i].fd = handle_to_fd (new_handle); + reader_table[i].context = rd_ctx; + reader_table[i].used = 1; + UNLOCK (reader_table_lock); + } + + wt_ctx = find_writer (fd, 1); + if (wt_ctx) + { + /* No need for locking, as the only races are against the writer + thread itself, which doesn't touch refcount. */ + wt_ctx->refcount++; + + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + if (!writer_table[i].used) + break; + /* FIXME. */ + assert (i != writer_table_size); + writer_table[i].fd = handle_to_fd (new_handle); + writer_table[i].context = wt_ctx; + writer_table[i].used = 1; + UNLOCK (writer_table_lock); + } + + return TRACE_SYSRES (handle_to_fd (new_handle)); +} + -/* The following interface is only useful for GPGME Glib. */ +/* The following interface is only useful for GPGME Glib and Qt. */ -/* Look up the giochannel for file descriptor FD. */ +/* Compatibility interface, obsolete. */ void * gpgme_get_giochannel (int fd) { return NULL; } + +/* Look up the giochannel or qiodevice for file descriptor FD. */ +void * +gpgme_get_fdptr (int fd) +{ + return NULL; +} diff -urpNP gpgme-1.1.5/gpgme/w32-qt-io.cpp gpgme-1.1.6/gpgme/w32-qt-io.cpp --- gpgme-1.1.5/gpgme/w32-qt-io.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/gpgme/w32-qt-io.cpp 2007-10-04 23:05:48.000000000 +0000 @@ -0,0 +1,636 @@ +/* w32-qt-io.c - W32 Glib I/O functions + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2004, 2005, 2007 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kdpipeiodevice.h" + +extern "C" +{ +#include "util.h" +#include "priv-io.h" +#include "sema.h" +#include "debug.h" +} + +#ifndef O_BINARY +#ifdef _O_BINARY +#define O_BINARY _O_BINARY +#else +#define O_BINARY 0 +#endif +#endif + +using _gpgme_::KDPipeIODevice; + + +/* This file is an ugly hack to get GPGME working with Qt on Windows + targets. On Windows, you can not select() on file descriptors. + + The only way to check if there is something to read is to read + something. This means that GPGME can not let Qt check for data + without letting Qt also handle the data on Windows targets. + + The ugly consequence is that we need to work on QIODevices in + GPGME, creating a Qt dependency. Also, we need to export an + interface for the application to get at GPGME's QIODevices. There + is no good way to abstract all this with callbacks, because the + whole thing is also interconnected with the creation of pipes and + child processes. + + The following rule applies only to this I/O backend: + + * ALL operations must use the user defined event loop. GPGME can + not anymore provide its own event loop. This is mostly a sanity + requirement: Although we have in theory all information we need to + make the GPGME W32 code for select still work, it would be a big + complication and require changes throughout GPGME. + + Eventually, we probably have to bite the bullet and make some + really nice callback interfaces to let the user control all this at + a per-context level. */ + +#define MAX_SLAFD 1024 + +struct DeviceEntry { + DeviceEntry() : iodev( 0 ), refCount( 1 ), blocking( true ) {} + KDPipeIODevice* iodev; + bool blocking; + mutable int refCount; + void ref() const { ++refCount; } + int unref() const { assert( refCount > 0 ); return --refCount; } +}; + +DeviceEntry* iodevice_table[MAX_SLAFD]; + + +static KDPipeIODevice * +find_channel (int fd, int create) +{ + assert( fd < MAX_SLAFD ); + if (fd < 0 || fd >= MAX_SLAFD) + return NULL; + + if (create && !iodevice_table[fd]) + { + DeviceEntry* entry = new DeviceEntry; + entry->iodev = new KDPipeIODevice + (fd, QIODevice::ReadWrite|QIODevice::Unbuffered); + iodevice_table[fd] = entry; + } + return iodevice_table[fd] ? iodevice_table[fd]->iodev : 0; +} + +/* Write the printable version of FD to the buffer BUF of length + BUFLEN. The printable version is the representation on the command + line that the child process expects. */ +int +_gpgme_io_fd2str (char *buf, int buflen, int fd) +{ + return snprintf (buf, buflen, "%d", (long)_get_osfhandle( fd ) ); +} + + +void +_gpgme_io_subsystem_init (void) +{ +} + + +static struct +{ + _gpgme_close_notify_handler_t handler; + void *value; +} notify_table[MAX_SLAFD]; + + +int +_gpgme_io_read (int fd, void *buffer, size_t count) +{ + int saved_errno = 0; + qint64 nread; + KDPipeIODevice *chan; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd, + "buffer=%p, count=%u", buffer, count); + + chan = find_channel (fd, 0); + if (!chan) + { + TRACE_LOG ("no channel registered"); + errno = EINVAL; + return TRACE_SYSRES (-1); + } + TRACE_LOG1 ("channel %p", chan); + if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->readWouldBlock() ) { + errno = EAGAIN; + return TRACE_SYSRES( -1 ); + } + + nread = chan->read ((char *) buffer, count); + if (nread < 0) + { + TRACE_LOG1 ("err %s", qPrintable (chan->errorString ())); + saved_errno = EIO; + nread = -1; + } + + TRACE_LOGBUF ((char *) buffer, nread); + + errno = saved_errno; + return TRACE_SYSRES (nread); +} + + +int +_gpgme_io_write (int fd, const void *buffer, size_t count) +{ + qint64 nwritten; + KDPipeIODevice *chan; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd, + "buffer=%p, count=%u", buffer, count); + TRACE_LOGBUF ((char *) buffer, count); + + chan = find_channel (fd, 0); + if (!chan) + { + TRACE_LOG ("fd %d: no channel registered"); + errno = EINVAL; + return -1; + } + + if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->writeWouldBlock() ) + { + errno = EAGAIN; + return TRACE_SYSRES( -1 ); + } + nwritten = chan->write ((char *) buffer, count); + + if (nwritten < 0) + { + nwritten = -1; + errno = EIO; + return TRACE_SYSRES(-1); + } + errno = 0; + return TRACE_SYSRES (nwritten); +} + + +int +_gpgme_io_pipe (int filedes[2], int inherit_idx) +{ + KDPipeIODevice *chan; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, + "inherit_idx=%i (GPGME uses it for %s)", + inherit_idx, inherit_idx ? "reading" : "writing"); + +#define PIPEBUF_SIZE 4096 + if (_pipe (filedes, PIPEBUF_SIZE, O_NOINHERIT | O_BINARY) == -1) + return TRACE_SYSRES (-1); + + /* Make one end inheritable. */ + if (inherit_idx == 0) + { + int new_read; + + new_read = _dup (filedes[0]); + _close (filedes[0]); + filedes[0] = new_read; + + if (new_read < 0) + { + _close (filedes[1]); + return TRACE_SYSRES (-1); + } + } + else if (inherit_idx == 1) + { + int new_write; + + new_write = _dup (filedes[1]); + _close (filedes[1]); + filedes[1] = new_write; + + if (new_write < 0) + { + _close (filedes[0]); + return TRACE_SYSRES (-1); + } + } + + /* Now we have a pipe with the right end inheritable. The other end + should have a giochannel. */ + + chan = find_channel (filedes[1 - inherit_idx], 1); + + if (!chan) + { + int saved_errno = errno; + _close (filedes[0]); + _close (filedes[1]); + errno = saved_errno; + return TRACE_SYSRES (-1); + } + + 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); +} + +int +_gpgme_io_close (int fd) +{ + KDPipeIODevice *chan; + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd); + + if (fd < 0 || fd >= MAX_SLAFD) + { + errno = EBADF; + return TRACE_SYSRES (-1); + } + + /* First call the notify handler. */ + if (notify_table[fd].handler) + { + notify_table[fd].handler (fd, notify_table[fd].value); + notify_table[fd].handler = NULL; + notify_table[fd].value = NULL; + } + + /* Then do the close. */ + + DeviceEntry* const entry = iodevice_table[fd]; + if ( entry ) { + if ( entry->unref() == 0 ) { + entry->iodev->close(); + delete entry->iodev; + delete entry; + iodevice_table[fd] = 0; + } + } else { + _close( fd ); + } + + + + return 0; +} + + +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)) + { + errno = EINVAL; + return TRACE_SYSRES (-1); + } + notify_table[fd].handler = handler; + notify_table[fd].value = value; + return TRACE_SYSRES (0); +} + + +int +_gpgme_io_set_nonblocking (int fd) +{ + DeviceEntry* const entry = iodevice_table[fd]; + assert( entry ); + entry->blocking = false; + TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd); + return TRACE_SYSRES (0); +} + + +static char * +build_commandline (char **argv) +{ + int i; + int n = 0; + char *buf; + char *p; + + /* We have to quote some things because under Windows the program + parses the commandline and does some unquoting. We enclose the + whole argument in double-quotes, and escape literal double-quotes + as well as backslashes with a backslash. We end up with a + trailing space at the end of the line, but that is harmless. */ + for (i = 0; argv[i]; i++) + { + p = argv[i]; + /* The leading double-quote. */ + n++; + while (*p) + { + /* An extra one for each literal that must be escaped. */ + if (*p == '\\' || *p == '"') + n++; + n++; + p++; + } + /* The trailing double-quote and the delimiter. */ + n += 2; + } + /* And a trailing zero. */ + n++; + + buf = p = (char *) malloc (n); + if (!buf) + return NULL; + for (i = 0; argv[i]; i++) + { + char *argvp = argv[i]; + + *(p++) = '"'; + while (*argvp) + { + if (*argvp == '\\' || *argvp == '"') + *(p++) = '\\'; + *(p++) = *(argvp++); + } + *(p++) = '"'; + *(p++) = ' '; + } + *(p++) = 0; + + return buf; +} + + +int +_gpgme_io_spawn (const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list) +{ + SECURITY_ATTRIBUTES sec_attr; + PROCESS_INFORMATION pi = + { + NULL, /* returns process handle */ + 0, /* returns primary thread handle */ + 0, /* returns pid */ + 0 /* returns tid */ + }; + STARTUPINFO si; + char *envblock = NULL; + int cr_flags = CREATE_DEFAULT_ERROR_MODE + | GetPriorityClass (GetCurrentProcess ()); + int i; + char *arg_string; + int duped_stdin = 0; + int duped_stderr = 0; + 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; + sec_attr.bInheritHandle = FALSE; + + arg_string = build_commandline (argv); + if (!arg_string) + return TRACE_SYSRES (-1); + + memset (&si, 0, sizeof si); + si.cb = sizeof (si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = debug_me? SW_SHOW : SW_HIDE; + si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); + 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) + { + si.hStdInput = (HANDLE) _get_osfhandle (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) + { + si.hStdOutput = (HANDLE) _get_osfhandle (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) + { + si.hStdError = (HANDLE) _get_osfhandle (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) + { + SECURITY_ATTRIBUTES sa; + + memset (&sa, 0, sizeof sa); + sa.nLength = sizeof sa; + sa.bInheritHandle = TRUE; + hnul = CreateFile ("nul", + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + &sa, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hnul == INVALID_HANDLE_VALUE) + { + TRACE_LOG1 ("CreateFile (\"nul\") failed: ec=%d", + (int) GetLastError ()); + free (arg_string); + /* FIXME: Should translate the error code. */ + errno = EIO; + return TRACE_SYSRES (-1); + } + /* Make sure that the process has a connected stdin. */ + if (!duped_stdin) + { + si.hStdInput = hnul; + TRACE_LOG1 ("using 0x%x for dummy stdin", (int) hnul); + } + /* We normally don't want all the normal output. */ + if (!duped_stderr) + { + si.hStdError = hnul; + TRACE_LOG1 ("using %d for dummy stderr", (int)hnul); + } + } + + cr_flags |= CREATE_SUSPENDED; + cr_flags |= DETACHED_PROCESS; + if (!CreateProcessA (path, + arg_string, + &sec_attr, /* process security attributes */ + &sec_attr, /* thread security attributes */ + TRUE, /* inherit handles */ + cr_flags, /* creation flags */ + envblock, /* environment */ + NULL, /* use current drive/directory */ + &si, /* startup information */ + &pi)) /* returns process information */ + { + TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ()); + free (arg_string); + /* 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 (!CloseHandle (hnul)) + 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); + + + 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) + TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ()); + + if (!CloseHandle (pi.hThread)) + TRACE_LOG1 ("CloseHandle of thread failed: ec=%d", + (int) GetLastError ()); + + TRACE_SUC1 ("process=%p", pi.hProcess); + + /* We don't need to wait for the process. */ + CloseHandle (pi.hProcess); + + return TRACE_SYSRES (0); +} + + +/* 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) +{ + /* Use a 1s timeout. */ + + void *dbg_help = NULL; + TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds, + "nfds=%u, nonblock=%u", nfds, nonblock); + + /* We only implement the special case of nonblock == true. */ + assert (nonblock); + + int count = 0; + + TRACE_SEQ (dbg_help, "select on [ "); + for (int i = 0; i < nfds; i++) + { + if (fds[i].fd == -1) + { + fds[i].signaled = 0; + } + else if (fds[i].for_read ) + { + const KDPipeIODevice * const chan = find_channel (fds[i].fd, 0); + assert (chan); + fds[i].signaled = chan->readWouldBlock() ? 0 : 1; + TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd); + if ( fds[i].signaled ) + count++; + } + else if (fds[i].for_write) + { + const KDPipeIODevice * const chan = find_channel (fds[i].fd, 0); + assert (chan); + fds[i].signaled = chan->writeWouldBlock() ? 0 : 1; + TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd); + if ( fds[i].signaled ) + count++; + } + } + TRACE_END (dbg_help, "]"); + + return TRACE_SYSRES (count); +} + + +/* Look up the qiodevice for file descriptor FD. */ +extern "C" +void * +gpgme_get_fdptr (int fd) +{ + return find_channel (fd, 0); +} + + +/* Obsolete compatibility interface. */ +extern "C" +void * +gpgme_get_giochannel (int fd) +{ + return NULL; +} + + +int +_gpgme_io_dup (int fd) +{ + assert( iodevice_table[fd] ); + iodevice_table[fd]->ref(); + return fd; +} + diff -urpNP gpgme-1.1.5/gpgme/w32-sema.c gpgme-1.1.6/gpgme/w32-sema.c --- gpgme-1.1.5/gpgme/w32-sema.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/w32-sema.c 2007-10-04 11:06:48.000000000 +0000 @@ -1,6 +1,6 @@ /* w32-sema.c Copyright (C) 2001 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2004 g10 Code GmbH + Copyright (C) 2001, 2002, 2004, 2007 g10 Code GmbH This file is part of GPGME. @@ -65,7 +65,7 @@ critsect_init (struct critsect_s *s) /* first test whether it is really not initialized */ EnterCriticalSection (&init_lock); - if ( s->private ) { + if ( s->priv ) { LeaveCriticalSection (&init_lock); return; } @@ -76,7 +76,7 @@ critsect_init (struct critsect_s *s) sema_fatal ("out of core while creating critical section lock"); } InitializeCriticalSection (mp); - s->private = mp; + s->priv = mp; LeaveCriticalSection (&init_lock); } @@ -91,25 +91,25 @@ _gpgme_sema_subsystem_init () void _gpgme_sema_cs_enter ( struct critsect_s *s ) { - if (!s->private) + if (!s->priv) critsect_init (s); - EnterCriticalSection ( (CRITICAL_SECTION*)s->private ); + EnterCriticalSection ( (CRITICAL_SECTION*)s->priv ); } void _gpgme_sema_cs_leave (struct critsect_s *s) { - if (!s->private) + if (!s->priv) critsect_init (s); - LeaveCriticalSection ((CRITICAL_SECTION*)s->private); + LeaveCriticalSection ((CRITICAL_SECTION*)s->priv); } void _gpgme_sema_cs_destroy ( struct critsect_s *s ) { - if (s && s->private) { - DeleteCriticalSection ((CRITICAL_SECTION*)s->private); - free (s->private); - s->private = NULL; + if (s && s->priv) { + DeleteCriticalSection ((CRITICAL_SECTION*)s->priv); + free (s->priv); + s->priv = NULL; } } diff -urpNP gpgme-1.1.5/gpgme/w32-util.c gpgme-1.1.6/gpgme/w32-util.c --- gpgme-1.1.5/gpgme/w32-util.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/w32-util.c 2008-01-04 14:17:15.000000000 +0000 @@ -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 *na { 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] == '/') @@ -244,6 +245,37 @@ find_program_in_registry (const char *na static char * +find_program_in_inst_dir (const char *name) +{ + char *result = NULL; + char *tmp; + + tmp = read_w32_registry_string ("HKEY_LOCAL_MACHINE", + "Software\\GNU\\GnuPG", + "Install Directory"); + if (!tmp) + return NULL; + + result = malloc (strlen (tmp) + 1 + strlen (name) + 1); + if (!result) + { + free (tmp); + return NULL; + } + + strcpy (stpcpy (stpcpy (result, tmp), "\\"), name); + free (tmp); + if (access (result, F_OK)) + { + free (result); + return NULL; + } + + return result; +} + + +static char * find_program_at_standard_place (const char *name) { char path[MAX_PATH]; @@ -265,6 +297,7 @@ find_program_at_standard_place (const ch return result; } + const char * _gpgme_get_gpg_path (void) { @@ -274,15 +307,14 @@ _gpgme_get_gpg_path (void) if (!gpg_program) gpg_program = find_program_in_registry ("gpgProgram"); if (!gpg_program) - gpg_program = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); -#ifdef GPG_PATH + gpg_program = find_program_in_inst_dir ("gpg.exe"); if (!gpg_program) - gpg_program = GPG_PATH; -#endif + gpg_program = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); UNLOCK (get_path_lock); return gpg_program; } + const char * _gpgme_get_gpgsm_path (void) { @@ -292,16 +324,32 @@ _gpgme_get_gpgsm_path (void) if (!gpgsm_program) gpgsm_program = find_program_in_registry ("gpgsmProgram"); if (!gpgsm_program) - gpgsm_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe"); -#ifdef GPGSM_PATH + gpgsm_program = find_program_in_inst_dir ("gpgsm.exe"); if (!gpgsm_program) - gpgsm_program = GPGSM_PATH; -#endif + gpgsm_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe"); UNLOCK (get_path_lock); return gpgsm_program; } +const char * +_gpgme_get_gpgconf_path (void) +{ + static char *gpgconf_program; + + LOCK (get_path_lock); + if (!gpgconf_program) + gpgconf_program = find_program_in_registry ("gpgconfProgram"); + if (!gpgconf_program) + gpgconf_program = find_program_in_inst_dir ("gpgconf.exe"); + if (!gpgconf_program) + gpgconf_program + = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe"); + UNLOCK (get_path_lock); + return gpgconf_program; +} + + /* Return an integer value from gpgme specific configuration entries. VALUE receives that value; function returns true if a value has been configured and false if not. */ diff -urpNP gpgme-1.1.5/gpgme/wait.c gpgme-1.1.6/gpgme/wait.c --- gpgme-1.1.5/gpgme/wait.c 2007-01-05 16:46:14.000000000 +0000 +++ gpgme-1.1.6/gpgme/wait.c 2007-10-04 11:06:47.000000000 +0000 @@ -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. @@ -82,7 +82,6 @@ fd_table_put (fd_table_t fdt, int fd, in fdt->fds[i].fd = fd; fdt->fds[i].for_read = (dir == 1); fdt->fds[i].for_write = (dir == 0); - fdt->fds[i].frozen = 0; fdt->fds[i].signaled = 0; fdt->fds[i].opaque = opaque; *idx = i; @@ -136,6 +135,9 @@ _gpgme_add_io_cb (void *data, int fd, in return err; } + TRACE3 (DEBUG_CTX, "_gpgme_add_io_cb", ctx, + "fd %d, dir=%d -> tag=%p", fd, dir, tag); + *r_tag = tag; return 0; } @@ -156,8 +158,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); @@ -187,6 +191,7 @@ _gpgme_run_io_cb (struct io_select_fd_s int nr; struct io_select_fd_s fds; + TRACE0 (DEBUG_CTX, "_gpgme_run_io_cb", item, "need to check"); fds = *an_fds; fds.signaled = 0; /* Just give it a quick poll. */ @@ -200,5 +205,7 @@ _gpgme_run_io_cb (struct io_select_fd_s return 0; } + TRACE2 (DEBUG_CTX, "_gpgme_run_io_cb", item, "handler (%p, %d)", + item->handler_value, an_fds->fd); return item->handler (item->handler_value, an_fds->fd); } diff -urpNP gpgme-1.1.5/gpgme.spec gpgme-1.1.6/gpgme.spec --- gpgme-1.1.5/gpgme.spec 2007-07-09 13:15:54.000000000 +0000 +++ gpgme-1.1.6/gpgme.spec 2008-01-04 14:31:04.000000000 +0000 @@ -1,7 +1,7 @@ # This is a template. The dist target uses it to create the real file. Summary: GPGME - GnuPG Made Easy Name: gpgme -Version: 1.1.5 +Version: 1.1.6 Release: 1 URL: http://www.gnupg.org/gpgme.html Source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/%{name}-%{version}.tar.gz diff -urpNP gpgme-1.1.5/lang/Makefile.in gpgme-1.1.6/lang/Makefile.in --- gpgme-1.1.5/lang/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/lang/Makefile.in 2008-01-04 14:26:39.000000000 +0000 @@ -116,6 +116,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -157,6 +158,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/lang/cl/Makefile.in gpgme-1.1.6/lang/cl/Makefile.in --- gpgme-1.1.5/lang/cl/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/lang/cl/Makefile.in 2008-01-04 14:26:39.000000000 +0000 @@ -116,6 +116,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -157,6 +158,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ diff -urpNP gpgme-1.1.5/lang/cl/gpgme.asd gpgme-1.1.6/lang/cl/gpgme.asd --- gpgme-1.1.5/lang/cl/gpgme.asd 2007-07-09 13:14:53.000000000 +0000 +++ gpgme-1.1.6/lang/cl/gpgme.asd 2008-01-04 14:27:09.000000000 +0000 @@ -27,7 +27,7 @@ (defsystem gpgme :description "GnuPG Made Easy." :author "g10 Code GmbH" - :version "1.1.5" + :version "1.1.6" :licence "GPL" :depends-on ("cffi" "gpg-error") :components ((:file "gpgme-package") diff -urpNP gpgme-1.1.5/tests/ChangeLog gpgme-1.1.6/tests/ChangeLog --- gpgme-1.1.5/tests/ChangeLog 2007-03-09 13:10:20.000000000 +0000 +++ gpgme-1.1.6/tests/ChangeLog 2008-01-04 14:25:40.000000000 +0000 @@ -1,3 +1,48 @@ +2008-01-04 Marcus Brinkmann + + * gpg/Makefile.am (CLEANFILES): Add pubring.kbx and dirmngr.conf. + + * Makefile.am (TESTS_ENVIRONMENT): Use absolute path for + GNUPGHOME. + * gpg/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for + GNUPGHOME. + * gpgsm/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for + GNUPGHOME. + * gpg/Makefile.am (TESTS): Add t-gpgconf. + t-gpgconf.c: New file. + +2007-11-23 Marcus Brinkmann + + * gpgsm/t-verify.c (show_auditlog): Check for GPG_ERR_ASS_UNKNOWN_CMD. + +2007-11-23 Werner Koch + + * gpgsm/t-verify.c (check_result): Don't exit on error but set a flag. + (main): Cosnult flag for return value. + (show_auditlog): New. + (main): Use it. + +2007-09-27 Marcus Brinkmann + + * t-engine-info.c (check_engine_info): Fix debug output. + * gpg/Makefile.am (tests_unix): New variable. + (TESTS): Use it. + * gpg/t-support.h (passphrase_cb) [HAVE_W32_SYSTEM]: Use WriteFile instead of write. + * gpg/t-wait.c [HAVE_W32_SYSTEM]: Define sleep as _sleep. + +2007-09-14 Marcus Brinkmann + + * gpgsm/t-verify.c (main): Release TEXT and SIG. + +2007-07-12 Marcus Brinkmann + + * gpgsm/Makefile.am (key_id): Change := into =. + +2007-07-12 Werner Koch + + * gpgsm/t-support.h (init_gpgme) [W32]: Do not init the locales as + the constants are not available. + 2007-02-26 Werner Koch * gpg/t-verify.c (double_plaintext_sig): New. diff -urpNP gpgme-1.1.5/tests/Makefile.am gpgme-1.1.6/tests/Makefile.am --- gpgme-1.1.5/tests/Makefile.am 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/Makefile.am 2008-01-04 14:17:15.000000000 +0000 @@ -20,7 +20,7 @@ ## Process this file with automake to produce Makefile.in -TESTS_ENVIRONMENT = GNUPGHOME=. +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) TESTS = t-version t-data t-engine-info diff -urpNP gpgme-1.1.5/tests/Makefile.in gpgme-1.1.6/tests/Makefile.in --- gpgme-1.1.5/tests/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/tests/Makefile.in 2008-01-04 14:26:39.000000000 +0000 @@ -147,6 +147,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -188,6 +189,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ @@ -245,7 +248,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -TESTS_ENVIRONMENT = GNUPGHOME=. +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) EXTRA_DIST = t-data-1.txt t-data-2.txt INCLUDES = -I$(top_srcdir)/gpgme AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ diff -urpNP gpgme-1.1.5/tests/gpg/Makefile.am gpgme-1.1.6/tests/gpg/Makefile.am --- gpgme-1.1.5/tests/gpg/Makefile.am 2005-10-01 20:14:48.000000000 +0000 +++ gpgme-1.1.6/tests/gpg/Makefile.am 2008-01-04 14:25:18.000000000 +0000 @@ -21,17 +21,23 @@ GPG = @GPG@ -TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= # The keylist tests must come after the import and the edit test. noinst_HEADERS = t-support.h -TESTS = t-encrypt t-encrypt-sym t-encrypt-sign t-sign t-signers \ - t-decrypt t-verify t-decrypt-verify t-sig-notation \ - t-export t-import t-trustlist t-eventloop t-edit \ - t-keylist t-keylist-sig t-thread1 t-wait t-encrypt-large \ - t-file-name -CLEANFILES = secring.gpg pubring.gpg trustdb.gpg +if HAVE_W32_SYSTEM +tests_unix = +else +tests_unix = t-eventloop t-thread1 +endif + +TESTS = t-encrypt t-encrypt-sym t-encrypt-sign t-sign t-signers \ + t-decrypt t-verify t-decrypt-verify t-sig-notation t-export \ + t-import t-trustlist t-edit t-keylist t-keylist-sig t-wait \ + t-encrypt-large t-file-name t-gpgconf $(tests_unix) + +CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf DISTCLEANFILES = pubring.gpg~ random_seed gpg.conf EXTRA_DIST = mkdemodirs pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \ diff -urpNP gpgme-1.1.5/tests/gpg/Makefile.in gpgme-1.1.6/tests/gpg/Makefile.in --- gpgme-1.1.5/tests/gpg/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/tests/gpg/Makefile.in 2008-01-04 14:26:40.000000000 +0000 @@ -56,10 +56,11 @@ TESTS = t-encrypt$(EXEEXT) t-encrypt-sym t-encrypt-sign$(EXEEXT) t-sign$(EXEEXT) t-signers$(EXEEXT) \ t-decrypt$(EXEEXT) t-verify$(EXEEXT) t-decrypt-verify$(EXEEXT) \ t-sig-notation$(EXEEXT) t-export$(EXEEXT) t-import$(EXEEXT) \ - t-trustlist$(EXEEXT) t-eventloop$(EXEEXT) t-edit$(EXEEXT) \ - t-keylist$(EXEEXT) t-keylist-sig$(EXEEXT) t-thread1$(EXEEXT) \ - t-wait$(EXEEXT) t-encrypt-large$(EXEEXT) t-file-name$(EXEEXT) -noinst_PROGRAMS = $(am__EXEEXT_1) t-genkey$(EXEEXT) + t-trustlist$(EXEEXT) t-edit$(EXEEXT) t-keylist$(EXEEXT) \ + t-keylist-sig$(EXEEXT) t-wait$(EXEEXT) \ + t-encrypt-large$(EXEEXT) t-file-name$(EXEEXT) \ + t-gpgconf$(EXEEXT) $(am__EXEEXT_1) +noinst_PROGRAMS = $(am__EXEEXT_2) t-genkey$(EXEEXT) subdir = tests/gpg DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in @@ -73,13 +74,16 @@ am__configure_deps = $(am__aclocal_m4_de mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = -am__EXEEXT_1 = t-encrypt$(EXEEXT) t-encrypt-sym$(EXEEXT) \ +@HAVE_W32_SYSTEM_FALSE@am__EXEEXT_1 = t-eventloop$(EXEEXT) \ +@HAVE_W32_SYSTEM_FALSE@ t-thread1$(EXEEXT) +am__EXEEXT_2 = t-encrypt$(EXEEXT) t-encrypt-sym$(EXEEXT) \ t-encrypt-sign$(EXEEXT) t-sign$(EXEEXT) t-signers$(EXEEXT) \ t-decrypt$(EXEEXT) t-verify$(EXEEXT) t-decrypt-verify$(EXEEXT) \ t-sig-notation$(EXEEXT) t-export$(EXEEXT) t-import$(EXEEXT) \ - t-trustlist$(EXEEXT) t-eventloop$(EXEEXT) t-edit$(EXEEXT) \ - t-keylist$(EXEEXT) t-keylist-sig$(EXEEXT) t-thread1$(EXEEXT) \ - t-wait$(EXEEXT) t-encrypt-large$(EXEEXT) t-file-name$(EXEEXT) + t-trustlist$(EXEEXT) t-edit$(EXEEXT) t-keylist$(EXEEXT) \ + t-keylist-sig$(EXEEXT) t-wait$(EXEEXT) \ + t-encrypt-large$(EXEEXT) t-file-name$(EXEEXT) \ + t-gpgconf$(EXEEXT) $(am__EXEEXT_1) PROGRAMS = $(noinst_PROGRAMS) t_decrypt_SOURCES = t-decrypt.c t_decrypt_OBJECTS = t-decrypt.$(OBJEXT) @@ -125,6 +129,10 @@ t_genkey_SOURCES = t-genkey.c t_genkey_OBJECTS = t-genkey.$(OBJEXT) t_genkey_LDADD = $(LDADD) t_genkey_DEPENDENCIES = ../../gpgme/libgpgme.la +t_gpgconf_SOURCES = t-gpgconf.c +t_gpgconf_OBJECTS = t-gpgconf.$(OBJEXT) +t_gpgconf_LDADD = $(LDADD) +t_gpgconf_DEPENDENCIES = ../../gpgme/libgpgme.la t_import_SOURCES = t-import.c t_import_OBJECTS = t-import.$(OBJEXT) t_import_LDADD = $(LDADD) @@ -178,14 +186,16 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLF $(LDFLAGS) -o $@ SOURCES = t-decrypt.c t-decrypt-verify.c t-edit.c t-encrypt.c \ t-encrypt-large.c t-encrypt-sign.c t-encrypt-sym.c \ - t-eventloop.c t-export.c t-file-name.c t-genkey.c t-import.c \ - t-keylist.c t-keylist-sig.c t-sig-notation.c t-sign.c \ - t-signers.c t-thread1.c t-trustlist.c t-verify.c t-wait.c + t-eventloop.c t-export.c t-file-name.c t-genkey.c t-gpgconf.c \ + t-import.c t-keylist.c t-keylist-sig.c t-sig-notation.c \ + t-sign.c t-signers.c t-thread1.c t-trustlist.c t-verify.c \ + t-wait.c DIST_SOURCES = t-decrypt.c t-decrypt-verify.c t-edit.c t-encrypt.c \ t-encrypt-large.c t-encrypt-sign.c t-encrypt-sym.c \ - t-eventloop.c t-export.c t-file-name.c t-genkey.c t-import.c \ - t-keylist.c t-keylist-sig.c t-sig-notation.c t-sign.c \ - t-signers.c t-thread1.c t-trustlist.c t-verify.c t-wait.c + t-eventloop.c t-export.c t-file-name.c t-genkey.c t-gpgconf.c \ + t-import.c t-keylist.c t-keylist-sig.c t-sig-notation.c \ + t-sign.c t-signers.c t-thread1.c t-trustlist.c t-verify.c \ + t-wait.c HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags @@ -229,6 +239,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -270,6 +281,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ @@ -327,11 +340,13 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= # The keylist tests must come after the import and the edit test. noinst_HEADERS = t-support.h -CLEANFILES = secring.gpg pubring.gpg trustdb.gpg +@HAVE_W32_SYSTEM_FALSE@tests_unix = t-eventloop t-thread1 +@HAVE_W32_SYSTEM_TRUE@tests_unix = +CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf DISTCLEANFILES = pubring.gpg~ random_seed gpg.conf EXTRA_DIST = mkdemodirs pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \ geheim.txt pubkey-1.asc seckey-1.asc @@ -413,6 +428,9 @@ t-file-name$(EXEEXT): $(t_file_name_OBJE t-genkey$(EXEEXT): $(t_genkey_OBJECTS) $(t_genkey_DEPENDENCIES) @rm -f t-genkey$(EXEEXT) $(LINK) $(t_genkey_OBJECTS) $(t_genkey_LDADD) $(LIBS) +t-gpgconf$(EXEEXT): $(t_gpgconf_OBJECTS) $(t_gpgconf_DEPENDENCIES) + @rm -f t-gpgconf$(EXEEXT) + $(LINK) $(t_gpgconf_OBJECTS) $(t_gpgconf_LDADD) $(LIBS) t-import$(EXEEXT): $(t_import_OBJECTS) $(t_import_DEPENDENCIES) @rm -f t-import$(EXEEXT) $(LINK) $(t_import_OBJECTS) $(t_import_LDADD) $(LIBS) @@ -461,6 +479,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-export.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-file-name.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-genkey.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-gpgconf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-import.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-keylist-sig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-keylist.Po@am__quote@ diff -urpNP gpgme-1.1.5/tests/gpg/t-gpgconf.c gpgme-1.1.6/tests/gpg/t-gpgconf.c --- gpgme-1.1.5/tests/gpg/t-gpgconf.c 1970-01-01 00:00:00.000000000 +0000 +++ gpgme-1.1.6/tests/gpg/t-gpgconf.c 2008-01-04 14:17:15.000000000 +0000 @@ -0,0 +1,305 @@ +/* t-gpgconf.c - Regression test. + Copyright (C) 2001, 2004, 2007 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef HAVE_W32_SYSTEM +#include +#endif + +#include + + +#define fail_if_err(err) \ + do \ + { \ + if (err) \ + { \ + fprintf (stderr, "%s:%d: %s: %s\n", \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err)); \ + exit (1); \ + } \ + } \ + while (0) + + +void +init_gpgme (gpgme_protocol_t proto) +{ + gpgme_error_t err; + + gpgme_check_version (NULL); + setlocale (LC_ALL, ""); + gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); +#ifndef HAVE_W32_SYSTEM + gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); +#endif + + err = gpgme_engine_check_version (proto); + fail_if_err (err); +} + + +static char * +spaces (char *str, int extra) +{ + static char buf[80]; + int len = str ? strlen (str) : 0; + int n; + +#define TABSTOP 30 + n = TABSTOP - len - extra; + + memset (buf, ' ', sizeof (buf)); + if (n < 1 || n > (sizeof (buf) - 1)) + { + buf[0] = '\n'; + n = TABSTOP + 1; + } + + buf[n] = '\0'; + return buf; +} + + +void +dump_arg (int type, gpgme_conf_arg_t arg) +{ + if (!arg) + { + printf ("(none)"); + return; + } + + while (arg) + { + switch (type) + { + case GPGME_CONF_STRING: + case GPGME_CONF_PATHNAME: + case GPGME_CONF_LDAP_SERVER: + printf ("%s", arg->value.string); + break; + + case GPGME_CONF_UINT32: + printf ("%u", arg->value.uint32); + break; + + case GPGME_CONF_INT32: + printf ("%i", arg->value.int32); + break; + + case GPGME_CONF_NONE: + printf ("%i (times)", arg->value.count); + break; + + default: + printf ("(unknown type)"); + } + + arg = arg->next; + if (arg) + printf (" "); + } +} + + +void +dump_opt (gpgme_conf_opt_t opt) +{ + char level; + char runtime = (opt->flags & GPGME_CONF_RUNTIME) ? 'r' : ' '; + + switch (opt->level) + { + case GPGME_CONF_BASIC: + level = 'b'; + break; + case GPGME_CONF_ADVANCED: + level = 'a'; + break; + case GPGME_CONF_EXPERT: + level = 'e'; + break; + case GPGME_CONF_INVISIBLE: + level = 'i'; + break; + case GPGME_CONF_INTERNAL: + level = '#'; + break; + default: + level = '?'; + } + + if (opt->flags & GPGME_CONF_GROUP) + { + printf ("\n"); + printf ("%c%c [%s]%s%s\n", level, runtime, opt->name, spaces (opt->name, 5), + opt->description + ? opt->description : ""); + } + else + { + if (opt->argname) + { + char *more = (opt->flags & GPGME_CONF_LIST) ? "..." : ""; + + if (opt->flags & GPGME_CONF_OPTIONAL) + { + printf ("%c%c --%s [%s%s] %s", level, runtime, opt->name, opt->argname, more, + spaces (opt->name, 9 + strlen (opt->argname) + strlen (more))); + } + else + { + printf ("%c%c --%s %s%s %s", level, runtime, opt->name, opt->argname, more, + spaces (opt->name, 7 + strlen (opt->argname) + strlen (more))); + } + } + else + printf ("%c%c --%s%s", level, runtime, opt->name, spaces (opt->name, 5)); + + if (opt->description) + printf ("%s", opt->description); + printf ("\n"); + + if (opt->flags & GPGME_CONF_DEFAULT) + { + printf ("%s%s = ", spaces (NULL, 0), opt->argname ? opt->argname : "(default)"); + dump_arg (opt->type, opt->default_value); + printf ("\n"); + } + else if (opt->flags & GPGME_CONF_DEFAULT_DESC) + printf ("%s%s = %s\n", spaces (NULL, 0), opt->argname ? opt->argname : "(default)", + opt->default_description); + + if (opt->no_arg_value) + { + printf ("%sNo Arg Def = ", spaces (NULL, 0)); + dump_arg (opt->type, opt->no_arg_value); + printf ("\n"); + } + if (opt->value) + { + printf ("%sCurrent = ", spaces (NULL, 0)); + dump_arg (opt->type, opt->value); + printf ("\n"); + } + } + +#if 0 + arg = comp->options; + while (opt) + { + dump_opt (opt); + opt = opt->next; + } +#endif +} + + +void +dump_comp (gpgme_conf_comp_t comp) +{ + gpgme_conf_opt_t opt; + + printf ("COMPONENT\n"); + printf ("=========\n"); + printf (" Name: %s\n", comp->name); + if (comp->description) + printf (" Desc: %s\n", comp->description); + if (comp->program_name) + printf (" Path: %s\n", comp->program_name); + printf ("\n"); + + opt = comp->options; + while (opt) + { + dump_opt (opt); + opt = opt->next; + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_conf_comp_t conf; + gpgme_conf_comp_t comp; + int first; + init_gpgme (GPGME_PROTOCOL_GPGCONF); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_op_conf_load (ctx, &conf); + fail_if_err (err); + + comp = conf; + first = 1; + while (comp) + { + if (!first) + printf ("\n"); + else + first = 0; + dump_comp (comp); + comp = comp->next; + } + +#if 1 + /* Now change something. */ + { + unsigned int count = 1; + gpgme_conf_arg_t arg; + gpgme_conf_opt_t opt; + + err = gpgme_conf_arg_new (&arg, GPGME_CONF_NONE, &count); + fail_if_err (err); + + comp = conf; + while (comp && strcmp (comp->name, "dirmngr")) + comp = comp->next; + opt = comp->options; + while (opt && strcmp (opt->name, "verbose")) + opt = opt->next; + + err = gpgme_conf_opt_change (opt, 0, arg); + fail_if_err (err); + + err = gpgme_op_conf_save (ctx, comp); + fail_if_err (err); + } +#endif + + gpgme_conf_release (conf); + + return 0; +} diff -urpNP gpgme-1.1.5/tests/gpg/t-support.h gpgme-1.1.6/tests/gpg/t-support.h --- gpgme-1.1.5/tests/gpg/t-support.h 2005-09-25 19:26:35.000000000 +0000 +++ gpgme-1.1.6/tests/gpg/t-support.h 2007-09-27 13:00:05.000000000 +0000 @@ -24,6 +24,10 @@ #include #include +#ifdef HAVE_W32_SYSTEM +#include +#endif + #include #ifndef DIM @@ -65,7 +69,13 @@ gpgme_error_t passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, int last_was_bad, int fd) { +#ifdef HAVE_W32_SYSTEM + DWORD written; + WriteFile ((HANDLE) fd, "abc\n", 4, &written, 0); +#else write (fd, "abc\n", 4); +#endif + return 0; } diff -urpNP gpgme-1.1.5/tests/gpg/t-wait.c gpgme-1.1.6/tests/gpg/t-wait.c --- gpgme-1.1.5/tests/gpg/t-wait.c 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/gpg/t-wait.c 2007-09-27 13:00:05.000000000 +0000 @@ -1,6 +1,6 @@ /* t-wait.c - Regression test. 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. @@ -29,6 +29,10 @@ #include #include +#ifdef HAVE_W32_SYSTEM +#define sleep _sleep +#endif + #include #include "t-support.h" diff -urpNP gpgme-1.1.5/tests/gpgsm/Makefile.am gpgme-1.1.6/tests/gpgsm/Makefile.am --- gpgme-1.1.5/tests/gpgsm/Makefile.am 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/gpgsm/Makefile.am 2008-01-04 14:17:15.000000000 +0000 @@ -21,7 +21,7 @@ GPGSM = @GPGSM@ -TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= noinst_HEADERS = t-support.h TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export @@ -38,7 +38,7 @@ LDADD = ../../gpgme/libgpgme.la # and needs a working pinentry. noinst_PROGRAMS = $(TESTS) t-genkey -key_id := 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 +key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 DISTCLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ private-keys-v1.d/$(key_id).key random_seed diff -urpNP gpgme-1.1.5/tests/gpgsm/Makefile.in gpgme-1.1.6/tests/gpgsm/Makefile.in --- gpgme-1.1.5/tests/gpgsm/Makefile.in 2007-07-09 13:08:31.000000000 +0000 +++ gpgme-1.1.6/tests/gpgsm/Makefile.in 2008-01-04 14:26:40.000000000 +0000 @@ -164,6 +164,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GPG = @GPG@ +GPGCONF = @GPGCONF@ GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@ GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@ GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@ @@ -205,6 +206,8 @@ PTH_CFLAGS = @PTH_CFLAGS@ PTH_CPPFLAGS = @PTH_CPPFLAGS@ PTH_LDFLAGS = @PTH_LDFLAGS@ PTH_LIBS = @PTH_LIBS@ +QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@ +QT4_CORE_LIBS = @QT4_CORE_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SET_MAKE = @SET_MAKE@ @@ -262,7 +265,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= noinst_HEADERS = t-support.h EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \ $(key_id) @@ -270,7 +273,7 @@ EXTRA_DIST = cert_dfn_pca01.der cert_dfn INCLUDES = -I$(top_srcdir)/gpgme AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ LDADD = ../../gpgme/libgpgme.la -key_id := 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 +key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 DISTCLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ private-keys-v1.d/$(key_id).key random_seed diff -urpNP gpgme-1.1.5/tests/gpgsm/t-support.h gpgme-1.1.6/tests/gpgsm/t-support.h --- gpgme-1.1.5/tests/gpgsm/t-support.h 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/gpgsm/t-support.h 2007-07-12 18:23:13.000000000 +0000 @@ -91,9 +91,11 @@ init_gpgme (gpgme_protocol_t proto) gpgme_error_t err; gpgme_check_version (NULL); +#ifndef HAVE_W32_SYSTEM setlocale (LC_ALL, ""); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); +#endif err = gpgme_engine_check_version (proto); fail_if_err (err); diff -urpNP gpgme-1.1.5/tests/gpgsm/t-verify.c gpgme-1.1.6/tests/gpgsm/t-verify.c --- gpgme-1.1.5/tests/gpgsm/t-verify.c 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/gpgsm/t-verify.c 2007-11-26 17:33:45.000000000 +0000 @@ -34,6 +34,8 @@ #include "t-support.h" +static int got_errors; + static const char test_text1[] = "Hallo Leute!\n"; static const char test_text1f[]= "Hallo Leute?\n"; static const char test_sig1[] = @@ -60,54 +62,76 @@ check_result (gpgme_verify_result_t resu { fprintf (stderr, "%s:%i: Unexpected number of signatures\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->summary != summary) { fprintf (stderr, "%s:%i: Unexpected signature summary: " "want=0x%x have=0x%x\n", __FILE__, __LINE__, summary, sig->summary); - exit (1); + got_errors = 1; } if (strcmp (sig->fpr, fpr)) { fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n", __FILE__, __LINE__, sig->fpr); - exit (1); + got_errors = 1; } if (gpg_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); - exit (1); + got_errors = 1; } if (sig->notations) { fprintf (stderr, "%s:%i: Unexpected notation data\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->wrong_key_usage) { fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n", __FILE__, __LINE__); - exit (1); + got_errors = 1; } if (sig->validity != validity) { fprintf (stderr, "%s:%i: Unexpected validity: %i\n", __FILE__, __LINE__, sig->validity); - exit (1); + got_errors = 1; } if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); - exit (1); + got_errors = 1; } } +static void +show_auditlog (gpgme_ctx_t ctx) +{ + gpgme_error_t err; + gpgme_data_t data; + + err = gpgme_data_new (&data); + fail_if_err (err); + err = gpgme_op_getauditlog (ctx, data, GPGME_AUDITLOG_HTML); + if (err) + { + fprintf (stderr, "%s:%i: Can't get audit log: %s\n", + __FILE__, __LINE__, gpgme_strerror (err)); + if (gpg_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD) + got_errors = 1; + } + print_data (data); + gpgme_data_release (data); +} + + + int main (int argc, char **argv) { @@ -135,6 +159,8 @@ main (int argc, char **argv) "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", GPG_ERR_NO_ERROR, GPGME_VALIDITY_FULL); + show_auditlog (ctx); + /* Checking a manipulated message. */ gpgme_data_release (text); err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0); @@ -147,6 +173,10 @@ main (int argc, char **argv) "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", GPG_ERR_BAD_SIGNATURE, GPGME_VALIDITY_UNKNOWN); + show_auditlog (ctx); + + gpgme_data_release (text); + gpgme_data_release (sig); gpgme_release (ctx); - return 0; + return got_errors? 1 : 0; } diff -urpNP gpgme-1.1.5/tests/t-engine-info.c gpgme-1.1.6/tests/t-engine-info.c --- gpgme-1.1.5/tests/t-engine-info.c 2005-09-08 14:42:32.000000000 +0000 +++ gpgme-1.1.6/tests/t-engine-info.c 2007-09-27 13:00:05.000000000 +0000 @@ -1,5 +1,5 @@ /* t-engine-info.c - Regression test for gpgme_get_engine_info. - Copyright (C) 2003, 2004 g10 Code GmbH + Copyright (C) 2003, 2004, 2007 g10 Code GmbH This file is part of GPGME. @@ -54,13 +54,13 @@ check_engine_info (gpgme_engine_info_t i } if (strcmp (info->file_name, file_name)) { - fprintf (stderr, "Unexpected file name to executable %s (expected %s instead)", + fprintf (stderr, "Unexpected file name to executable %s (expected %s instead)\n", info->file_name, file_name); exit (1); } if (strcmp (info->req_version, req_version)) { - fprintf (stderr, "Unexpected required version %s (expected %s instead)", + fprintf (stderr, "Unexpected required version %s (expected %s instead)\n", info->req_version, req_version); exit (1); } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQCVAwUBR35ElPuIYr380qKTAQLDTAP/bQOaPmib2GZnAHvaXFg6ddLYtQdUNz0h tvd4TQ6XSjyDj8IEnO8RKKbllwBZKY5RWmqrKQPbjSATStjt+CUW+VmUpWSO9ABc oZ4K9139i/Wy9nrfZQZE6QeUuCsRqZnhXDNmktU3pZ10hFcjpJSnpbOVpT2l/Rvl VbLtbIdjrYo= =1MHV -----END PGP SIGNATURE-----