Page MenuHome GnuPG

No OneTemporary

diff --git a/ChangeLog b/ChangeLog
index 1fd5a52..0e89ce3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,189 +1,193 @@
+2006-10-09 Werner Koch <wk@g10code.com>
+
+ * m4/gnupg-pth.m4: New. Taked from GnuPG.
+
2006-10-04 Werner Koch <wk@g10code.com>
Released 0.9.2.
2006-10-04 Werner Koch <wk@g10code.com>
Released 0.9.1.
* configure.ac (AB_INIT): New.
* m4/autobuild.m4: New.
2006-09-19 Werner Koch <wk@g10code.com>
* tests/fdpassing.c: Reverted Marcus changes.
(client): New arg FNAME to replace hardwired file name.
(main): Pass motd to client.
* tests/Makefile.am (AM_CPPFLAGS): Removed.
(EXTRA_DIST): Add motd.
2006-09-19 Marcus Brinkmann <marcus@g10code.de>
* tests/fdpassing.c (MOTD): New macro.
* tests/Makefile.am (AM_CPPFLAGS): New variable.
* tests/motd: New file.
2006-09-14 Werner Koch <wk@g10code.com>
Released 0.9.0.
* configure.ac: Check for S_PEERCRED. Include check for socklen_t.
* m4/sys_socket_h.m4, m4/onceonly.m4, m4/socklen.m4: New.
* m4/Makefile.am: New.
2006-09-05 Werner Koch <wk@g10code.com>
* configure.ac (AH_BOTTOM): Define _ASSUAN_IN_LIBASSUAN.
2005-10-24 Werner Koch <wk@g10code.com>
* COPYING.LESSER: Added.
* README.CVS: Renamed to ..
* README.SVN: .. this.
2005-10-08 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Check for socket library and add it to
LIBASSUAN_CONFIG_LIBS if necessary.
2005-10-07 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Invoke AC_CANONICAL_HOST. Define _XOPEN_SOURCE,
_XOPEN_SOURCE_EXTENDED and __EXTENSIONS__ on Solaris.
Add stpcy as replacement function.
Add setenv as replacement function (and check for unistd.h).
2005-06-20 Werner Koch <wk@g10code.com>
Released 0.6.10.
2004-12-22 Werner Koch <wk@g10code.com>
Released 0.6.9.
For security reasons switched to automake 1.9.
2004-12-18 Werner Koch <wk@g10code.com>
* autogen.sh: Add Option --build-w32.
2004-12-07 Werner Koch <wk@g10code.com>
* configure.ac: Define HAVE_W32_SYSTEM and HAVE_DOSISH_SYSTEM.
Add -lwsock2 to the config lib flags for W32.
2004-11-25 Werner Koch <wk@g10code.com>
Released 0.6.8.
2004-09-27 Werner Koch <wk@g10code.com>
* config.sub, config.guess: Updated.
2004-06-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Check for <sys/uio.h>.
2004-06-08 Werner Koch <wk@gnupg.org>
Released 0.6.6.
2004-04-02 Thomas Schwinge <schwinge@nic-nac-project.de>
* autogen.sh: Added ACLOCAL_FLAGS.
2004-02-20 Werner Koch <wk@gnupg.org>
Released 0.6.4.
2004-02-11 Werner Koch <wk@gnupg.org>
* autogen.sh (check_version): Removed bashism and simplified.
2004-01-29 Werner Koch <wk@gnupg.org>
Released 0.6.3.
2003-12-18 Werner Koch <wk@gnupg.org>
Released 0.6.2.
2003-12-08 Werner Koch <wk@gnupg.org>
* TODO: New.
* Makefile.am: Add README.CVS and autogen.sh. Removed m4/Makefile.
* README.CVS: New.
* autogen.sh: Revamped.
* configure.ac: Add automake version number for autogen.sh use.
2003-11-17 Werner Koch <wk@gnupg.org>
Released 0.6.1.
2003-08-06 Werner Koch <wk@gnupg.org>
Released 0.6.0.
2003-07-29 Werner Koch <wk@gnupg.org>
* configure.ac: Cleanups for newer autoconf.
2003-07-29 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.am (EXTRA_DIST): Add config.rpath.
* configure.ac (AC_CONFIG_FILES): Add po/Makefile.in,
2003-04-28 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.am (SUBDIRS): Add m4.
(ACLOCAL_AMFLAGS): New variable.
(EXTRA_DIST): New variable.
* configure.ac (AC_CONFIG_FILES): Add po/Makefile.in,
2003-02-18 Neal H. Walfield <neal@g10code.de>
* COPYING: New file.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* configure.ac: Fix typo.
(AC_CONFIG_FILES): Remove common/Makefile.am.
* common: Remove directory.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* common: New directory.
* Makefile.am (SUBDIRS): Add common.
* configure.ac: Check for funopen. If not present, check for
fopencookie and implement it in terms of that. Otherwise, fail.
(AC_CONFIG_FILES): Add common/Makefile.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* configure.ac (AC_CONFIG_FILES): Add src/libassuan-config.
(LIBASSUAN_CONFIG_LIBS, LIBASSUAN_CONFIG_CFLAGS): New variables.
AC_SUBST them.
2003-02-17 Neal H. Walfield <neal@g10code.de>
* AUTHORS: New file.
* INSTALL: New file.
* Makefile.am: New file.
* NEWS: New file.
* README: New file.
* autogen.sh: New file, copied from newpg.
* configure.ac: New file, imported from newpg.
* depcomp: New file.
* install-sh: New file.
* missing: New file.
* mkinstalldirs: New file.
* doc: New directory.
* src: New directory.
* tests: New directory.
diff --git a/NEWS b/NEWS
index 3e95ee2..a684131 100644
--- a/NEWS
+++ b/NEWS
@@ -1,134 +1,139 @@
+Noteworthy changes in version 0.9.3
+------------------------------------------------
+
+
+
Noteworthy changes in version 0.9.2 (2006-10-04)
------------------------------------------------
* A fix to make CANCEL work again in Pinentries.
Noteworthy changes in version 0.9.1 (2006-10-04)
------------------------------------------------
* Minor bug fixes
* Portability fixes.
Noteworthy changes in version 0.9.0 (2006-09-14)
------------------------------------------------
* Internal cleanups to make inclusion of the code into libraries
easier.
* Made clear that the software is under the LGPL.
* New function assuan_set_assuan_err_source. All gpg-error enabled
software should call this right at startup to switch libassuan into
the gpg-error style mode. All error codes are then returned as
gpg-error style codes (GPG_ERR_ASS_* as well as others).
If the new macro _ASSUAN_ONLY_GPG_ERRORS is defned all old
definitions are excluded from assuan.h.
* Logging of hex strings is now limited to 16 bytes. To enable
printing of the full data, a new environment variable
ASSUAN_FULL_LOGGING may be set to any value.
* Removed the assuan_domain_* functions.
* New functions assuan_pipe_connect_ext and assuan_socket_connect_ext
to allow connections on a socketpair and to pass descriptors.
* New function assuan_get_peercred.
Noteworthy changes in version 0.6.10 (2005-06-20)
-------------------------------------------------
* New functions assuan_get_flag and assuan_set_flag.
* Add flag ASSUAN_NO_WAITPID.
Noteworthy changes in version 0.6.9 (2004-12-22)
------------------------------------------------
* Ported to W32 based systems.
Noteworthy changes in version 0.6.8 (2004-11-25)
------------------------------------------------
* assuan_write_status does now return an error code.
* Fixes for C89 compatibility and some first takes on a W32 port.
Noteworthy changes in version 0.6.7 (2004-09-27)
------------------------------------------------
* Minor build fixes.
Noteworthy changes in version 0.6.6 (2004-06-08)
------------------------------------------------
* assuan_set_hello_line may now take a multi line argument where the
first lines are send as comment lines and the last one as a OK
line.
Noteworthy changes in version 0.6.5 (2004-04-29)
------------------------------------------------
* Pass the client's pid to a pipe server.
Noteworthy changes in version 0.6.4 (2004-02-20)
------------------------------------------------
* Will now also build on systems not providing funopen or
fopencookie.
* Some smaller build fixes.
Noteworthy changes in version 0.6.3 (2004-01-29)
------------------------------------------------
* Fixed a data corruption bug in assuan_get_data_fp.
* New function assuan_pipe_connect2.
Noteworthy changes in version 0.6.2 (2003-12-18)
------------------------------------------------
* New function assuan_set_assuan_log_prefix to store a log prefix to
be used when no context is available. The existing function
assuan_get_assuan_log_context is not anymore declared as user
overridable.
* Documentation cleanups.
Noteworthy changes in version 0.6.1 (2003-11-17)
------------------------------------------------
* Fixed a bug in assuan_inquire which led to an Invalid_Value error
for large inquiry parameters.
* Fixed a bug in the client socket connect code.
Noteworthy changes in version 0.6.0 (2003-08-06)
------------------------------------------------
* Initial release as a standalone library.
Copyright 2003, 2004 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/configure.ac b/configure.ac
index 7557b54..0c8bdff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,200 +1,215 @@
# configure.ac - for libassuan
# Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc,
#
# This file is part of Assuan.
#
# Assuan 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.
#
# Assuan 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., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
min_automake_version="1.9.3"
# Version number: Remember to change it immediately *after* a release.
# Add a "-cvs" prefix for non-released code.
-AC_INIT(libassuan, 0.9.2, gnupg-devel@gnupg.org)
+AC_INIT(libassuan, 0.9.3-cvs, gnupg-devel@gnupg.org)
# Note, that this is not yet available as a shared library.
PACKAGE=$PACKAGE_NAME
VERSION=$PACKAGE_VERSION
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR(src/assuan.h)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
AB_INIT
AC_GNU_SOURCE
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
[Bug report address])
# Checks for programs.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
#AC_ARG_PROGRAM
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
fi
AH_BOTTOM([
#define _ASSUAN_IN_LIBASSUAN 1
])
#
# Options depending on the host OS.
#
have_dosish_system=no
have_w32_system=no
case "${host}" in
*-mingw32*)
have_dosish_system=yes
have_w32_system=yes
;;
*-solaris*)
AC_DEFINE(_XOPEN_SOURCE, 500, Activate extensions on Solaris)
AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Activate extensions on Solaris)
AC_DEFINE(__EXTENSIONS__, 1, Activate extensions on Solaris)
;;
esac
if test "$have_dosish_system" = yes; then
AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
[Defined if we run on some of the PCDOS like systems
(DOS, Windoze. OS/2) with special properties like
no file modes])
fi
dnl AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
if test "$have_w32_system" = yes; then
AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
fi
dnl AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
+#
+# See whether we can build a Pth enabled version
+#
+GNUPG_PATH_PTH
+AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
+
+
# Check for network libraries.
NETLIBS=
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
[NETLIBS="-lsocket"]))
# For src/libassuan-config.in
-LIBASSUAN_CONFIG_LIBS="-lassuan"
+LIBASSUAN_CONFIG_LIB="-lassuan"
LIBASSUAN_CONFIG_CFLAGS=""
+LIBASSUAN_CONFIG_API_VERSION="1"
+LIBASSUAN_CONFIG_THREAD_MODULES=
+if test "$have_pth" = yes; then
+LIBASSUAN_CONFIG_THREAD_MODULES="pth"
+fi
+LIBASSUAN_CONFIG_EXTRA_LIBS=
if test "$have_w32_system" = yes; then
- LIBASSUAN_CONFIG_LIBS="$LIBASSUAN_CONFIG_LIBS -lwsock32"
+ LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lwsock32"
fi
if test x"$NETLIBS" != x; then
- LIBASSUAN_CONFIG_LIBS="$LIBASSUAN_CONFIG_LIBS $NETLIBS"
+ LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS"
fi
-AC_SUBST(LIBASSUAN_CONFIG_LIBS)
+AC_SUBST(LIBASSUAN_CONFIG_LIB)
AC_SUBST(LIBASSUAN_CONFIG_CFLAGS)
-
+AC_SUBST(LIBASSUAN_CONFIG_API_VERSION)
+AC_SUBST(LIBASSUAN_CONFIG_THREAD_MODULES)
+AC_SUBST(LIBASSUAN_CONFIG_EXTRA_LIBS)
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([string.h locale.h sys/uio.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST
gl_TYPE_SOCKLEN_T
# Checks for library functions.
AC_CHECK_FUNCS(flockfile funlockfile)
# Check for funopen
AC_CHECK_FUNCS(funopen)
if test $ac_cv_func_funopen != yes; then
# No funopen but we can implement that in terms of fopencookie.
AC_CHECK_FUNCS(fopencookie)
if test $ac_cv_func_fopencookie = yes; then
AC_LIBOBJ([funopen])
else
AC_MSG_WARN([
***
*** No implementation of fopencookie or funopen available.
*** The assuan_get_data_fp feature won't work.
***])
fi
fi
AC_REPLACE_FUNCS(isascii)
AC_REPLACE_FUNCS(putc_unlocked)
AC_REPLACE_FUNCS(memrchr)
AC_REPLACE_FUNCS(stpcpy)
# Check for unistd.h for setenv replacement function.
AC_CHECK_HEADERS(unistd.h)
AC_REPLACE_FUNCS(setenv)
#
# Check for the getsockopt SO_PEERCRED
#
AC_MSG_CHECKING(for SO_PEERCRED)
AC_CACHE_VAL(assuan_cv_sys_so_peercred,
[AC_TRY_COMPILE([#include <sys/socket.h>],
[struct ucred cr;
int cl = sizeof cr;
getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
assuan_cv_sys_so_peercred=yes,
assuan_cv_sys_so_peercred=no)
])
AC_MSG_RESULT($assuan_cv_sys_so_peercred)
if test $assuan_cv_sys_so_peercred = yes; then
AC_DEFINE(HAVE_SO_PEERCRED, 1,
[Defined if SO_PEERCRED is supported (Linux specific)])
fi
# Create the config files.
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([m4/Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([doc/Makefile])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([src/libassuan-config], [chmod +x src/libassuan-config])
AC_OUTPUT
diff --git a/doc/assuan.texi b/doc/assuan.texi
index 2422f73..d83a812 100644
--- a/doc/assuan.texi
+++ b/doc/assuan.texi
@@ -1,915 +1,937 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename assuan.info
@macro copyrightnotice
Copyright @copyright{} 2002, 2003, 2006 Free Software Foundation, Inc.
@end macro
@macro permissionnotice
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. The text of the license can be found in the
section entitled ``Copying''.
@end macro
@include version.texi
@settitle Developing with Assuan
@c Create a separate index for command line options.
@defcodeindex op
@c Merge the standard indexes into a single one.
@syncodeindex fn cp
@syncodeindex vr cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp
@c A simple macro for optional variables.
@macro ovar{varname}
@r{[}@var{\varname\}@r{]}
@end macro
@c printing stuff taken from gcc.
@macro gnupgtabopt{body}
@code{\body\}
@end macro
@macro gnupgoptlist{body}
@smallexample
\body\
@end smallexample
@end macro
@c Makeinfo handles the above macro OK, TeX needs manual line breaks;
@c they get lost at some point in handling the macro. But if @macro is
@c used here rather than @alias, it produces double line breaks.
@iftex
@alias gol = *
@end iftex
@ifnottex
@macro gol
@end macro
@end ifnottex
@c Change the font used for @def... commands, since the default
@c proportional one used is bad for names starting __.
@tex
\global\setfont\defbf\ttbshape{10}{\magstep1}
@end tex
@c %**end of header
@ifnottex
@dircategory GNU Libraries
@direntry
* Assuan: (assuan). An IPC library for non-persistent servers.
@end direntry
This file documents the use and the internals of Assuan.
This is Edition @value{EDITION}, last updated @value{UPDATED}, of
@cite{The `Developing with Assuan' Manual}, for Version @value{VERSION}.
@sp 1
Published by the Free Software Foundation@*
51 Franklin Street, Fifth Floor@*
Boston, MA 02110-1301 USA
@sp 1
@copyrightnotice{}
@sp 1
@permissionnotice{}
@end ifnottex
@setchapternewpage odd
@titlepage
@title Developing with Assuan
@subtitle Version @value{VERSION}
@subtitle @value{UPDATED}
@author Werner Koch @code{(wk@@gnupg.org)}
@page
@vskip 0pt plus 1filll
@copyrightnotice{}
@sp 2
@permissionnotice{}
@end titlepage
@summarycontents
@contents
@page
@ifnottex
@node Top
@top Introduction
@cindex introduction
This manual documents how to exploit the Assuan library, a simple
interprocess communcation library.
@end ifnottex
@menu
* Introduction:: An introduction to and the motivation behind Assuan.
* Assuan:: Description of the Assuan protocol.
* Implementation:: Overview of the implementation.
* Preparation:: What you should do before using the library.
* Generalities:: Initialization code and data types used.
* Client code:: How to develop an Assuan client.
* Server code:: How to develop an Assuan server.
* Utilities:: Utility functions.
Miscellaneous
* Library Copying:: GNU Lesser General Public License says
how you can copy and share Assuan.
* Copying:: How you can copy and share this manual.
Indices
* Index:: Index of concepts and symbol names.
@end menu
@c
@c I N T R O
@c
@node Introduction
@chapter Introduction to Assuan
In an ideal world, Assuan is irrelevant. Assuan's primary use is to
allow a client to interact with a non-persistent server. Using
Assuan, this is accomplished by forking a subprocess and communicating
with it via, for example, a pipe or unix domain socket. This method
is neither elegant nor efficient especially when there is a lot of
data spread across several transactions: not only is there a penalty
for an increased number of context switches, but also a significant
amount of data is @var{memcpy}ed from the client to a file descriptor
and from the file descriptor to the server. Despite these and other
disadvantages, this type of client/server communication can be useful:
the client is completely separate from the server; they are in
different address spaces. This is especially important in situations
where the server must have a known degree of reliability and data must
be protected: as the Assuan protocol is well defined and clients
cannot corrupt the servers' address space, auditing become much
easier.
Assuan was developed for use by the GNU Privacy Guard, GnuPG, to
prevent potentially buggy clients from unwittingly corrupting
sensitive transactions or compromising data such as a secret key.
Assuan permits the servers, which do the actual work, e.g. encryption
and decryption of data using a secret key, to be developed
independently of the user interfaces, e.g. mail clients and other
encryption front ends. Like a shared library, the interface is well
defined and any number of front ends can use it; however, unlike a
shared library, the client cannot see or touch the server's data. As
with any modular system, Assuan helps keep the servers small and
understandable help to make code more understandable and less error
prone.
Assuan is not, however, limited to use with GnuPG servers and clients:
it was design to be flexible enough to meet the demands of almost any
transaction based environment with non-persistent servers.
@node Assuan
@chapter Description of the Assuan protocol.
The architecture of the modular GnuPG system is based on several
highly specialized modules which compose a network of client/server
communication. A common framework for intermodule communication is
therefore needed and should be implemented in a library.
Goals:
@itemize @bullet
@item Common framework for module communication
@item Easy debugging
@item Easy module testing
@item Extendible
@item Optional authentication and encryption facility
@item Usable to access external hardware
@end itemize
Design criteria:
@itemize @bullet
@item Client server with back channel
@item Use a mainly text based protocol
@item Escape certain control characters
@item Allow indefinite data length
@item Request confidentiality for parts of the communication
@item Dummy module to allow direct linking of client and server
@item Inline data or descriptor passing for bulk data
@item No protection against DoS needed
@item Subliminal channels are not an issue
@end itemize
@node Implementation
@chapter Implementation
The implementation is line based with a maximum line size of 1000
octects. The default IPC mechanism are Unix Domain Sockets.
On a connect request the server responds either with an okay or an error
status. For authentication check the server may send an Inquiry
Response prior to the first Okay, it may also issue Status messages.
The server must check that the client is allowed to connect, this is
done by requesting the credentials for the peer and comparing them to
those of the server. This avoids attacks based on wrong socket
permissions.
It may choose to delay the first response in case of an error. The
server never closes the connection - however the lower protocol may do
so after some time of inactivity or when the connection is in an error
state.
All textual messages are assumed to be in UTF-8 unless otherwise noted.
@menu
* Server responses:: Description of server responses.
* Client requests:: Description of client requests.
* Error codes:: List of error and status codes.
@end menu
@node Server responses
@section Server responses
@table @code
@item OK [<arbitary debugging information>]
Request was successful.
@item ERR @var{errorcode} [<human readable error description>]
Request could not be fulfilled. The error codes are mostly application
specific except for a few common ones.
@item S @var{keyword} <status information depending on keyword>
Informational output by the server, still processing the request.
@item # <string>
Comment line issued only for debugging purposes. Totally ignored.
@item D <raw data>
Raw data returned to client. There must be exactly one space after the
'D'. The values for '%', CR and LF must be percent escaped; this is
encoded as %25, %0D and %0A. Only uppercase letters should be used in
the hexadecimal representation. Other characters may be percent escaped
for easier debugging. All these Data lines are considered one data
stream up to the OK or ERR response. Status and Inquiry Responses
may be mixed with the Data lines.
@item INQUIRE @var{keyword}> <parameters>
Server needs further information from the client. The client should
answer with a command which is allowed after an inquiry. Note that the
server does not confirm that client command but either continues
processing or ends processing with an error status. Not all commands
are allowed.
@end table
A client should only check the first letter of each line and then skip
over to the next token (except for data lines where the raw data starts
exactly after 2 bytes). Lines larger than 1000 bytes should be
treated as a communication error. (The rationale for having a line
length limit is to allow for easier multiplexing of several channels).
@node Client requests
@section Client requests
The server waits for client requests after he sent an Okay or Error.
The client should not issue a request in other cases.
@example
@var{command} <parameters>
@end example
@var{command} is a one word string without preceding white space.
Parameters are command specific, CR, LF and the percent signs should be
percent escaped as described above. To send a backslash as the last
character it should also be percent escaped. Percent escaping is
allowed anywhere in the parameters but not in the command. The line
ends with a CR, LF or just a LF.
Not yet implemented feature: If there is a need for a parameter list
longer than the line length limit (1000 characters including command and
CR, LF), the last character of the line (right before the CR/LF or LF)
must be a non-escape encoded backslash. The following line is then
expected to be a continuation of the line with the backslash replaced by
a blank and the line ending removed.
@example
D <raw data>
@end example
Raw data to the server. There must be exactly one space after the 'D'.
The values for '%', CR and LF must be percent escaped; this is encoded
as %25, %0D and %0A. Only uppercase letters should be used in the
hexadecimal representation. Other characters may be percent escaped for
easier debugging. All these Data lines are considered one data stream
up to the OKAY or ERROR response. Status and Inquiry Responses may be
mixed with the Data lines.
@example
END
@end example
Lines beginning with a @code{#} or empty lines are ignored. This is
useful to comment test scripts.
Although the commands are application specific, some of them are used by
all protocols and partly directly supported by the Assuan library:
@table @code
@item CANCEL
This command is used for future extenxions. It may today be used to
cancel outstanding requests in an asynchronous protocol.
@item BYE
Close the connect, the server will reply with an @code{OK}.
@item AUTH
Not yet specified as we don't implement it in the first phase. See my
mail to gpa-dev on 2001-10-25 about the rationale for measurements
against local attacks.
@item RESET
Reset the connection but not any existing authentication. The server
should release all resources associated with the connection.
@item END
Used by a client to mark the end of raw data. The server may send END
to indicate a partial end of data.
@item HELP
Reserved for future extensions.
@item QUIT
Reserved for future extensions.
@end table
@node Error codes
@section Error codes
Here we keep a list of error codes used in any Assuan based
protocol. The format is the string @code{ERR}, white space, the error
number, white space, a textual description of the error.
General error codes pertaining to the actual Assuan operations:
@table @code
@item 0 Success
@item 1 General error
@item 2 Out of core
@item 3 Invalid value
@item 4 Timeout
@item 5 Read error
@item 6 Write error
@item 7 Problem starting server
@item 8 Not a server
@item 9 Not a client
@item 10 Nested commands
@item 11 Invalid response
@item 12 No data callback
@item 13 No inquire callback
@item 14 Connect failed
@item 15 Accept failed
@end table
Error codes used as status codes in the Assuan protocol:
@table @code
@item 100 Not implemented
@item 101 Server fault (catch all error code)
@item 102 Invalid command
@item 103 Unknown command
@item 104 Syntax error
@item 105 Parameter error
@item 106 Parameter conflict
@item 107 Line too long
@item 108 Line not terminated
@item 109 No input
@item 110 No output
@item 111 Canceled
@item 112 Unsupported algorithm
@item 113 Server resource problem
@item 114 Server I/O error
@item 115 Server bug
@item 116 No data available
@item 117 Invalid data
@item 118 Unexpected command
@item 119 Too much data
@item 120 Inquire unknown
@item 121 Inquire error
@item 122 Invalid option
@item 123 Invalid index
@item 124 Unexpected status
@item 125 Unexpected data
@item 126 Invalid status
@item 128 Not confirmed
@end table
For historical reasons a few more error codes are defined in
@file{assuan.h}; they should not be used by new applications.
Errror codes in the range @var{ASSUAN_USER_ERROR_FIRST} to
@var{ASSUAN_USER_ERROR_LAST} may be used at the applications own
discretion. Error codes greater than 65535 are not defined by Assuan
and may also be used by applications --- note that the GnuPG system
maps libgpg-error codes into this range.
@c
@c P R E P A R A T I O N
@c
@node Preparation
@chapter Preparation
To use `@sc{libassuan}', you have to perform some changes to your
sources and the build system. The necessary changes are small and
explained in the following sections.
@menu
* Header:: What header file you need to include.
* Building sources:: How to build sources using the library.
* Automake:: How to build sources with the help of Automake.
* Multi Threading:: How @sc{libassuan} can be used in a MT environment.
@end menu
@node Header
@section Header
All interfaces (data types and functions) of @sc{libassuan} are defined
in the header file @file{assuan.h}. You must include this in all source
files using the library, either directly or through some other header
file, like this:
@example
#include <assuan.h>
@end example
The name space of `@sc{assuan}' is @code{assuan_*} for function
and type names and @code{ASSUAN*} for other symbols. In addition the
same name prefixes with one prepended underscore are reserved for
internal use and should never be used by an application.
@node Building sources
@section Building sources
If you want to compile a source file including the @file{assuan.h}
header file, you must make sure that the compiler can find it in the
directory hierarchy. This is accomplished by adding the path to the
directory in which the header file is located to the compilers include
file search path (via the @option{-I} option).
However, the path to the include file is determined at the time the
source is configured. To solve this problem, @sc{libgcrypt} ships with
a small helper program @command{libassuan-config} that knows the path to
the include file and other configuration options. The options that need
to be added to the compiler invocation at compile time are output by the
@option{--cflags} option to @command{libassuan-config}. The following
example shows how it can be used at the command line:
@example
gcc -c foo.c $(libassuan-config --cflags)
@end example
Adding the output of @samp{libassuan-config --cflags} to the compiler's
command line will ensure that the compiler can find the @file{assuan.h}
header file.
A similar problem occurs when linking the program with the library.
Again, the compiler/linker has to find the library files. For this to
work, the path to the library files has to be added to the library
search path (via the @option{-L} option). For this, the option
@option{--libs} to @command{libassuan-config} can be used. For
convenience, this option also outputs all other options that are
required to link the program with the @sc{libassuan} libraries (in
particular, the @option{-lassuan} option). The example shows how to
link @file{foo.o} with the @sc{libassuan} library to a program
@command{foo}.
@example
gcc -o foo foo.o $(libassuan-config --libs)
@end example
Of course you can also combine both examples to a single command by
specifying both options to @command{libassuan-config}:
@example
gcc -o foo foo.c $(libassuan-config --cflags --libs)
@end example
+If your application uses Pth or pthread, you need to pass the option
+@option{--thread=pth} respective @option{--thread=pthread} to the
+invocation of @command{libassuan-config}.
+
+
@node Automake
@section Building sources using Automake
It is much easier if you use GNU Automake instead of writing your own
Makefiles. If you do that you do not have to worry about finding and
invoking the @command{libassuan-config} script at all. @sc{libassuan}
provides an Automake macro that does all the work for you.
@defmac AM_PATH_LIBASSUAN (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
Check whether @sc{libassuan} (at least version @var{minimum-version}, if
given) exists on the host system. If it is found, execute
@var{action-if-found}, otherwise do @var{action-if-not-found}, if given.
Additionally, the function defines @code{LIBASSUAN_CFLAGS} to the
flags needed for compilation of the program to find the
@file{assuan.h} header file, and @code{LIBASSUAN_LIBS} to the linker
flags needed to link the program to the @sc{libassuan} library.
@end defmac
You can use the defined Autoconf variables like this in your
@file{Makefile.am}:
@example
AM_CPPFLAGS = $(LIBASSUAN_CFLAGS)
LDADD = $(LIBASSUAN_LIBS)
@end example
+@defmac AM_PATH_LIBASSUAN_PTH (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
+Same as @code{AM_PATH_LIBASSUAN} but checks for the GNU Pth enabled
+version of the library and defines @code{LIBASSUAN_PTH_CFLAGS}
+@code{LIBASSUAN_PTH_LIBS} instead. Use this is you are using GNU Pth.
+Note that you also need to pass the appropriate options for Pth to the
+compiler and linker.
+@end defmac
+
+@defmac AM_PATH_LIBASSUAN_PTHREAD (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
+Same as @code{AM_PATH_LIBASSUAN} but checks for the pthreads enabled
+version of the library and defines @code{LIBASSUAN_PTHREAD_CFLAGS}
+@code{LIBASSUAN_PTHREAD_LIBS} instead. Use this is you are using GNU Pth.
+Note that you also need to pass the appropriate options for Pth to the
+compiler and linker.
+@end defmac
+
+
@node Multi Threading
@section Multi Threading
The @sc{libgcrypt} library is thread-safe if you adhere to the following
requirements:
@itemize @bullet
@item Run the initialization functions before you actually start
to use threads.
@item Only one thread at a time may access an @sc{libassuan} context.
@item Use @code{assuan_set_assuan_log_stream} to setup a default log stream.
@end itemize
@c
@c G E N E R A L I T I E S
@c
@node Generalities
@chapter Generalities
@menu
* Data Types:: Data types used by @sc{libassuan}.
* Initializing the library:: How to initialize the library.
* Reading and Writing:: How to communicate with the peer.
@end menu
@node Data Types
@section Data Types used by the library
@sc{libassuan} uses a context approach to keep state. The following
data type is used all over the place:
@deftp {Data type} assuan_context_t
The @code{assuan_context_t} type is a pointer to an object mainted
internally by the library. Certain Assuan functions allocate such a
context and return it to the caller using this data type. Other
functions take this data type to access the state created by these
functions.
@end deftp
@noindent
For compatibility with older versions of @sc{libassuan} a data
type for error return values exists:
@deftp {Data type} assuan_error_t
This has orginally been an @code{enum} but applications should either
view it as an @code{int} or if possible use the @code{gpg_error_t} data
type as defined by the @sc{libgpg-error} package.
@end deftp
@node Initializing the library
@section Initializing the library
In general the library requires no initialization. There are however
some initialization hooks provided which aren often useful. These
should be called as early as possible and in a multi-threaded
application before a second thread is created.
If your application uses its own memory allocation functions or wrappers
it is good idea to tell @sc{libassuan} about it so it can make use of the
same functions or wrappers. You do this with
@deftypefun void assuan_set_malloc_hooks (@w{void *(*@var{malloc_func})(size_t)}, @w{void *(*@var{realloc_func})(void *, size_t)}, @w{void (*@var{free_func})(void*)})
You need to provide all three functions. Those functions need to behave
exactly as their standard counterparts (@code{malloc}, @code{realloc}
and @code{free}). If you write your own functions please take care to
set @code{errno} whenever an error has occured.
@end deftypefun
@noindent
To integrate assuan logging and diagnostics into your own logging
system, you may use the following two functions:
@deftypefun void assuan_set_assuan_log_stream (FILE *@var{fp})
This sets the stream to which @sc{libassuan} should log messages not
associated with a specific context to @var{fp}. The default is to log
to @code{stderr}. This default value is also changed by using
@code{assuan_set_log_stream} (to set a logging stream for a specific
context) unless this function has been used. Obviously this is not
thread-asfe and thus it is highly recommended to use this function to
setup a proper default.
@end deftypefun
@deftypefun void assuan_set_assuan_log_prefix (@w{const char *@var{text}})
Set the prefix to be used at the start of a line emitted by assuan
on the log stream to @var{text}. The default is the empty string.
@end deftypefun
If you intend to use @sc{libassuan} along with the package
@sc{libgpg-error} it is recommended to switch @sc{libassuan} into a mode
which directly makes use of error codes provided by @sc{libgpg-error}.
Because the Assuan error codes and those of gpg-error overlap, it is
required to explictly request this. You do this by calling the function
@deftypefun void assuan_set_assuan_err_source (int @var{errsource})
Enable gpg-error style error codes. @var{errsource} is one of the
gpg-error sources. Switching back to the old style mode is not
possible. The usual way to call this function is
@smallexample
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
@end smallexample
@end deftypefun
@node Reading and Writing
@section How to communicate with the peer
What would be a IPC library without the ability to read and write data?
Not very useful. Libassuan has high level functions to take care of of
the more boring stuff but eventully actually data needs to be written.
@noindent
The basic read and write functions are:
@deftypefun assuan_error_t assuan_read_line (@w{assuan_context_t @var{ctx}}, @w{char **@var{line}}, @w{size_t *@var{linelen}})
Read the next line from the client or server and store a pointer to the
buffer holding that line at the address @var{line}. The valid length of
the lines is stored at the address of @var{linelen}. This buffer is
valid until the next read operation on the same context @var{ctx}. You
may modify the contet of this buffer. The buffer is invalid (i.e. must
not be used) if an error is returned. This function returns @code{0} on
success or an error code.
@end deftypefun
@deftypefun assuan_error_t assuan_write_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}})
Write the string @var{line} to the other end. This string needs to be a
proper formatted Assuan protocol line and should not include a linefeed.
Sending linefeed or Nul characters is not possible and not alowed by the
assuan protocol. This fucntion shall not be used for sendind data (D)
lines. This function returns @code{0} on success or an error code.
@end deftypefun
@noindent
To actually send bulk data lines a specialized function is available:
@deftypefun assuan_error_t assuan_send_data (@w{assuan_context_t @var{ctx}}, @w{const void *@var{buffer}}, @w{size_t @var{length}})
This function is used by a server or a client to send
@var{length} bytes of bulk data in @var{buffer} to the other end.
The data will be escaped as required by the Assuan protocol and
may get buffered until a line is full. To force sending the data out
@var{buffer} may be passed as @code{NULL} and @var{length} be @code{0}.
When used by a client this flush operation does also send the
terminating @code{END} command to terminate the response on an
``INQUIRE'' response. Note, that the fucntion @code{assuan_transact}
takes care of sending this @code{END} itself.
@noindent
This function returns @code{0} on success or an error code.
@end deftypefun
@c
@c C L I E N T C O D E
@c
@node Client code
@chapter How to develop an Assuan client
assuan_error_t assuan_pipe_connect (assuan_context_t *ctx,
const char *name,
const char *const argv[],
int *fd_child_list);
assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx,
const char *name,
const char *const argv[],
int *fd_child_list,
void (*atfork) (void*, int),
void *atforkvalue);
assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx,
const char *name,
const char *const argv[],
int *fd_child_list,
void (*atfork) (void *, int),
void *atforkvalue,
unsigned int flags);
assuan_error_t assuan_socket_connect (assuan_context_t *ctx,
const char *name,
pid_t server_pid);
assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx,
const char *name,
pid_t server_pid,
unsigned int flags);
void assuan_disconnect (assuan_context_t ctx);
assuan_error_t
assuan_transact (assuan_context_t ctx,
const char *command,
int (*data_cb)(void *, const void *, size_t),
void *data_cb_arg,
int (*inquire_cb)(void*, const char *),
void *inquire_cb_arg,
int (*status_cb)(void*, const char *),
void *status_cb_arg);
/* The file descriptor must be pending before assuan_receivefd is
called. This means that assuan_sendfd should be called *before* the
trigger is sent (normally via assuan_write_line ("INPUT FD")). */
@anchor{fun-assuan_sendfd}
assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd);
assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd);
@c
@c S E R V E R C O D E
@c
@node Server code
@chapter How to develop an Assuan server
bar
int assuan_register_command (assuan_context_t ctx,
const char *cmd_string,
int (*handler)(assuan_context_t, char *));
int assuan_register_bye_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_reset_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_cancel_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_input_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *));
int assuan_register_output_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *));
int assuan_register_option_handler (assuan_context_t ctx,
int (*fnc)(assuan_context_t,
const char*, const char*));
int assuan_process (assuan_context_t ctx);
int assuan_process_next (assuan_context_t ctx);
FILE *assuan_get_data_fp (assuan_context_t ctx);
assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
assuan_error_t assuan_write_status (assuan_context_t ctx,
const char *keyword, const char *text);
/* Negotiate a file descriptor. If LINE contains "FD=N", returns N
assuming a local file descriptor. If LINE contains "FD" reads a
file descriptor via CTX and stores it in *RDF (the CTX must be
capable of passing file descriptors). */
assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
int *rfd);
assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
assuan_error_t assuan_accept (assuan_context_t ctx);
int assuan_get_input_fd (assuan_context_t ctx);
int assuan_get_output_fd (assuan_context_t ctx);
assuan_error_t assuan_close_input_fd (assuan_context_t ctx);
assuan_error_t assuan_close_output_fd (assuan_context_t ctx);
int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]);
void assuan_deinit_server (assuan_context_t ctx);
int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd);
int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd);
int assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd,
unsigned int flags);
assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
unsigned char **r_buffer, size_t *r_length,
size_t maxlen);
@c
@c U T I L I T I E S
@c
@node Utilities
@chapter Utility functions
void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
int assuan_set_error (assuan_context_t ctx, int err, const char *text);
void assuan_set_pointer (assuan_context_t ctx, void *pointer);
void *assuan_get_pointer (assuan_context_t ctx);
void assuan_begin_confidential (assuan_context_t ctx);
void assuan_end_confidential (assuan_context_t ctx);
/* For context CTX, set the flag FLAG to VALUE. Values for flags
are usually 1 or 0 but certain flags might allow for other values;
see the description of the type assuan_flag_t for details. */
void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
typedef enum
/* When using a pipe server, by default Assuan will wait for the
forked process to die in assuan_disconnect. In certain cases
this is not desirable. By setting this flag, the waitpid will
be skipped and the caller is responsible to cleanup a forked
process. */
ASSUAN_NO_WAITPID = 1
assuan_flag_t;
/* Return the VALUE of FLAG in context CTX. */
int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
const char *assuan_strerror (assuan_error_t err);
@deftypefun pid_t assuan_get_pid (@w{assuan_context_t @var{ctx}})
This function returns the pid of the connected connected peer. If that
pid is not known @code{-1} is returned. Note that it is not always
possible to learn the pid of the other process. For a pipe based server
the client knows it instantly and a mechnism is in palce to let the
server learn it. For socket based servers the pid is only available on
systems providing the ``SO_PEERCRED'' socket option @footnote{to our
knowledge only the Linux kernel has this feature}.
@end deftypefun
@deftypefun assuan_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}})
Return user credentials of the peer. This will work only on certain
systems and only when connected over a socket. If you are not
interested in some of the values, pass @code{NULL} instead of the
address of an appropriate variable. @var{pid}, @var{uid} and @var{gid}
are only set if the function succeeds and returns with @code{0}.
As of now only the server is able to retrieve this information. Note,
that for getting the pid of the peer @code{assuan_get_pid} is usually
better suited.
@end deftypefun
int assuan_get_active_fds (assuan_context_t ctx, int what,
int *fdarray, int fdarraysize);
int assuan_pending_line (assuan_context_t ctx);
/* Return the stream which is currently being using for global logging. */
FILE *assuan_get_assuan_log_stream (void);
/* Return a prefix to be used at the start of a line emitted by assuan
on the log stream. The default implementation returns the empty
string, i.e. "" */
const char *assuan_get_assuan_log_prefix (void);
@c ---------------------------------------------------------------------
@c Legal BS
@c ---------------------------------------------------------------------
@include lgpl.texi
@include gpl.texi
@c ---------------------------------------------------------------------
@c Indexes
@c ---------------------------------------------------------------------
@node Index
@unnumbered Index
@printindex cp
@c ---------------------------------------------------------------------
@c Epilogue
@c ---------------------------------------------------------------------
@bye
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 4b141b2..0848e42 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 autobuild.m4
+EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 autobuild.m4 gnupg-pth.m4
diff --git a/m4/gnupg-pth.m4 b/m4/gnupg-pth.m4
new file mode 100644
index 0000000..00db177
--- /dev/null
+++ b/m4/gnupg-pth.m4
@@ -0,0 +1,114 @@
+dnl GnuPG's check for Pth.
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; as a special exception the author gives
+dnl unlimited permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+dnl This file is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+
+# GNUPG_PTH_VERSION_CHECK(REQUIRED)
+#
+# If the version is sufficient, HAVE_PTH will be set to yes.
+#
+# Taken and modified from the m4 macros which come with Pth.
+AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
+ [
+ _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
+ _req_version="ifelse([$1],,1.2.0,$1)"
+
+ AC_MSG_CHECKING(for PTH - version >= $_req_version)
+ for _var in _pth_version _req_version; do
+ eval "_val=\"\$${_var}\""
+ _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
+ _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
+ _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
+ _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
+ case $_rtype in
+ "a" ) _rtype=0 ;;
+ "b" ) _rtype=1 ;;
+ "." ) _rtype=2 ;;
+ esac
+ _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
+ "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
+ eval "${_var}_hex=\"\$_hex\""
+ done
+ have_pth=no
+ if test ".$_pth_version_hex" != .; then
+ if test ".$_req_version_hex" != .; then
+ if test $_pth_version_hex -ge $_req_version_hex; then
+ have_pth=yes
+ fi
+ fi
+ fi
+ if test $have_pth = yes; then
+ AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING([whether PTH installation is sane])
+ AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
+ _gnupg_pth_save_cflags=$CFLAGS
+ _gnupg_pth_save_ldflags=$LDFLAGS
+ _gnupg_pth_save_libs=$LIBS
+ CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
+ LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
+ LIBS="$LIBS `$PTH_CONFIG --libs`"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
+ ],
+ [[ pth_init ();]])],
+ gnupg_cv_pth_is_sane=yes,
+ gnupg_cv_pth_is_sane=no)
+ CFLAGS=$_gnupg_pth_save_cflags
+ LDFLAGS=$_gnupg_pth_save_ldflags
+ LIBS=$_gnupg_pth_save_libs
+ ])
+ if test $gnupg_cv_pth_is_sane != yes; then
+ have_pth=no
+ fi
+ AC_MSG_RESULT($gnupg_cv_pth_is_sane)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ ])
+
+
+#
+# GNUPG_PATH_PTH([MINIMUM_VERSION])
+#
+# This is a special version of the check whioch assumes that a
+# emulation for W32 systems is available. The test assumes that
+# $have_w32_system has already been set. On return $have_pth is set
+# as well as HAVE_PTH is defined and PTH_CLFAGS and PTH_LIBS are AS_SUBST.
+#
+AC_DEFUN([GNUPG_PATH_PTH],
+[ AC_ARG_WITH(pth-prefix,
+ AC_HELP_STRING([--with-pth-prefix=PFX],
+ [prefix where GNU Pth is installed (optional)]),
+ pth_config_prefix="$withval", pth_config_prefix="")
+ if test x$pth_config_prefix != x ; then
+ PTH_CONFIG="$pth_config_prefix/bin/pth-config"
+ fi
+ AC_PATH_PROG(PTH_CONFIG, pth-config, no)
+ tmp=ifelse([$1], ,1.3.7,$1)
+ if test "$have_w32_system" = no; then
+ if test "$PTH_CONFIG" != "no"; then
+ GNUPG_PTH_VERSION_CHECK($tmp)
+ if test $have_pth = yes; then
+ PTH_CFLAGS=`$PTH_CONFIG --cflags`
+ PTH_LIBS=`$PTH_CONFIG --ldflags`
+ PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
+ AC_DEFINE(HAVE_PTH, 1,
+ [Defined if the GNU Pth is available])
+ fi
+ fi
+ else
+ have_pth=yes
+ PTH_CFLAGS=""
+ PTH_LIBS=""
+ AC_DEFINE(HAVE_PTH, 1)
+ fi
+ AC_SUBST(PTH_CFLAGS)
+ AC_SUBST(PTH_LIBS)
+])
+
diff --git a/src/ChangeLog b/src/ChangeLog
index 9b0cb74..bd91192 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,932 +1,941 @@
+2006-10-09 Werner Koch <wk@g10code.com>
+
+ * assuan-io.c: Removed Pth support.
+ * assuan-io-pth.c: New. Based on assuan-io.c
+
+2006-10-06 Werner Koch <wk@g10code.com>
+
+ * libassuan-config.in: New options --api-version and --thread.
+
2006-10-04 Werner Koch <wk@g10code.com>
* assuan-client.c (assuan_transact): Need to map old assuan status
codes so that for example CANCELED is correctly mapped.
2006-09-28 Marcus Brinkmann <marcus@g10code.de>
* assuan-client.c (assuan_transact): Do not convert error on
status line, it is already a gpg-error. Do convert
ASSUAN_Server_Fault.
2006-09-19 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (assuan_init_socket_server_ext)
[_ASSUAN_EXT_SYM_PREFIX]: Fix typo in macro.
2006-09-19 Werner Koch <wk@g10code.com>
* assuan-defs.h (putc_unlocked): Add prototype.
* assuan-socket-server.c (accept_connection): Made LEN a socklen_t.
* assuan.h: Replaced assuan error code enum by simple defines and
made assuan_error_t an int.
* mkerrors: Changed parser accordingly.
2006-09-19 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c: Add hacks for Slowaris.
* assuan-socket.c: Likewise here.
* assuan.h (enum): Avoid trailing comma in enumerator list. Ugh.
* mkerrors (_assuan_error): Change return type to assuan_error_t.
* assuan-buffer.c (_assuan_read_line): Change return type to
assuan_error_t. Map returned value of -1.
(_assuan_write_line): Change type of RC to assuan_error_t.
* assuan-defs.h (_assuan_read_line, _assuan_error): Likewise for
prototypes.
* assuan-defs.h (unsetenv): Define correctly.
2006-09-14 Werner Koch <wk@g10code.com>
* assuan-io.c (_assuan_waitpid): New. Changed all waitpid calls
to this.
* assuan.h (_ASSUAN_DEPRECATED): New internal macro.
(assuan_pipe_connect2): Declare deprecated.
(assuan_init_connected_socket_server): Declare deprecated.
* assuan-connect.c (assuan_get_peercred): New.
* assuan-socket-server.c (accept_connection_bottom): Save uid and gid.
2006-09-13 Werner Koch <wk@g10code.com>
* assuan-client.c (assuan_transact): Need to map the error code.
* mkerrors: Need to map ASSUAN_No_Secret_Key.
* assuan-pipe-server.c (is_valid_socket): New.
(assuan_init_pipe_server): Use UDS with the environmet variable is
set and a valid descriptor is given. Ignore FILEDES in this case.
* assuan-socket-server.c (assuan_init_socket_server_ext): New.
Changed other init fucntions to make use of it.
* assuan-handler.c (assuan_command_parse_fd): Allow for lowercase
"fd".
(std_handler_reset): Close pending fds.
* assuan-uds.c (uds_receivefd): Fixed.
(_assuan_uds_close_fds): New.
* assuan-socket-connect.c (assuan_socket_connect_ext): New. Takes
all code of assuan_socket_connect plus an option to use sendmsg.
* assuan-pipe-connect.c (assuan_pipe_connect_ext): New arg FLAGS.
2006-09-12 Werner Koch <wk@g10code.com>
* assuan-buffer.c (_assuan_write_line): Also log the prefix.
* assuan-defs.h (DIM, DIMof): New.
* assuan-domain-server.c: Removed.
* assuan-domain-connect.c: Renamed to ..
* assuan-uds.c: this.
(domain_reader, domain_writer, domain_sendfd, domain_receivefd)
(assuan_domain_connect, _assuan_domain_init): Removed.
(uds_reader, uds_writer, uds_sendfd, uds_receivefd)
(_assuan_init_uds_io): New.
(_assuan_uds_deinit): New.
* assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg): New.
(my_pth_fdmode, my_pth_select): New.
2006-09-11 Werner Koch <wk@g10code.com>
* assuan-pipe-server.c (assuan_init_pipe_server): Allow for
FILEDES to be NULL and try to start as a socketpair server in this
case.
* assuan-pipe-connect.c (assuan_pipe_connect2): Split up into two
functions (unix and w32) for clarity.
(pipe_connect_unix): This is the new fucntion. Add USE_CMSG flag.
(pipe_connect_w32): Ditto.
(initial_handshake): Factored out code.
(socketpair_connect): New.
(assuan_pipe_connect_ext): New.
(do_finish): Handle case if outbound and inbound fd are the same.
This is to support socketpairs.
2006-09-10 Werner Koch <wk@g10code.com>
* assuan-util.c (_assuan_log_print_buffer)
(_assuan_log_sanitized_string,assuan_set_log_stream): Moved to ..
* assuan-logging.c: .. here.
(_assuan_log_print_buffer): Only print the leading bytes in hex
log mode unless the new env variable ASSUAN_FULL_LOGGING has been
set.
(_assuan_set_default_log_stream): Test this env variable.
2006-09-06 Werner Koch <wk@g10code.com>
* assuan.h (_ASSUAN_ONLY_GPG_ERRORS): New.
* assuan-handler.c (dispatch_command): Use Syntax_Error instead of
Invalid_Command.
* assuan-domain-connect.c: Changed alloc malloc/free/realloc to
xtrymalloc et al.
(read_int, write_int): Make args void pointers.
(domain_receivefd): Take care of realloc shrinking failure.
* assuan-buffer.c (_assuan_read_line, _assuan_write_line)
(assuan_write_line, _assuan_cookie_write_data)
(_assuan_cookie_write_flush): Print the inbound fd instead of the
address of the context when logging I/0. This makes it more
readable.
2006-09-05 Werner Koch <wk@g10code.com>
* assuan-defs.h (err_code, err_is_eof): New.
* mkerrors (_assuan_error): New. Wrapped all error code
assignments in a call to this.
(assuan_strerror): Map gpg-style error codes back. Also print a
string for the old EOF code.
(assuan_set_assuan_err_source): New.
* assuan-logging.c (_assuan_log_printf): Do not change ERRNO and
print the pid.
* assuan-domain-connect.c (domain_reader): Replaced plain printf
by assuan_log function.
2005-10-24 Werner Koch <wk@g10code.com>
* putc_unlocked.c, memrchr.c, isascii.c, funopen.c: Changed
distribution terms to LGPL. This are small and trivial files so
there are no obstacles of doing so.
* assuan-socket.c: Likewise, the stated GPL was not intended.
2005-10-08 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (setenv, unsetenv, clearenv) [!HAVE_SETENV]:
Define to _assuan_*.
* setenv.c: Include "assuan-defs.h".
(__add_to_environ): Make static.
2005-10-07 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (memrchr) [!HAVE_MEMRCHR]: New prototype.
(stpcpy) [!HAVE_STPCPY]: Likewise.
* stpcpy.c: New LGPL'ed file from the GNU C Library.
* setenv.c: New file.
* assuan-domain-connect.c (read_int): New function.
(write_int): New function.
(domain_reader): Use read_int.
(domain_sendfd): Use write_int.
2005-10-01 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (assuan_pipe_connect, assuan_pipe_connect2): Make type
of ARGV parameter const in prototype.
* assuan-pipe-connect.c (assuan_pipe_connect,
assuan_pipe_connect2): Likewise in declaration.
(assuan_pipe_connect2): Add braindead cast to make execv happy.
* assuan-client.c (assuan_transact): Change LINE, S and D from
unsigned char * to char * to silence gcc warning.
* assuan-util.c (_assuan_log_sanitized_string): Add explicit cast
to silence gcc warning.
* assuan-inquire.c (assuan_inquire): Likewise.
2005-09-08 Marcus Brinkmann <marcus@g10code.com>
* assuan-pipe-connect.c (assuan_pipe_connect2): Add missing
declaration of PID.
2005-08-09 Werner Koch <wk@g10code.com>
* mkerrors: Include config.h into assuan-errors.c. This is
required so that assuan.h knows about the W32 macro.
* assuan.h [_ASSUAN_EXT_SYM_PREFIX]: New.
* assuan-io.c [_ASSUAN_NO_PTH]: New.
* assuan-pipe-connect.c (fix_signals) [_ASSUAN_NO_FIXED_SIGNALS]: New.
(assuan_pipe_connect2) [_ASSUAN_USE_DOUBLE_FORK]: Use double fork.
(fix_signals) [_ASSUAN_USE_DOUBLE_FORK]: Do not wait..
2005-05-21 Werner Koch <wk@g10code.com>
* assuan-util.c (assuan_set_flag, assuan_get_flag): New.
* assuan-defs.h (struct assuan_context_s): New field flags.
* assuan.h (assuan_flag_t): New with one flag value
ASSUAN_NO_WAITPID for now.
* assuan-pipe-connect.c (do_finish): Take care of the no_waitpid
flag.
2005-04-04 Werner Koch <wk@g10code.com>
* assuan-util.c (_assuan_calloc): Avoid integer overflow.
2005-03-22 Werner Koch <wk@g10code.com>
* assuan-defs.h (struct assuan_io): Renamed elements READ and
WRITE to READFNC and WRITEFNC to avoid problems with read defined
as macros. Changed callers. Noted by Ville Skyttä.
2005-02-24 Werner Koch <wk@g10code.com>
* assuan-client.c (assuan_transact): Handle empty and comment
commands correctly.
2004-12-20 Werner Koch <wk@g10code.com>
* assuan-socket-connect.c (assuan_socket_connect) [W32]: Allow for
a drive letter in the path.
2004-12-19 Werner Koch <wk@g10code.com>
* assuan-pipe-server.c (assuan_init_pipe_server) [W32]: Map file
descriptors using _get_osfhandle.
2004-12-19 Moritz Schulte <moritz@g10code.com>
* assuan-pipe-connect.c (assuan_pipe_connect2): Removed "`"
character at beginning of line 532.
2004-12-18 Werner Koch <wk@g10code.com>
* assuan-logging.c (_assuan_w32_strerror): New.
* assuan-defs.h (w32_strerror): new.
* assuan-pipe-connect.c (assuan_pipe_connect2, fix_signals):
Factored signal code out to new function.
(build_w32_commandline, create_inheritable_pipe): New. Taken
from gnupg 1.9.
(assuan_pipe_connect2) [W32]: Implemented for W32.
2004-12-14 Werner Koch <wk@g10code.com>
* assuan-socket-connect.c (assuan_socket_connect): Always allow
NAME to start with a froward slash.
2004-12-07 Werner Koch <wk@g10code.com>
* assuan-logging.c, assuan-io.c: Include config.h
Replaced all usages of _WIN32 by the new HAVE_W32_SYSTEM because
there is nothing winning in this API.
* assuan-pipe-connect.c (assuan_pipe_connect2) [_WIN32]: Return
error Not Imlemented.
2004-11-27 Werner Koch <wk@g10code.com>
* assuan-socket.c: Include sys/types.h. Noted by Michael
Nottebrock.
2004-11-26 Werner Koch <wk@g10code.com>
* assuan-io.c [_WIN32]: Avoid warnings about unknown pragmas.
2004-11-24 Werner Koch <wk@g10code.com>
* assuan-logging.c (_assuan_log_printf): New.
* assuan-domain-connect.c (LOG): Removed and replaced all callers
by _assuan_log_printf. This is needed for C89 and gcc 2.95 which
both don't have C99 style variable arg macros.
* assuan-pipe-connect.c (LOG): Ditto.
* assuan-socket-connect.c (LOG): Ditto.
* assuan-socket.c[!_WIN32]: Fixed includes.
2004-11-23 Timo Schulz <twoaday@g10code.com>
* assuan-socket.c (_assuan_sock_connect): Get local port from
the sun_path[] file.
(_assuan_sock_bind): Write local port to the sun_path[] file.
* assuan-socket-connect.c (assuan_socket_connect): Use DIRSEP_C
for a better portability.
(assuan-defs.h): Define DIRSEP_C.
2004-11-19 Werner Koch <wk@g10code.com>
* assuan-handler.c (assuan_write_status): Return an error code.
2004-11-22 Timo Schulz <twoaday@g10code.com>
* assuan-io.c (_assuan_simple_read, _assuan_simple_write): W32
support.
* assuan-socket.c (_assuan_close): New.
(_assuan_sock_new): New.
(_assuan_sock_bind): New.
2004-11-16 Werner Koch <wk@g10code.com>
* assuan-socket-connect.c (LOG): Fixed macro to print not only the
prefix.
* assuan-domain-connect.c, assuan-socket-connect.c (LOG): Ditto.
2004-10-02 Werner Koch <wk@g10code.com>
* assuan-socket-connect.c: Define SUN_LEN, AF_LOCAL and PF_LOCAL
if they are not available.
* assuan-domain-connect.c: Define PF_LOCAL and AF_LOCAL if needed.
2004-06-23 Marcus Brinkmann <marcus@g10code.de>
* assuan-domain-connect.c [HAVE_SYS_UIO_H]: Include <sys/uio.h>.
2004-05-11 Werner Koch <wk@gnupg.org>
* assuan-listen.c (assuan_set_hello_line, assuan_accept): Allow
for multi line hello strings.
* assuan-buffer.c (_assuan_write_line): New with parts of ..
(assuan_write_line): .. factored out.
2004-04-29 Werner Koch <wk@gnupg.org>
* assuan-socket-connect.c: Include string.h.
* assuan-logging.c: Ditto.
2004-04-22 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Quote first argument to AC_DEFUN.
2004-04-21 Werner Koch <wk@gnupg.org>
* assuan-socket-server.c (accept_connection_bottom): Save the pid
of the peer if it is available.
* assuan-socket-connect.c (assuan_socket_connect): Do not save the
dummy SERVED_PID arg.
* assuan-pipe-connect.c (do_finish): Don't wait if the pid is 0.
(assuan_pipe_connect2): Store the parents pid in the environment
of the child.
* assuan-pipe-server.c (assuan_init_pipe_server): Initialize the
peer's pid from the environment.
* assuan-connect.c (assuan_get_pid): Do not return 0 as a PID.
2004-04-19 Werner Koch <wk@gnupg.org>
* assuan-socket-server.c, assuan-socket-connect.c: Includes
sys/types.h. Reported by Michael Nottebrock.
* assuan-domain-connect.c: Ditto.
2004-04-13 Werner Koch <wk@gnupg.org>
* assuan-util.c (_assuan_log_print_buffer): Relaxed quoting.
(_assuan_log_sanitized_string): Ditto.
2004-03-14 Werner Koch <wk@gnupg.org>
* assuan-handler.c: Include <errno.h>. Reported by Bernd Kuhls.
2004-02-18 Werner Koch <wk@gnupg.org>
* libassuan-config.in: Ignore setting of --prefix.
* assuan-handler.c (assuan_get_data_fp): Fail with ENOSYS if we
can't implement this.
2004-02-15 Werner Koch <wk@gnupg.org>
* memrchr.c (memrchr): Fixed implementation. Taken from gpgme.
2004-02-13 Werner Koch <wk@gnupg.org>
* assuan-domain-connect.c: Removed the unneeded alloca.h.
2004-01-24 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect2): New as an
extension of assuan_pipe_connect. Made the latter call this one.
2004-01-14 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (_assuan_cookie_write_data): Return the
requested size to indicate successful operation. Fixes a spurious
bug we previously fixed using fflush().
2003-12-22 Werner Koch <wk@gnupg.org>
* assuan.h (ASSUAN_Locale_Problem): Added.
* assuan-errors.c (assuan_strerror): Ditto.
2003-12-18 Werner Koch <wk@gnupg.org>
* assuan.h (AssuanCommand): Clarified that these are now
deprecated and actually useless.
(assuan_error_t): Clarified and added ASSUAN_USER_ERROR_FIRST,
ASSUAN_USER_ERROR_LAST.
2003-12-16 Werner Koch <wk@gnupg.org>
* assuan-buffer.c: Changed formatting of the debug output prefix.
* assuan-util.c (assuan_set_log_stream): Set global log stream if
it has not been done yet.
* assuan-logging.c (_assuan_set_default_log_stream): New.
(assuan_set_assuan_log_prefix): New.
2003-12-11 Werner Koch <wk@gnupg.org>
* funopen.c (_assuan_funopen): Renamed from funopen, to keep the
name space clean and avoid duplicate definitions if another
library uses the same replacement.
* assuan-defs.h (funopen): Renamed prototype and add a macro.
2003-12-08 Werner Koch <wk@gnupg.org>
* TODO: Removed.
2003-11-12 Werner Koch <wk@gnupg.org>
* assuan-handler.c (process_request): Kludge to print better error
messages for gpg-error enabled programs.
2003-11-06 Werner Koch <wk@gnupg.org>
* assuan.h (assuan_context_t): New. Should be used in favor of
ASSUAN_CONTEXT.
(assuan_error_t): New. To be used instead of AssuanError.
2003-11-11 Moritz Schulte <mo@g10code.com>
* assuan-socket-connect.c (assuan_socket_connect): Fix computation
of socket address length.
2003-08-13 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (assuan_inquire): Increase length of cmdbuf to
the Assuan limit.
2003-06-24 Werner Koch <wk@gnupg.org>
* mkerrors: Kludge to print libgpg-error values in an easier
readable way.
2003-04-29 Werner Koch <wk@gnupg.org>
* libassuan.m4: New. Based on libgrypt.m4.
* Makefile.am (m4data_DATA): New.
* assuan.h (AssuanCommand): Removed.
* assuan-handler.c: Remove the cmd_id element,
(assuan_register_command): Likewise. Note that semantics changed.
(_assuan_register_std_commands): Adjusted.
2003-02-22 Neal H. Walfield <neal@g10code.de>
* Makefile.am (bin_SCRIPTS): Renamed from bin_PROGRAMS.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* Makefile.am (libassuan_a_LIBADD): New variable.
* funopen.c: Move from ../common.
* isascii.c: Likewise.
* memrchr.c: Likewise.
* putc_unlocked.c: Likewise.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* assuan-handler.c (_IO_cookie_io_functions_t): Remove.
(cookie_io_functions_t): Remove.
(fopencookie): Remove prototype.
(assuan_get_data_fp): Use funopen, not fopencookie.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* libassuan-config.in: New file.
* Makefile.am (bin_PROGRAMS): New variable.
2003-02-17 Neal H. Walfield <neal@g10code.de>
* .cvsignore: New file.
2003-02-17 Neal H. Walfield <neal@g10code.de>
* Makefile.am (lib_LIBRARIES): Use this instead of . . .
(noinst_LIBRARIES): . . . this.
(include_HEADERS): New variable.
(libassuan_a_SOURCES): Remove assuan.h, add assuan-logging.c.
* assuan.h (assuan_set_assuan_log_stream): New prototype.
(assuan_get_assuan_log_stream): Likewise.
(assuan_get_assuan_log_prefix): Likewise.
* assuan-logging.c: New file.
* assuan-buffer.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(my_log_prefix): Remove function.
(_assuan_read_line): Use assuan_get_assuan_log_prefix in lieu of
my_log_prefix.
(assuan_write_line): Likewise.
(_assuan_cookie_write_data): Likewise.
(_assuan_cookie_write_flush): Likewise.
* assuan-domain-connect.c (LOGERROR, LOGERROR1, LOGERROR2,
LOGERRORX): Remove.
(LOG): New macro.
(domain_reader): Use it.
(domain_writer): Likewise.
(domain_sendfd): Likewise.
(domain_receivefd): Likewise.
(_assuan_domain_init): Likewise.
(assuan_domain_connect): Likewise.
* assuan-pipe-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_pipe_connect): Use it.
* assuan-socket-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_socket_connect): Use it.
(socket_reader): Remove dead code.
(socket_writer): Likewise.
* assuan-util.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(_assuan_log_sanitized_string): Use assuan_get_assuan_log_stream,
not jnlib.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h (assuan_command_parse_fd): New prototype.
* assuan-handler.c (assuan_command_parse_fd): Rename from
parse_cmd_input_output. Export.
(std_handler_input): Update to use assuan_command_parse_fd.
(std_handler_output): Likewise.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h (assuan_sendfd): New prototype.
(assuan_receivefd): New prototype.
* assuan-buffer.c (assuan_sendfd): New function.
(assuan_receivefd): New function.
* assuan-handler.c (parse_cmd_input_output): Recognize incoming
file descriptors and act appropriately.
* assuan-defs.h (struct assuan_io): Add fields sendfd and
receivefd.
(struct assuan_context_s): Add fields pendingfds and
pendingfdscount.
* assuan-pipe-server.c (_assuan_new_context): Update IO to reflect
new features.
* assuan-domain-connect.c (do_deinit): Cleanup any unreceived file
descriptors.
(domain_reader): Receive file descriptors.
(domain_sendfd): New function.
(domain_receivefd): New function.
(_assuan_domain_init): Update initialization code to reflect new
features.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan-domain-connect.c (do_finish): Remove.
(_assuan_domain_init): Use default handlers where possible.
Add an assert and update comments.
* assuan-domain-server.c (accept_connection): Remove.
(assuan_init_domain_server): Use default handlers where possible.
Put the server in pipe mode: it can only be used by a single
client.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h: Add prototype for assuan_domain_connect and
assuan_init_domain_server.
* assuan-defs.h: Include <unistd.h>.
Add prototype for _assuan_domain_init.
* assuan-domain-connect.c: New file.
* assuan-domain-server.c: New file.
* Makefile.am (libassuan_a_SOURCES): Add assuan-domain-connect.c
and assuan-domain-server.c
2002-11-23 Neal H. Walfield <neal@g10code.de>
* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
* assuan-io.c: Restore.
(_assuan_simple_read): Rename from _assuan_read.
(_assuan_simple_write): Rename from _assuan_write.
* assuan-defs.h (_assuan_simple_read): New prototype.
(_assuan_simple_write): Likewise.
* assuan-pipe-server.c (pipe_reader): Remove.
(pipe_writer): Remove.
(_assuan_new_context): Initialize IO is with _assuan_simple_read
and _assuan_simple_write.
* assuan-socket-connect.c (socket_reader): Remove.
(socket_writer): Remove.
(assuan_socket_connect): Initialize IO is with _assuan_simple_read
and _assuan_simple_write.
* assuan-socket-server.c (io): New local variable.
(assuan_init_socket_server): Initialize CTX->io.
(assuan_init_connected_socket_server): Likewise.
2002-11-23 Neal H. Walfield <neal@g10code.de>
* assuan-buffer.c (readline): Use memrchr.
(_assuan_read_line): Rewritten to use the string functions.
2002-11-20 Neal H. Walfield <neal@g10code.de>
* assuan-socket-connect.c (assuan_socket_connect): Pass PF_LOCAL
to socket(), not AF_UNIX: it expects a PF_* macro and the former
is more portable.
(assuan_socket_connect): Use AF_LOCAL, not AF_UNIX which is more
POSIXy.
2002-11-20 Neal H. Walfield <neal@g10code.de>
* assuan-defs.h (struct assuan_io): New structure.
(struct assuan_context_s): New field, io.
(_assuan_read): Depreciated.
(_assuan_write): Likewise.
* assuan-pipe-server.c: Include <unistd.h>.
(pipe_reader): New function.
(pipe_writer): Likewise.
(_assuan_new_context.IO): New local static. Set to pipe_reader
and pipe_writer. Use it to initialize new context.
* assuan-socket-connect.c (socket_reader): New function.
(socket_writer): New function.
(assuan_socket_connect.IO): New local static. Set to socket_reader
and socket_writer. Use it to initialize new context.
* assuan-buffer.c (writen): Take an ASSUAN_CONTEXT rather than a
file descriptor. Do not use _assuan_write but the write method
in the supplied context.
(readline): Likewise for _assuan_read.
(assuan_write_line): When calling writen, pass CTX; not the file
descriptor directly.
(_assuan_cookie_write_data): Likewise.
(_assuan_cookie_write_flush): Likewise.
(_assuan_read_line): Likewise for readline.
* Makefile.am (libassuan_a_SOURCES): Remove assuan-io.c.
* assuan-io.c: Removed.
2002-11-10 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect): Changed the order
of the dups to handle cases where we have already used fd 2 for
other things.
2002-10-31 Neal H. Walfield <neal@g10code.de>
* assuan-util.c: Include <ctype.h>.
(_assuan_log_print_buffer): Elide the magic numbers preferring the
standard isfoo functions. Use putc_unlocked where possible.
(_assuan_log_sanitized_string): Rewrite to use putc_unlocked and
the isfoo functions.
2002-09-05 Neal H. Walfield <neal@g10code.de>
* assuan-defs.h (_assuan_read_wrapper): Depreciated.
* assuan-util.c (_assuan_read_wrapper): Removed.
* assuan-defs.h (_assuan_write_wrapper): Depreciated.
* assuan-util.c (_assuan_write_wrapper): Removed.
* assuan.h (assuan_set_io_fun): Depreciated.
* assuan-util.c (assuan_set_io_fun): Removed.
* assuan-defs.h (_assuan_read): New function.
(_assuan_write): Likewise.
* assuan-io.c: New file.
* assuan-buffer.c (writen): Use _assuan_write rather than doing
the work here.
(readline): Likewise for _assuan_read.
* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
2002-08-16 Werner Koch <wk@gnupg.org>
* assuan.h: Renamed Bad_Certificate_Path to Bad_Certificate_Chain.
2002-07-30 Werner Koch <wk@gnupg.org>
Changed the license from GPL to LGPL.
2002-07-23 Werner Koch <wk@gnupg.org>
* assuan-handler.c (_IO_cookie_io_functions_t): Define it here if
it does not exists.
2002-06-27 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect): No special handling
for the log_fd and stderr. Connect stderr to /dev/null if it
should not be retained.
2002-06-26 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (assuan_write_line): Make sure we never
accidently print an extra LF.
2002-05-23 Werner Koch <wk@gnupg.org>
* assuan-util.c (assuan_set_io_func): New.
* assuan-buffer.c (writen, readline): Use the new functions
instead of pth.
* assuan-socket-server.c (accept_connection): Don't use the
pth_accept - using the assuan included accept code would be a bad
idea within Pth so we don't need a replacement function.
2002-05-22 Werner Koch <wk@gnupg.org>
* assuan-socket-server.c (assuan_init_connected_socket_server): New.
(accept_connection): Factored most code out to..
(accept_connection_bottom): .. new function.
2002-04-04 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (my_log_prefix): New. Use it for all i/o debug
output.
2002-03-06 Werner Koch <wk@gnupg.org>
* assuan-client.c (_assuan_read_from_server): Detect END.
(assuan_transact): Pass it to the data callback.
2002-02-27 Werner Koch <wk@gnupg.org>
* assuan-client.c (assuan_transact): Add 2 more arguments to
support status lines. Passing NULL yields the old behaviour.
* assuan-handler.c (process_request): Flush data lines send
without using the data fp.
2002-02-14 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (assuan_inquire): Check for a cancel command
and return ASSUAN_Canceled. Allow for non-data inquiry.
* assuan.h: Add a few token specific error codes.
2002-02-13 Werner Koch <wk@gnupg.org>
* assuan-defs.h (assuan_context_s): New var CLIENT_PID.
* assuan-pipe-server.c (_assuan_new_context): set default value.
* assuan-socket-server.c (accept_connection): get the actual pid.
2002-02-12 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (writen,readline) [USE_GNU_PT]: Use pth_read/write.
* assuan-socket-server.c (accept_connection) [USE_GNU_PTH]: Ditto.
2002-02-01 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (MOSTLYCLEANFILES): New variable.
2002-01-23 Werner Koch <wk@gnupg.org>
* assuan-socket-connect.c (LOGERRORX): and removed typo.
2002-01-22 Marcus Brinkmann <marcus@g10code.de>
* assuan-socket-connect.c (LOGERRORX): Reverse arguments to fputs.
2002-01-21 Werner Koch <wk@gnupg.org>
* assuan-connect.c: Move all except assuan_get_pid to...
* assuan-pipe-connect.c: this.
(assuan_pipe_disconnect): Removed.
(do_finish, do_deinit): New
(assuan_pipe_connect): and set them into the context.
* assuan-socket-connect.c: New.
* assuan-util.c (_assuan_log_sanitized_string): New.
* assuan-pipe-server.c (assuan_init_pipe_server): Factored most
code out to ...
(_assuan_new_context): new func.
(_assuan_release_context): New
* assuan-connect.c (assuan_pipe_connect): Use the new functions.
2002-01-20 Werner Koch <wk@gnupg.org>
* assuan.h: Added Invalid Option error code.
* assuan-handler.c (std_handler_option): New.
(std_cmd_tbl): Add OPTION as standard command.
(assuan_register_option_handler): New.
(dispatch_command): Use case insensitive matching as a fallback.
(my_strcasecmp): New.
2002-01-19 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (_assuan_read_line): Add output logging.
(assuan_write_line): Ditto.
(_assuan_cookie_write_data): Ditto.
(_assuan_cookie_write_flush): Ditto.
* assuan-util.c (_assuan_log_print_buffer): New.
(assuan_set_log_stream): New.
(assuan_begin_confidential): New.
(assuan_end_confidential): New.
* assuan-defs.h: Add a few handler variables.
* assuan-pipe-server.c (assuan_deinit_pipe_server): Removed.
(deinit_pipe_server): New.
(assuan_deinit_server): New. Changed all callers to use this.
* assuan-listen.c (assuan_accept): Use the accept handler.
* assuan-handler.c (process_request): Use the close Handler.
* assuan-socket-server.c: New.
2002-01-14 Werner Koch <wk@gnupg.org>
* assuan-client.c (_assuan_read_from_server): Skip spaces after
the keyword.
2002-01-03 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_set_okay_line): New.
(process_request): And use it here.
2002-01-02 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (init_membuf,put_membuf,get_membuf): Apply a
hidden 0 behind the buffer so that the buffer can be used as a
string in certain contexts.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-connect.c (assuan_pipe_connect): New argument
FD_CHILD_LIST. Don't close those fds.
* assuan.h: Likewise for prototype.
2001-12-14 Werner Koch <wk@gnupg.org>
* assuan-listen.c (assuan_close_input_fd): New.
(assuan_close_output_fd): New.
* assuan-handler.c (std_handler_reset): Always close them after a
reset command.
(std_handler_bye): Likewise.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
it to save the length of the attic line.
Rediddle the code a bit to make it more clear what happens.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
assuan.h: Define ASSUAN_LINELENGTH.
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (assuan_read_line): Fix order of execution to
get correct return values.
2001-12-13 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_get_active_fds): Fixed silly bug,
pretty obvious that nobody ever tested this function.
2001-12-12 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_pipe_connect): Implemented the inital
handshake.
* assuan-client.c (read_from_server): Renamed to
(_assuan_read_from_server): this and made external.
* assuan-listen.c (assuan_set_hello_line): New.
(assuan_accept): Use a custom hello line is available.
* assuan-buffer.c (assuan_read_line): New.
(assuan_pending_line): New.
(_assuan_write_line): Renamed to ..
(assuan_write_line): this, made public and changed all callers.
2001-12-04 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_pipe_connect): Add more error reporting.
* assuan-client.c: New.
* assuan-inquire.c: New.
* assuan-handler.c (process_request): Check for nested invocations.
2001-11-27 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_register_input_notify): New.
(assuan_register_output_notify): New.
2001-11-26 Werner Koch <wk@gnupg.org>
* assuan.h: Added more status codes.
2001-11-25 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_register_bye_notify)
(assuan_register_reset_notify)
(assuan_register_cancel_notify): New and call them from the
standard handlers.
(assuan_process): Moved bulk of function to ..
(process_request): .. new.
(assuan_process_next): One shot version of above.
(assuan_get_active_fds): New.
2001-11-24 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_get_pid): New.
* assuan-buffer.c (_assuan_read_line): Deal with reads of more
than a line.
* assuan-defs.h: Add space in the context for this.
Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/src/Makefile.am b/src/Makefile.am
index e90b7af..52980ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,57 +1,67 @@
# Assuan Makefile
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
#
# This file is part of Assuan.
#
# Assuan 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.
#
# Assuan 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
## Process this file with automake to produce Makefile.in
EXTRA_DIST = libassuan-config.in mkerrors libassuan.m4
INCLUDES = -I.. -I$(top_srcdir)/include
BUILT_SOURCES = assuan-errors.c
MOSTLYCLEANFILES = assuan-errors.c
+if HAVE_PTH
+libassuan_pth = libassuan-pth.a
+else
+libassuan_pth =
+endif
+
bin_SCRIPTS = libassuan-config
m4datadir = $(datadir)/aclocal
m4data_DATA = libassuan.m4
-lib_LIBRARIES = libassuan.a
+lib_LIBRARIES = libassuan.a $(libassuan_pth)
include_HEADERS = assuan.h
-#libassuan_a_LDFLAGS =
-libassuan_a_SOURCES = \
+common_sources = \
assuan-defs.h \
assuan-util.c \
assuan-errors.c \
assuan-buffer.c \
assuan-handler.c \
assuan-inquire.c \
assuan-listen.c \
assuan-connect.c \
assuan-client.c \
assuan-pipe-server.c \
assuan-socket-server.c \
assuan-pipe-connect.c \
assuan-socket-connect.c \
assuan-uds.c \
- assuan-io.c \
assuan-logging.c \
assuan-socket.c
+libassuan_a_SOURCES = $(common_sources) assuan-io.c
libassuan_a_LIBADD = @LIBOBJS@
+if HAVE_PTH
+libassuan_pth_a_SOURCES = $(common_sources) assuan-io-pth.c
+libassuan_pth_a_LIBADD = @LIBOBJS@
+endif
+
assuan-errors.c : assuan.h mkerrors
$(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c
diff --git a/src/assuan-io-pth.c b/src/assuan-io-pth.c
new file mode 100644
index 0000000..13f8794
--- /dev/null
+++ b/src/assuan-io-pth.c
@@ -0,0 +1,147 @@
+/* assuan-io-pth.c - Pth version of assua-io.c.
+ * Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Assuan.
+ *
+ * Assuan 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.
+ *
+ * Assuan 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+#include <unistd.h>
+#include <errno.h>
+#ifdef HAVE_W32_SYSTEM
+# include <windows.h>
+#else
+# include <sys/wait.h>
+#endif
+#include <pth.h>
+
+#include "assuan-defs.h"
+
+
+
+#ifndef HAVE_W32_SYSTEM
+pid_t
+_assuan_waitpid (pid_t pid, int *status, int options)
+{
+ return pth_waitpid (pid, status, options);
+}
+#endif
+
+
+ssize_t
+_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
+{
+#ifndef HAVE_W32_SYSTEM
+ return pth_read (ctx->inbound.fd, buffer, size);
+#else
+ return recv (ctx->inbound.fd, buffer, size, 0);
+#endif
+}
+
+ssize_t
+_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
+{
+#ifndef HAVE_W32_SYSTEM
+ return pth_write (ctx->outbound.fd, buffer, size);
+#else
+ return send (ctx->outbound.fd, buffer, size, 0);
+#endif
+}
+
+
+ssize_t
+_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
+{
+#if defined(HAVE_W32_SYSTEM)
+ return _assuan_error (ASSUAN_Not_Implemented);
+#else
+ /* Pth does not provide a sendmsg function. Thus we implement it here. */
+ int ret;
+ int fd = ctx->outbound.fd;
+ int fdmode;
+
+ fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
+ if (fdmode == PTH_FDMODE_ERROR)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (fdmode == PTH_FDMODE_BLOCK)
+ {
+ fd_set fds;
+
+ FD_ZERO (&fds);
+ FD_SET (fd, &fds);
+ while ( (ret = pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
+ && errno == EINTR)
+ ;
+ if (ret < 0)
+ return -1;
+ }
+
+ while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
+ ;
+ return ret;
+#endif
+}
+
+
+ssize_t
+_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
+{
+#if defined(HAVE_W32_SYSTEM)
+ return _assuan_error (ASSUAN_Not_Implemented);
+#else
+ /* Pth does not provide a recvmsg function. Thus we implement it here. */
+ int ret;
+ int fd = ctx->inbound.fd;
+ int fdmode;
+
+ fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
+ if (fdmode == PTH_FDMODE_ERROR)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (fdmode == PTH_FDMODE_BLOCK)
+ {
+ fd_set fds;
+
+ FD_ZERO (&fds);
+ FD_SET (fd, &fds);
+ while ( (ret = pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
+ && errno == EINTR)
+ ;
+ if (ret < 0)
+ return -1;
+ }
+
+ while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
+ ;
+ return ret;
+#endif
+}
diff --git a/src/assuan-io.c b/src/assuan-io.c
index 0fe48b7..a1be67d 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -1,217 +1,91 @@
/* assuan-io.c - Wraps the read and write functions.
* Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
* Assuan 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.
*
* Assuan 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#if HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_W32_SYSTEM
# include <windows.h>
#else
# include <sys/wait.h>
#endif
#include "assuan-defs.h"
-/* We can't include pth.h and we are not sure whether other headers
- already included it. This we define macros with the same
- values. */
-#define MY_PTH_FDMODE_ERROR (-1)
-#define MY_PTH_FDMODE_POLL 0
-#define MY_PTH_FDMODE_BLOCK 1
-#define MY_PTH_FDMODE_NONBLOCK 2
-
-
-#ifndef _ASSUAN_NO_PTH
-extern pid_t pth_waitpid (pid_t pid, int *status, int options);
-extern ssize_t pth_read (int fd, void *buffer, size_t size);
-extern ssize_t pth_write (int fd, const void *buffer, size_t size);
-extern int pth_fdmode (int, int);
-extern int pth_select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
-
-#ifndef HAVE_W32_SYSTEM
-#pragma weak pth_waitpid
-#pragma weak pth_read
-#pragma weak pth_write
-#pragma weak pth_fdmode
-#pragma weak pth_select
-#endif
-#endif /*!_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_fdmode. */
-static int
-my_pth_fdmode (int fd, int mode)
-{
- if (pth_fdmode)
- return pth_fdmode (fd, mode);
- else
- return MY_PTH_FDMODE_NONBLOCK; /* This is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_select. */
-static int
-my_pth_select (int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
- struct timeval *timeout)
-{
- if (pth_select)
- return pth_select (nfd, rfds, wfds, efds, timeout);
- else
- return 1; /* Fake one fd ready; this is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
#ifndef HAVE_W32_SYSTEM
pid_t
_assuan_waitpid (pid_t pid, int *status, int options)
{
-#ifdef _ASSUAN_NO_PTH
return waitpid (pid, status, options);
-#else
- return (pth_waitpid ? pth_waitpid : waitpid) (pid, status, options);
-#endif
}
#endif
ssize_t
_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
{
-#ifdef _ASSUAN_NO_PTH
return read (ctx->inbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
- return (pth_read ? pth_read : read) (ctx->inbound.fd, buffer, size);
-# else
- return pth_read ? pth_read (ctx->inbound.fd, buffer, size)
- : recv (ctx->inbound.fd, buffer, size, 0);
-# endif
-#endif
}
ssize_t
_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
{
-#ifdef _ASSUAN_NO_PTH
return write (ctx->outbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
- return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size);
-# else
- return pth_write ? pth_write (ctx->outbound.fd, buffer, size)
- : send (ctx->outbound.fd, buffer, size, 0);
-# endif
-#endif
}
ssize_t
_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
{
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
- int ret;
- while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR)
- ;
- return ret;
#else
- /* Pth does not provide a sendmsg function. Thus we implement it here. */
int ret;
- int fd = ctx->outbound.fd;
- int fdmode;
-
- fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
- if (fdmode == MY_PTH_FDMODE_ERROR)
- {
- errno = EBADF;
- return -1;
- }
- if (fdmode == MY_PTH_FDMODE_BLOCK)
- {
- fd_set fds;
-
- FD_ZERO (&fds);
- FD_SET (fd, &fds);
- while ( (ret = my_pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
- && errno == EINTR)
- ;
- if (ret < 0)
- return -1;
- }
-
- while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
+ while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
ssize_t
_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
{
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
- int ret;
- while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR)
- ;
- return ret;
#else
- /* Pth does not provide a recvmsg function. Thus we implement it here. */
int ret;
- int fd = ctx->inbound.fd;
- int fdmode;
-
- fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
- if (fdmode == MY_PTH_FDMODE_ERROR)
- {
- errno = EBADF;
- return -1;
- }
- if (fdmode == MY_PTH_FDMODE_BLOCK)
- {
- fd_set fds;
-
- FD_ZERO (&fds);
- FD_SET (fd, &fds);
- while ( (ret = my_pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
- && errno == EINTR)
- ;
- if (ret < 0)
- return -1;
- }
-
- while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
+ while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
diff --git a/src/libassuan-config.in b/src/libassuan-config.in
index a50ffba..60f4aa2 100644
--- a/src/libassuan-config.in
+++ b/src/libassuan-config.in
@@ -1,110 +1,144 @@
#!/bin/sh
# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PGM=libassuan-config
-libs="@LIBASSUAN_CONFIG_LIBS@"
+lib="@LIBASSUAN_CONFIG_LIB@"
+extralibs="@LIBASSUAN_CONFIG_EXTRA_LIBS@"
cflags="@LIBASSUAN_CONFIG_CFLAGS@"
+api_version="@LIBASSUAN_CONFIG_API_VERSION@"
+all_thread_modules="@LIBASSUAN_CONFIG_THREAD_MODULES@"
+thread_module=
prefix=@prefix@
exec_prefix=@exec_prefix@
includes=""
libdirs=""
exec_prefix_set=no
echo_libs=no
echo_cflags=no
echo_prefix=no
echo_exec_prefix=no
+if test x"$all_thread_modules" = x; then
+ all_thread_modules="none pthread"
+else
+ all_thread_modules="none pthread $all_thread_modules"
+fi
usage()
{
cat <<EOF
Usage: $PGM [OPTIONS]
Options:
+ [--thread={`echo "${all_thread_modules}" | sed 's/ /|/g'`}]
[--prefix[=DIR]]
[--exec-prefix[=DIR]]
[--version]
[--libs]
[--cflags]
EOF
exit $1
}
if test $# -eq 0; then
- usage 1 1>&2
+ usage 1 1>&2
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
# Dummy
;;
--prefix)
echo_prefix=yes
;;
--exec-prefix=*)
# Dummy
;;
--exec-prefix)
echo_exec_prefix=yes
;;
--version)
echo "@VERSION@"
exit 0
;;
+ --api-version)
+ echo_api_version=yes
+ ;;
+ --thread=*)
+ for mod in $all_thread_modules; do
+ if test "$mod" = "$optarg"; then
+ thread_module="-$mod"
+ fi
+ done
+ if test "x$thread_module" = "x"; then
+ usage 1 1>&2
+ fi
+ if test "$thread_module" = "-none"; then
+ thread_module=""
+ fi
+ if test "$thread_module" = "-pthread"; then
+ thread_module=""
+ fi
+ ;;
--cflags)
echo_cflags=yes
;;
--libs)
echo_libs=yes
;;
*)
usage 1 1>&2
;;
esac
shift
done
if test "$echo_prefix" = "yes"; then
echo $prefix
fi
if test "$echo_exec_prefix" = "yes"; then
echo $exec_prefix
fi
+if test "$echo_api_version" = "yes"; then
+ echo $api_version
+fi
+
+
if test "$echo_cflags" = "yes"; then
if test "@includedir@" != "/usr/include" ; then
includes="-I@includedir@"
for i in $cflags ; do
if test "$i" = "-I@includedir@" ; then
includes=""
fi
done
fi
echo $includes $cflags
fi
if test "$echo_libs" = "yes"; then
if test "@libdir@" != "/usr/lib" ; then
libdirs="-L@libdir@"
- for i in $libs ; do
+ for i in $lib $extralibs ; do
if test "$i" = "-L@libdir@" ; then
libdirs=""
fi
done
fi
- echo $libdirs $libs
+ echo $libdirs $lib${thread_module} $extralibs
fi
diff --git a/src/libassuan.m4 b/src/libassuan.m4
index 16b664c..680f93b 100644
--- a/src/libassuan.m4
+++ b/src/libassuan.m4
@@ -1,76 +1,160 @@
dnl Autoconf macros for libassuan
dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl
dnl This file is free software; as a special exception the author gives
dnl unlimited permission to copy and/or distribute it, with or without
dnl modifications, as long as this notice is preserved.
dnl
dnl This file is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
dnl
-AC_DEFUN([AM_PATH_LIBASSUAN],
+dnl Common code used for libassuan detection [internal]
+dnl Returns ok set to yes or no.
+dnl
+AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
[ AC_ARG_WITH(libassuan-prefix,
- AC_HELP_STRING([--with-libassuan-prefix=PFX],
- [prefix where LIBASSUAN is installed (optional)]),
+ AC_HELP_STRING([--with-libassuan-prefix=PFX],
+ [prefix where LIBASSUAN is installed (optional)]),
libassuan_config_prefix="$withval", libassuan_config_prefix="")
if test x$libassuan_config_prefix != x ; then
- libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
- if test x${LIBASSUAN_CONFIG+set} != xset ; then
- LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
- fi
+ libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
+ if test x${LIBASSUAN_CONFIG+set} != xset ; then
+ LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
+ fi
fi
-
AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no)
- min_libassuan_version=ifelse([$1], ,0.0.1,$1)
- AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version)
+
+ tmp=ifelse([$1], ,1:0.9.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_libassuan_api=0
+ min_libassuan_version="$tmp"
+ fi
+
+ if test "$LIBASSUAN_CONFIG" != "no" ; then
+ libassuan_version=`$LIBASSUAN_CONFIG --version`
+ fi
+ libassuan_version_major=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ libassuan_version_minor=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ libassuan_version_micro=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+
+ AC_MSG_CHECKING(for LIBASSUAN ifelse([$2], ,,[$2 ])- version >= $min_libassuan_version)
ok=no
if test "$LIBASSUAN_CONFIG" != "no" ; then
+ ifelse([$2], ,,[if `$LIBASSUAN_CONFIG --thread=$2 2> /dev/null` ; then])
req_major=`echo $min_libassuan_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_libassuan_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
req_micro=`echo $min_libassuan_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
- libassuan_config_version=`$LIBASSUAN_CONFIG $libassuan_config_args --version`
- major=`echo $libassuan_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
- minor=`echo $libassuan_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
- micro=`echo $libassuan_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
- if test "$major" -gt "$req_major"; then
+ if test "$libassuan_version_major" -gt "$req_major"; then
ok=yes
else
- if test "$major" -eq "$req_major"; then
- if test "$minor" -gt "$req_minor"; then
+ if test "$libassuan_version_major" -eq "$req_major"; then
+ if test "$libassuan_version_minor" -gt "$req_minor"; then
ok=yes
else
- if test "$minor" -eq "$req_minor"; then
- if test "$micro" -ge "$req_micro"; then
+ if test "$libassuan_version_minor" -eq "$req_minor"; then
+ if test "$libassuan_version_micro" -ge "$req_micro"; then
ok=yes
fi
fi
fi
fi
fi
+ ifelse([$2], ,,[fi])
+ fi
+
+ if test $ok = yes; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
fi
+
+ if test $ok = yes; then
+ if test "$req_libassuan_api" -gt 0 ; then
+ tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ AC_MSG_CHECKING([LIBASSUAN ifelse([$2], ,,[$2 ])API version])
+ if test "$req_libassuan_api" -eq "$tmp" ; then
+ AC_MSG_RESULT(okay)
+ else
+ ok=no
+ AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.])
+ fi
+ fi
+ fi
+ fi
+
+])
+
+
+
+dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN],
+[ _AM_PATH_LIBASSUAN_COMMON($1)
if test $ok = yes; then
LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
- AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
LIBASSUAN_CFLAGS=""
LIBASSUAN_LIBS=""
- AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(LIBASSUAN_CFLAGS)
AC_SUBST(LIBASSUAN_LIBS)
])
+
+
+dnl AM_PATH_LIBASSUAN_PTH([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTH_CFLAGSand LIBASSUAN_PTH_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTH],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pth)
+ if test $ok = yes; then
+ LIBASSUAN_PTH_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+ LIBASSUAN_PTH_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_PTH_CFLAGS=""
+ LIBASSUAN_PTH_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_PTH_CFLAGS)
+ AC_SUBST(LIBASSUAN_PTH_LIBS)
+])
+
+
+dnl AM_PATH_LIBASSUAN_PTHREAD([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTHREAD_CFLAGS
+dnl and LIBASSUAN_PTHREAD_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTHREAD],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pth)
+ if test $ok = yes; then
+ LIBASSUAN_PTHREAD_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+ LIBASSUAN_PTHREAD_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_PTHREAD_CFLAGS=""
+ LIBASSUAN_PTHREAD_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_PTHREAD_CFLAGS)
+ AC_SUBST(LIBASSUAN_PTHREAD_LIBS)
+])
+

File Metadata

Mime Type
text/x-diff
Expires
Wed, Aug 6, 10:08 PM (1 d, 15 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a6/a3/64d6ebf2aae4adb7624892dbcd08

Event Timeline