Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F22948198
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
140 KB
Subscribers
None
View Options
diff --git a/doc/ChangeLog b/doc/ChangeLog
index f5fa9d0..cfc0e48 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,80 +1,85 @@
+2008-10-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * assuan.texi: Change return type of callback handlers in
+ assuan_transact.
+
2007-11-14 Werner Koch <wk@g10code.com>
* assuan.texi (Client code): Describe the new flag bit 7 of the
pipe_server_connect_ext function.
2007-10-18 Marcus Brinkmann <marcus@g10code.de>
* assuan.texi (Client requests): Document HELP.
2007-09-07 Moritz Schulte <moritz@g10code.com>
* assuan.texi (Client code): mention assuan_send_data() instead of
assuan_write_data().
2007-09-03 Marcus Brinkmann <marcus@g10code.de>
* assuan.texi: Fix prototype and documentation for
assuan_inquire_ext.
2007-08-24 Werner Koch <wk@g10code.com>
* lgpl.texi: Replace by LGPLv2.1 version.
2007-08-09 Marcus Brinkmann <marcus@g10code.de>
* assuan.texi (External I/O Loop): New chapter.
2007-07-12 Werner Koch <wk@g10code.com>
* assuan.texi (Utilities): Document that under W32 we return a
system handle.
2007-07-05 Werner Koch <wk@g10code.com>
* lgpl.texi: New. Taken from COPYING.LIB and reformatted.
* gpl.texi: Updated to v3.
* assuan.texi (Utilities): Explain ASSUAN_CONFIDENTIAL.
2007-05-06 Marcus Brinkmann <marcus@g10code.de>
* assuan.texi: Clean up typos.
2006-10-31 Werner Koch <wk@g10code.com>
* assuan.texi: Finished.
2003-12-18 Werner Koch <wk@gnupg.org>
* assuan.texi: Changed copyright to GPL because this is not a book
but useful documentation in other software too. Reworked
sectioning, updated list of error codes.
* gpl.texi: Added.
* fdl.texi: Removed.
2003-08-06 Werner Koch <wk@gnupg.org>
* lgpl.texi: New.
* gpl.texi: Removed.
* assuan.texi: Dropped requirement vor invariant sections,
front- and back-cover texts. Include lgpg.texi.
2003-02-18 Neal H. Walfield <neal@cs.uml.edu>
* Makefile.am: New file.
* fdl.texi: New file.
* gpl.texi: New file.
* assuan.texi: Imported from newpg.
Copyright 2003, 2006, 2007 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/doc/assuan.texi b/doc/assuan.texi
index c8a1ca0..479d4bb 100644
--- a/doc/assuan.texi
+++ b/doc/assuan.texi
@@ -1,1703 +1,1703 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename assuan.info
@macro copyrightnotice
Copyright @copyright{} 2002, 2003, 2006, 2007 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 3 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 by Werner Koch and Marcus Brinkmann
@author @code{@{wk,mb@}@@g10code.com}
@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.
* External I/O Loop:: How to use external I/O event loops.
* Utilities:: Utility functions.
* Socket wrappers:: Socket wrapper 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 would not be necessary. 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 becomes
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 components small,
understandable and less error prone.
Assuan is not, however, limited to use with GnuPG servers and clients:
it was designed to be flexible enough to meet the demands of many
transaction based environments 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
octets. 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, and 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 [<arbitrary 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 BYE
Close the connect, the server will reply with an @code{OK}.
@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
Lists all commands that the server understands as comment lines on the
status channel.
@item QUIT
Reserved for future extensions.
@item OPTION
Set options for the connection. The syntax of such a line is
@display
OPTION @var{name} [ [=] @var{value} ]
@end display
Leading and trailing spaces around @var{name} and @var{value} are
allowed but should be ignored. For compatibility reasons, @var{name}
may be prefixed with two dashes. The use of the equal sign is optional
but suggested if @var{value} is given.
@item CANCEL
This command is reserved for future extensions.
@item AUTH
This command is reserved for future extensions. 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.
@end table
@node Error codes
@section Error codes
In general Libassuan should be used with gpg-error style error codes.
For compatibility reasons and for applications not wanting to use these
error codes, the old Assuan error codes may still be used. In fact they
are used by default. To switch to gpg-error style error codes,
applications should call the @ref{function assuan_set_assuan_err_source}
right after startup.
@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 maintained
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 originally 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 are 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 occurred.
@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-safe 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 explicitly request this. You do this by calling the function
@anchor{function assuan_set_assuan_err_source}
@deftypefun void assuan_set_assuan_err_source (@w{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 an 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 eventually data needs to be
written and read.
@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 context 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 allowed by the
assuan protocol. This function shall not be used for sending 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 function @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
Depending on the type of the server you want to connect you need to use
different functions.
For a pipe based server you fork and exec yourself, you use:
@deftypefun assuan_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}},@w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}})
A call to this functions forks the current process and executes the
program @var{name}, passing the arguments given in the NULL-terminated
list @var{argv}. A list of file descriptors not to be closed may be
given using the @code{-1} terminated array @var{fd_child_list}.
On success a new assuan context is returned at @var{ctx}.
@end deftypefun
If it is not a simple pipe server but one using full-duplex sockets, the
full-fledged variant of the above function should be used:
@deftypefun assuan_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}},@w{const char *@var{name}}, @w{const char *const @var{argv}[]}, @w{int *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}})
A call to this functions forks the current process and executes the
program @var{name}, passing the arguments given in the NULL-terminated
list @var{argv}. A list of file descriptors not to be closed may be
given using the @code{-1} terminated array @var{fd_child_list}.
If @var{name} as well as @var{argv} are given as @code{NULL}, only a
fork but no exec is done. Thus the child continues to run. However all
file descriptors are closed and some special environment variables are
set. To let the caller detect whether the child or the parent continues,
the child returns with a @var{ctx} set to @code{NULL}.
If @var{atfork} is not NULL, this function is called in the child right
after the fork and the value @var{atforkvalue} is passed as the first
argument. That function should only act if the second argument it
received is @code{0}. Such a fork callback is useful to release
additional resources not to be used by the child.
@noindent
@var{flags} is a bit vector and controls how the function acts:
@table @code
@item bit 0 (value 1)
If cleared a simple pipe based server is expected and the function
behaves similar to @code{assuan_pipe_connect}.
If set a server based on full-duplex pipes is expected. Such pipes are
usually created using the @code{socketpair} function. It also enables
features only available with such servers.
@item bit 7 (value 128)
If set and there is a need to start ther server it will be started as a
background process. This flag is useful under W32 systems, so that no
new console is created and pops up a console window when starting the server
@end table
@end deftypefun
If you are using a long running server listening either on a TCP or a
Unix domain socket, the following function is used to connect to the server:
@deftypefun assuan_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}})
Make a connection to the Unix domain socket @var{name} and return a
new Assuan context at @var{ctx}. @var{server_pid} is currently not
used but may become handy in the future; if you don't know the
server's pid, pass @code{-1}. With @var{flags} set to @code{1},
@code{sendmsg} and @code{recvmesg} are used for input and output and
thereby enabling the the use of descriptor passing.
Connecting to a TCP server is not yet implemented. Standard URL
schemes are reserved for @var{name} specifying a TCP server.
@end deftypefun
@deftypefun assuan_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}})
Same as above but no way to specify flags.
@end deftypefun
Finally, after using the Assuan connection, the resources should be
deallocated:
@deftypefun void assuan_disconnect (@w{assuan_context_t @var{ctx}})
Close the connection described by the Assuan context @var{ctx} and
release all resources. This function also tries to send the BYE command
to the server but won't fail on error. It is explicitly allowed to pass
@code{NULL} for @var{ctx}, in which case the function does nothing.
@end deftypefun
Now that we have a connection to the server, all work may be
conveniently done using a couple of callbacks and the transact
function:
-@deftypefun assuan_error_t assuan_transact (@w{assuan_context_t @var{ctx}}, @w{const char *@var{command}}, @w{int (*@var{data_cb})(void *, const void *, size_t)}, @w{void *@var{data_cb_arg}}, @w{int (*@var{inquire_cb})(void*, const char *)}, @w{void *@var{inquire_cb_arg}}, @w{int (*@var{status_cb})(void*, const char *)}, @w{void *@var{status_cb_arg}})
+@deftypefun assuan_error_t assuan_transact (@w{assuan_context_t @var{ctx}}, @w{const char *@var{command}}, @w{assuan_error_t (*@var{data_cb})(void *, const void *, size_t)}, @w{void *@var{data_cb_arg}}, @w{assuan_error_t (*@var{inquire_cb})(void*, const char *)}, @w{void *@var{inquire_cb_arg}}, @w{assuan_error_t (*@var{status_cb})(void*, const char *)}, @w{void *@var{status_cb_arg}})
Here @var{ctx} is the Assuan context opened by one of the connect
calls. @var{command} is the actual one liner Assuan command. It
shall not end with a line feed and its length is limited to
@code{ASSUAN_LINELENGTH} (~1000 bytes)
@var{data_cb} is called by Libassuan for data lines; @var{data_cb_arg}
is passed to it along with the data and the length. [FIXME: needs
more documentation].
@var{inquire_cb} is called by Libassuan when the server requests
additional information from the client while processing the command.
This callback shall check the provided inquiry name and send the data
as requested back using the @code{assuan_send_data}. The server
passed @var{inquiry_cb_arg} along with the inquiry name to the
callback.
@var{status_cb} is called by Libassuan for each status line it receives
from the server. @var{status_cb_arg} is passed along with the status
line to the callback.
The function returns @code{0} success or an error code. The error code
may be the one one returned by the server in error lines or one
generated by the callback functions.
@end deftypefun
Libassuan supports descriptor passing on some platforms. The next two
functions are used with this feature:
@anchor{function assuan_sendfd}
@deftypefun assuan_error_t assuan_sendfd (@w{assuan_context_t @var{ctx}}, @w{int @var{fd}})
Send the descriptor @var{fd} to the peer using the context @var{ctx}.
Note, that calling this function with a @var{ctx} of @code{NULL} and
@var{fd} of @code{-1} is a valid runtime test to check whether
descriptor passing is available on the platform. The descriptor must
be sent before the command is issued that makes use of the descriptor.
@end deftypefun
@anchor{fun-assuan_receivedfd}
@deftypefun assuan_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{int *@var{fd}})
Receive a descriptor pending for the context @var{ctx} from the peer.
The descriptor must be pending before this function is called. To
accomplish this, the peer needs to use @code{assuan_sendfd} before the
trigger is sent (e.g. using @code{assuan_write_line ("INPUT FD")}.
@end deftypefun
@c
@c S E R V E R C O D E
@c
@node Server code
@chapter How to develop an Assuan server
Implementing a server for Assuan is a bit more complex than a
client. However it is a straightforward task we are going to explain
using a commented example.
@noindent
The list of the implemented server commands is defined by a table like:
@smallexample
static struct @{
const char *name;
int (*handler)(assuan_context_t, char *line);
@} command_table[] = @{
@{ "FOO", cmd_foo @},
@{ "BAR", cmd_bar @},
@{ "INPUT", NULL @},
@{ "OUTPUT", NULL @},
@{ NULL @}@};
@end smallexample
For convenience this table is usually put after the actual command
handlers (cmd_foo, cmd_bar) or even put inside the command_handler.
Note that commands with the name ``INPUT'' and ``OUTPUT'' do not require
a handler because Libassuan provides a default handler for them. It is
however possible to assign a custom handler.
A prerequisite for this example code is that a client has already
connected to the server. Often there are two modes combined in one
program: A pipe based server, where a client has forked the server
process, or a Unix domain socket based server that is listening on the
socket.
@example
void
command_handler (int fd)
@{
int i, rc;
assuan_context_t ctx;
if (fd == -1)
@{
int filedes[2];
filedes[0] = 0;
filedes[1] = 1;
rc = assuan_init_pipe_server (&ctx, filedes);
@}
else
rc = assuan_init_socket_server_ext (&ctx, fd, 2);
if (rc)
@{
fprintf (stderr, "server init failed: %s\n", gpg_strerror(rc));
return;
@}
@end example
@noindent
This is the first part of the command handler. In case this is called
as a pipe based server, @var{fd} will be based as @code{fd} and the
code assumes that the server's @code{stdin} and @code{stdout} file
handles are connected to a pipe. The initialization is thus done
using the function:
@deftypefun assuan_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{filedes}[2]})
The function takes the two file descriptors from @var{filedes} and
returns a new Assuan context at @var{r_ctx}. As usual, a return value
of @code{0} indicates success and a failure is indicated by a
returning an error code. In case of error, @code{NULL} will be stored
at @var{r_ctx}.
In case the server has been called using a bi-directional pipe
(socketpair), @var{filedes} is ignored and the file descriptor is
taken from the environment variable @env{_assuan_connection_fd}. You
won't need to know that because @code{assuan_pipe_connect_ext}, used
by the client to connect to such a server, automagically sets this
variable.
@end deftypefun
@noindent
If a file descriptor has been passed, the assuan context gets
initialized by the function:
@deftypefun assuan_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}})
The function takes the file descriptor @var{fd} which is expected to be
associated with a socket and returns a new Assuan context at
@var{r_ctx}. The following bits are currently defined for @var{flags}:
@table @code
@item Bit 0
If set, @code{sendmsg} and @code{recvmesg} are used for input and
output and thus enabling the use of descriptor passing.
@item Bit 1
If set, @var{fd} refers to an already accepted socket. That is,
Libassuan won't call @var{accept} for it. It is suggested to set this
bit as it allows better control of the connection state.
@end table
As usual, a return value of @code{0} indicates success and a failure
is indicated by a returning an error code. In case of error,
@code{NULL} will be stored at @var{r_ctx}.
@end deftypefun
@noindent
On the Windows platform the following function needs to be called after
assuan_init_socket_server_ext:
@deftypefun void assuan_set_sock_nonce ( @
@w{assuan_context_t @var{ctx}}, @
@w{assuan_sock_nonce_t *@var{nonce}})
Save a copy of @var{nonce} in context @var{ctx}. This should be used to
register the server's nonce with a context established by
assuan_init_socket_server. It is actually only needed for Windows but
it does not harm to use it on other systems as well.
@end deftypefun
@noindent
After error checking, the implemented assuan commands are registered with
the server.
@example
for (i = 0; command_table[i].name; i++)
@{
rc = assuan_register_command (ctx,
command_table[i].name,
command_table[i].handler);
if (rc)
@{
fprintf (stderr, "register failed: %s\n", gpg_strerror (rc));
assuan_deinit_server (ctx);
return;
@}
@}
@end example
@deftypefun assuan_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{int (*@var{handler}) (assuan_context_t, char *)})
This registers the command named @var{cmd_string} with the Assuan
context @var{ctx}. @var{handler} is the function called by Libassuan
if this command is received from the client. @var{NULL} may be used
for @var{handler} to use a default handler (this only works with a few
pre-defined commands). Note that several default handlers have
already been registered when the context has been created: ``NOP'',
``CANCEL'', ``OPTION'', ``BYE'', ``AUTH'', ``RESET'' and ``END''. It
is possible, but not recommended, to override these commands.
@end deftypefun
@deftypefun assuan_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{int @var{err}})
Register a function to be called right after a command has been
processed. @var{err} is the result code from the last internal assuan
operation and not the one returned by the handler. It may be used for
command-related cleanup.
@end deftypefun
@deftypefun assuan_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)})
Register function @var{fnc} with context @var{ctx} to be called right
before the standard handler for the ``BYE'' command is being called.
@end deftypefun
@deftypefun assuan_error_t assuan_register_reset_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)})
Register function @var{fnc} with context @var{ctx} to be called right
before the standard handler for the ``RESET'' command is being called.
@end deftypefun
@deftypefun assuan_error_t assuan_register_cancel_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)})
Register function @var{fnc} with context @var{ctx} to be called right
before the standard handler for the ``RESET'' command is being called.
@end deftypefun
@deftypefun assuan_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{int (*@var{fnc})(assuan_context_t, const char*, const char*)})
Register function @var{fnc} with context @var{ctx} for processing
options. That function is being called with the context, the name and
the value of the option. Leading and trailing spaces are removed from
the name and the value. The optional leading two dashes of the name
are removed as well. If no value has been given, an empty string is
passed. The function needs to return @code{0} on success or an error
code.
@end deftypefun
@deftypefun assuan_error_t assuan_register_input_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)})
Although the input function may be overridden with a custom handler, it
is often more convenient to use the default handler and to know whether
an ``INPUT'' command has been seen and successfully parsed. The second
argument passed to that function is the entire line. Because that line
has already been parsed when the function gets called, a file descriptor
set with the ``INPUT'' command may already be used. That file
descriptor is available by calling @code{assuan_get_input_fd}.
@end deftypefun
@deftypefun assuan_error_t assuan_register_output_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)})
Although the output function may be overridden with a custom handler, it
is often more convenient to use the default handler and to know whether
an ``OUTPUT'' command has been seen and successfully parsed. The second
argument passed to that function is the entire line. Because that line
has already been parsed when the function gets called, a file descriptor
set with the ``OUTPUT'' command may already be used. That file
descriptor is available by calling @code{assuan_get_output_fd}.
@end deftypefun
@deftypefun assuan_error_t assuan_set_hello_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}})
This is not actually a register function but may be called also after
registering commands. It changes the ``Hello'' line, sent by the
server to the client as a first response, from a default string to the
string @var{line}. For logging purposes, it is often useful to use
such a custom hello line which may tell version numbers and such.
Linefeeds are allowed in this string, however, each line needs to be
shorter than the Assuan line length limit.
@end deftypefun
@noindent
As a last initialization step, debugging may be enabled for the
current connection. This is done using
@deftypefun void assuan_set_log_stream (@w{assuan_context_t @var{ctx}}, @w{FILE *@var{fp}})
Enable debugging for the context @var{ctx} and write all debugging
output to the stdio stream @var{fp}. If the default log stream (used
for non-context specific events) has not yet been set, a call to this
functions implicitly sets this stream also to @var{fp}.
@end deftypefun
@noindent
Now that everything has been setup, we can start to process our
clients requests.
@example
for (;;)
@{
rc = assuan_accept (ctx);
if (rc == -1)
break;
else if (rc)
@{
fprintf (stderr, "accept problem: %s\n", gpg_strerror (rc));
break;
@}
rc = assuan_process (ctx);
if (rc)
@{
fprintf (stderr, "processing failed: %s\n", gpg_strerror (rc));
continue;
@}
@}
assuan_deinit_server (ctx);
@}
@end example
@noindent
For future extensibility and to properly detect the end of the
connection the core of the server should loop over the
accept and process calls.
@deftypefun assuan_error_t assuan_accept (@w{assuan_context_t @var{ctx}})
A call to this function cancel any existing connection and waits for a
connection from a client (that might be skipped, depending on the type
of the server). The initial handshake is performed which may include an
initial authentication or encryption negotiation. On success @code{0}
is returned. An error code will be returned if the connection could for
some reason not be established. An error code of @code{-1} indicates
the end of the connection.
@end deftypefun
@deftypefun assuan_error_t assuan_process (@w{assuan_context_t @var{ctx}})
This function is used to handle the Assuan protocol after a connection
has been established using @code{assuan_accept}. It is the main
protocol handler responsible for reading the client commands and calling
the appropriate handlers. The function returns @code{0} on success or
an error code if something went seriously wrong. Error codes from the
individual command handlers, i.e. operational error, are not seen here.
@end deftypefun
@noindent
After the loop has terminated, the Assuan context needs to be released:
@deftypefun void assuan_deinit_server (@w{assuan_context_t @var{ctx}})
Releases the resources described by the Assuan context @var{ctx} It is
explicitly allowed to pass @code{NULL} for @var{ctx}, in which case the
function does nothing.
@end deftypefun
@noindent
That is all needed for the server code. You only need to come up with
the code for the individual command handlers. Take care that the line
passed to the command handlers is allocated statically within the
context and calls to Assuan functions may modify that line. You are
also allowed to modify that line which makes parsing much easier.
@c
@c E x t e r n a l I / O L o o p s
@c
@node External I/O Loop
@chapter How to use external I/O event loops
The above implementations of an Assuan client and server are
synchronous, insofar the main routines block until a request or client
connection is completely processed. In some programs, for example GUI
applications, this is undesirable. Instead, Assuan operations should
be non-blocking, and the caller should be able to poll all involved
file descriptors to determine when the next Assuan function can be
invoked without blocking.
To make this possible, client and server have to adhere to some rules:
@itemize @bullet
@item
Either partner should always write full lines. If partial lines are
written, the remainder of the line should b sent without delay.
@item
Either partner should eagerly receive status messages. While
receiving and sending bulk data may be delayed, the status
communication channel is different: Both partners may send status
messages in blocking mode at any time the protocol allows them to send
such status messages. To ensure that these send operations do not
actually block the sender, the recipient must be ready to receive
without undue delay.
@item
If descriptor passing is used over a socket, the descriptor must be
sent after the corresponding command without undue delay.
@end itemize
Together, these restrictions allow to limit the need for asynchronous
I/O operations to bulk data and the inbound status file descriptor.
In addition to the above rules, client and server should adhere to the
following implementation guidelines.
@menu
* External I/O Loop Client:: External I/O event loops in the client.
* External I/O Loop Server:: External I/O event loops in the server.
@end menu
@node External I/O Loop Client
@section External I/O event loops in the client.
The reference implementation for using external I/O event loops in the
client is the GPGME library, which exports its own external I/O event
loop mechanism and utilizes the Assuan library transparently for the
user. The following steps document how GPGME achieves this.
@enumerate
@item
Before connecting, set up pipes for bulk data transfer (using the
INPUT/OUTPUT commands, for example). These are passed to the server
either by inheritance (using a pipe server) or by FD passing (using a
socket server).
@item
Then you need to connect to the server. GPGME uses a pipe server, so
it just spawns a server process, which is a non-blocking operation.
FIXME: Currently, using a client with external event loop over a
socket connection is not supported. It is easy to support (we just
need a variation of @code{assuan_socket_connect} which takes an
already connected socket FD and turns it into an Assuan context), so
if you need this let us know.
@item
After connecting, get the inbound status FD with
@code{assuan_get_active_fds} (the first one returned is the status
FD). This FD can be duplicated if it is convenient (GPGME does this
to be able to close this FD and associated callback handlers without
disrupting Assuan's internals).
@item
Then register the Assuan inbound status FD and all bulk data FDs with
the I/O event mechanism. In general, this requires setting up
callback handlers for these FDs and registering them with the main
event loop.
@item
When bulk data FDs become ready, you can simply perform the
corresponding read or write operations. When the inbound status FD
becomes ready, you can receive the next server line with
assuan_read_line().
@item
You should close and unregister the bulk data FDs when you wrote all
data (for outbound FDs) or receive an EOF (for inbound FDs). When you
receive an ERR from the server, or an OK for the final operation, you
can unregister the inbound status FD and call @code{assuan_disconnect}
to close it.
@item
As noted above, all send operations on the outbound status FD are done
immediate with blocking. In GPGME, this has never caused any problems.
@item
The @code{INQUIRE} function can be handled in two ways: If the
requested data is immediately available, the client can just send the
data blockingly. If the requested data needs to be fetched from a
blocking source, a callback handler can be registered for the FD with
the main event loop. GPGME does not support the @code{INQUIRE}
function, so we do not have any practical experience with this.
@end enumerate
Currently, the client can not cancel a pending operation gracefully.
It can, however, disconnect from the server at any time. It is the
responsibility of the server to periodically send status messages to
the client to probe if the connection remains alive.
@node External I/O Loop Server
@section External I/O event loops in the server.
Currently, no Assuan server exists which uses external I/O event
loops. However, the following guidelines should lead to a usable
implementation:
@enumerate
@item
For socket servers: You can not use @code{assuan_accept}, so you
should just implement the bind/connect/listen/accept stage yourself.
You can register the listen FD with your main event loop, accept the
connection when it becomes ready, and finally call
@code{assuan_init_socket_server_ext} with the final argument being 2
to create an Assuan context for this connection. This way you can
also handle multiple connections in parallel. The reference
implementation for this approach is DirMngr.
For pipe servers: @code{assuan_init_pipe_server} creates an Assuan
context valid for the pipe FDs.
@item
Once you have a context for a single connection, you can get the
inbound status FD with @code{assuan_get_active_fds} (the first one
returned is the status FD). This FD can be duplicated if it is
convenient. Every time the inbound status FD is readable, you should
invoke the function @code{assuan_process_next} (see below) to process
the next incoming message. @code{assuan_process_next} processes as
many status lines as can be received by a single @code{read}
operation. When it returns, the inbound status FD may still be
readable, but Assuan does not check this.
The function @code{assuan_process_next} returns 0 if it can not make
progress reliably, and it returns an end of file error code if the
client closed the connection. See below for more information on this
function.
@item
The command will be dispatched by @code{assuan_process_next} just as
with @code{assuan_process}, however, you will want to implement the
command handlers in such a way that they do not block. For example,
the command handler may just register the bulk data FDs with the main
event loop and return.
When the command is finished, irregardless if this happens directly in
the command handler or later, you must call @code{assuan_process_done}
with an appropriate error code (or 0 for success) to return an
appropriate status line to the client. You can do this at the end of
the command handler, for example by ending it with @code{return
assuan_process_done (error_code);}. Another possibility is to invoke
@code{assuan_process_done} from the place in the code which closes the
last active bulk FD registered with the main event loop for this
operation.
@end enumerate
It is not possible to use @code{assuan_inquire} in a command handler,
as this function blocks on receiving the inquired data from the
client. Instead, the asynchronous version @code{assuan_inquire_ext}
needs to be used (see below), which invokes a callback when the client
provided the inquired data. A typical usage would be for the command
handler to register a continuation with @code{assuan_inquire_ext} and
return 0. Eventually, the continuation would be invoked by
@code{assuan_process_next} when the client data arrived. The
continuation could complete the command and eventually call
@code{assuan_process_done}.
Cancellation is supported by returning an appropriate error code to
the client with @code{assuan_process_done}. For long running
operations, the server should send progress status messages to the
client in regular intervals to notice when the client disconnects.
@deftypefun assuan_error_t assuan_process_next (@w{assuan_context_t @var{ctx}})
This is the same as @code{assuan_process} but the caller has to
provide the outer loop. He should loop as long as the return code is
zero and stop otherwise; @code{-1} or @code{GPG_ERR_EOF} indicate a
regular end.
@end deftypefun
@deftypefun assuan_error_t assuan_inquire_ext (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{size_t @var{maxlen}}, @w{int (*@var{cb}) (void *cb_data, int rc, unsigned char *buffer, size_t buffer_len)}, @w{void *@var{cb_data}})
This is similar to @code{assuan_inquire} but the caller has to provide
the outer loop (using @code{assuan_process_next}). The caller should
specify a continuation with @var{cb}, which receives @var{cb_data} as
its first argument, and the error code as well as the inquired data as
its remaining arguments.
@end deftypefun
@c
@c U T I L I T I E S
@c
@node Utilities
@chapter Utility functions
@noindent
There are a lot of helper functions to make writing Assuan code easier.
Some of these functions provide information not available with the
general functions.
@deftypefun void assuan_set_pointer (@w{assuan_context_t @var{ctx}}, @w{void *@var{pointer}})
Store the arbitrary pointer value @var{pointer} into the context
@var{ctx}. This is useful to provide command handlers with additional
application context.
@end deftypefun
@deftypefun void* assuan_get_pointer (@w{assuan_context_t @var{ctx}})
This returns the pointer for context @var{ctx} which has been set using
the above function. A common way to use it is by setting the pointer
before starting the processing loop and to retrieve it right at the
start of a command handler:
@smallexample
static int
cmd_foo (assuan_context_t ctx, char *line)
@{
ctrl_t ctrl = assuan_get_pointer (ctx);
...
@}
@end smallexample
@end deftypefun
@deftypefun assuan_error_t assuan_write_status (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{const char *@var{text}})
This is a convenience function for a server to send a status line. You
need to pass it the @var{keyword} and the content of the status line in
@var{text}.
@end deftypefun
@deftypefun assuan_error_t assuan_inquire (@w{assuan_context_t @var{ctx}}, @w{const char *@var{keyword}}, @w{unsigned char **@var{r_buffer}}, @w{size_t *@var{r_length}}, @w{size_t @var{maxlen}})
A server may use this function to inquire data from a client. It sends
an ``INQUIRE'' command back to the server and returns the response
conveniently in a newly allocated buffer. You need to pass at least the
server's context @var{ctx} and the @var{keyword} describing the
requested data. All other parameters may be @code{NULL} or @code{0},
although this is rarely useful.
On success the result is stored in a newly allocated buffer stored at
@var{r_buffer}. The length of the data is stored at @var{r_length}. If
@var{maxlen} has not been given as @code{0}, it describes an upper size
limited of the expected data. If the client returns too much data the
function fails and the error code @code{GPG_ERR_ASS_TOO_MUCH_DATA} will
be returned.
@end deftypefun
@deftypefun FILE* assuan_get_data_fp (@w{assuan_context_t @var{ctx}})
Return a stdio stream for the Assuan context @var{ctx}. This stream may
then be used for data output (assuan_write_data). The stream is valid
until the end of the current handler. Calling @code{fclose} for that stream is
not required. Assuan does all the buffering needed to insert the status
line as well as the required line wrapping and quoting for data lines.
This function is only available on systems supporting either
@code{funopen} or @code{fopencookie}. If it is not supported @code{NULL}
is returned and @code{errno} is set to @code{ENOSYS}.
@end deftypefun
@deftypefun assuan_error_t assuan_set_okay_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}})
Set the text used for the next ``OK'' response to @var{line}. This is
sometimes useful to send additional human readable information along
with the OK line. The string is automatically reset at the end of the
current handler.
@end deftypefun
@deftypefun assuan_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{int *@var{rfd}})
This is the core of the default ``INPUT'' and ``OUTPUT'' handler. It
may be used in custom commands as well to negotiate a file descriptor.
If @var{line} contains @code{FD=@var{n}}, it returns @var{n} in
@var{rfd} assuming a local file descriptor. If @var{line} contains
just @code{FD} it returns a file descriptor at @var{rfd}; this file
descriptor needs to have been sent by the client right before using
@code{assuan_sendfd}.
On W32 systems the returned file descriptor is a system handle and not a
libc low level I/O file descriptor. Thus applications need to use
@code{_open_osfhandle} before they can pass this descriptor to standard
functions like @code{fdopen} or @code{dup}.
@end deftypefun
@deftypefun int assuan_get_input_fd (@w{assuan_context_t @var{ctx}})
Return the file descriptor sent by the client using the last ``INPUT''
command. Returns @code{-1} if no file descriptor is available.
@end deftypefun
@deftypefun int assuan_get_output_fd (@w{assuan_context_t @var{ctx}})
Return the file descriptor sent by the client using the last
``OUTPUT'' command. Returns @code{-1} if no file descriptor is
available.
@end deftypefun
@deftypefun assuan_error_t assuan_close_input_fd (@w{assuan_context_t @var{ctx}})
Close the file descriptor set by the last ``INPUT'' command. This
function has the advantage over a simple @code{close} that it can do
some sanity checks and make sure that a following
@code{assuan_get_input_fd} won't return an already closed descriptor.
@end deftypefun
@deftypefun assuan_error_t assuan_close_output_fd (@w{assuan_context_t @var{ctx}})
Close the file descriptor set by the last ``OUTPUT'' command. This
function has the advantage over a simple @code{close} that it can do
some sanity checks and make sure that a following
@code{assuan_get_input_fd} won't return an already closed descriptor.
@end deftypefun
@deftypefun int assuan_set_error (@w{assuan_context_t @var{ctx}}, @w{int @var{err}}, @w{const char *@var{text}})
This is a helper to provide a more descriptive error text with ``ERR''
lines. For this to work, the text needs to be stored in the context
@var{ctx} while still being in the command handler. This function is
commonly called this way
@smallexample
return assuan_set_error (ctx, err, "commands needs 5 arguments");
@end smallexample
The value @var{err} is passed through and thus the return value of the
command handler in the example. The provided text further explains
that error code to humans.
@end deftypefun
@deftypefun void assuan_set_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}}, @w{int @var{value}})
Set the the @var{flag} for context @var{ctx} to @var{value}. Values for
flags are usually 1 or 0 but certain flags might need other values.
@deftp {Data type} assuan_flag_t
The flags are all named and collected in an @code{enum} for better readability.
Currently only one flag is defined:
@table @code
@item ASSUAN_NO_WAITPID
When using a pipe server, by default Libassuan will wait for the forked
process to die in @code{assuan_disconnect}. In certain cases this is
not desirable. By setting this flag, a call to @code{waitpid} will be
suppressed and the caller is responsible to cleanup the child process.
@item ASSUAN_CONFIDENTIAL
Uses to return the state of the confidential logging mode. For changing
this mode the functions @code{assuan_begin_confidential} and
@code{assuan_end_confidential} should be used.
@end table
@end deftp
@end deftypefun
@deftypefun int assuan_get_flag (@w{assuan_context_t @var{ctx}}, @w{assuan_flag_t @var{flag}})
Return the value of @var{flag} in context @var{ctx}.
@end deftypefun
@deftypefun @w{const char*} assuan_strerror (@w{assuan_error_t @var{err}})
This function returns a textual representation of the given error code
@var{err}. If this is an unknown value, a string with the value is
returned. (Beware: it is hold in a static buffer). It is suggested that
gpg-error style error numbers should be used and thus
@code{gpg_strerror} be called. @xref{function
assuan_set_assuan_err_source}, on how to enable these error codes.
@end deftypefun
@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 mechanism is in place 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
@deftypefun int assuan_get_active_fds (@w{assuan_context_t @var{ctx}}, @w{int @var{what}}, @w{assuan_fd_t *@var{fdarray}}, @w{int @var{fdarraysize}})
Return all active file descriptors for the context @var{ctx}. This
function can be used to select on the file descriptors and to call
@code{assuan_process_next} if there is an active one. The first
descriptor in the array is the one used for the command connection.
Currently @var{what} needs to be @code{0} to return descriptors used for
reading, @code{1} will eventually be used to return descriptors used for
writing. @var{fdarray} is an array of integers provided by the caller;
@var{fdarraysize} gives the size of that array.
On success the number of active descriptors are returned. These active
descriptors are then stored in @var{fdarray}. On error @code{-1} is
returned; the most likely reason for this is a too small @var{fdarray}.
Note that on W32 systems the returned file descriptor is a system handle
and not a libc low level I/O file descriptor.
@end deftypefun
@deftypefun int assuan_pending_line (@w{assuan_context_t @var{ctx}})
A call to this function return true if a full line has been buffered and
thus an entire assuan line may be read without triggering any actual
I/O.
@end deftypefun
@deftypefun void assuan_set_io_monitor (@w{assuan_context_t @var{ctx}}, @w{unsigned int} (*@var{monitor})(@w{assuan_context_t @var{ctx}}, @w{int @var{direction}}, @w{const char *@var{line}}, @w{size_t @var{linelen}}))
This function registers an I/O monitor for the context @var{ctx}. Such
a monitor function is called right after a line has been received or
just before it is send. With @var{direction} set to 1 the monitor has
been called for an output operation; 0 obviosuly means it has been
called for an input operation. If the monitor sets bit 0 in the return
value, any active logging of the line will be suppressed. With bit 1
set, the entire line will be ignored.
@end deftypefun
@deftypefun void assuan_begin_confidential (@w{assuan_context_t @var{ctx}})
Put the logging feature into confidential mode. This is to avoid
logging of sensitive data.
@end deftypefun
@deftypefun void assuan_end_confidential (@w{assuan_context_t @var{ctx}})
Get the logging feature out of confidential mode. All data will be
logged again (if logging is enabled).
@end deftypefun
@deftypefun FILE* assuan_get_assuan_log_stream (void)
Return the stream which is currently being using for global logging.
@end deftypefun
@deftypefun @w{const char*} assuan_get_assuan_log_prefix (void)
Return the prefix to be used at the start of a line emitted by assuan
on the log stream. The default implementation returns the empty
string.
@end deftypefun
@c
@c S O C K E T W R A P P E R S
@c
@node Socket wrappers
@chapter Socket wrapper functions
@noindent
It is sometimes useful to support Unix domain sockets on Windows. To do
this in a portable way, Assuan provides a set of wrapper functions which
may be used on any system but will enhance Windows to support these
socket types. The actual implementation is based on local TCP sockets
and fully transparent for the client. Server code needs to utilize two
extra functions to check the permissions.
@deftypefun int assuan_sock_close (@w{assuan_fd_t @var{fd}})
Wrapper for close which does a closesocket on Windows if needed.
@end deftypefun
@deftypefun assuan_fd_t assuan_sock_new (@w{int @var{domain}}, @w{int @var{type}}, @w{int @var{proto}});
Wrapper around socket.
@end deftypefun
@deftypefun int assuan_sock_connect (@w{assuan_fd_t @var{sockfd}}, @
@w{struct sockaddr *@var{addr}}, @
@w{int @var{addrlen}})
Wrapper around connect. For Unix domain sockets under Windows this
function also does a write immediatley after the the connect to send the
nonce as read from the socket's file.
@end deftypefun
@deftypefun int assuan_sock_bind ( @
@w{assuan_fd_t @var{sockfd}}, @
@w{struct sockaddr *@var{addr}}, @
@w{int @var{addrlen}})
Wrapper around bind. Under Windows this creates a file and writes the
port number and a random nonce to this file.
@end deftypefun
@deftypefun int assuan_sock_get_nonce ( @
@w{struct sockaddr *@var{addr}}, @
@w{int @var{addrlen}}, @
@w{assuan_sock_nonce_t *@var{nonce}})
This is used by the server after a bind to return the random nonce. To
keep the code readable this may also be used on POSIX system.
@end deftypefun
@deftypefun int assuan_sock_check_nonce ( @
@w{assuan_fd_t @var{fd}}, @
@w{assuan_sock_nonce_t *@var{nonce}})
On Windows this is used by the server after an accept to read the nonce
from the client and compare it with the saved @var{nonce}. If this
function fails the server should immediatly drop the connection. To
keep the code readable this may also be used on POSIX system; it is a
dummy function then. See also @code{assuan_set_sock_nonce}.
@end deftypefun
@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/src/ChangeLog b/src/ChangeLog
index d114b47..ec6afaf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,1293 +1,1300 @@
+2008-10-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * assuan.h (assuan_error_t) (_ASSUAN_ONLY_GPG_ERRORS): Make
+ unsigned int.
+ (assuan_transact): Change return type of callback handlers to
+ assuan_error_t.
+
2008-10-15 Werner Koch <wk@g10code.com>
* assuan-logging.c (_assuan_log_printf): Flush if the format
string ends with a LF.
2008-09-01 Werner Koch <wk@g10code.com>
* assuan-io.c: Include time.h. Fixes bug#951.
(_assuan_usleep): Use nanosleep only is available.
2008-03-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-inquire.c (assuan_inquire): Loop over _assuan_read_line
for EAGAIN.
2008-03-21 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (_assuan_usleep): New prototype.
* assuan-io.c (_assuan_usleep): New function.
* assuan-io-pth.c (_assuan_usleep): New function.
* mkerrors: Do not incude <windows.h>, but assuan-defs.h.
(_assuan_error_is_eagain): Call _assuan_usleep.
* mkerrors [HAVE_W32_SYSTEM]: Include <windows.h>
(_assuan_error_is_eagain) [HAVE_W32_SYSTEM]: Wait the tenth of a
second.
2007-11-23 Marcus Brinkmann <marcus@g10code.de>
* assuan-inquire.c (_assuan_inquire_ext_cb): Pass through return
value from callback function.
Suggested by Ben Kibbey <bjk@luxsci.net>.
2007-11-14 Werner Koch <wk@g10code.com>
* assuan-pipe-connect.c (pipe_connect_unix): Add dummy arg FLAGS.
(pipe_connect_w32): Add arg FLAGS and start process detached if
requested. Changed callers to pass 0.
(assuan_pipe_connect_ext): Pass FLAG.
2007-11-12 Marcus Brinkmann <marcus@g10code.de>
* assuan-inquire.c (_assuan_inquire_ext_cb): Clear
CTX->inquire_membuf after deallocating it.
2007-10-18 Marcus Brinkmann <marcus@g10code.de>
* assuan-handler.c (std_handler_help): New function.
(std_cmd_table): Add new command HELP.
2007-10-08 Werner Koch <wk@g10code.com>
* assuan-util.c (assuan_set_io_hooks): New.
* assuan.h (struct assuan_io_hooks): New.
(assuan_set_io_hooks, _assuan_io_hooks): Add prefix macros.
* assuan-defs.h (_assuan_io_hooks): New.
* assuan-io.c (do_io_read): Take all code from _assuan_io_read.
(_assuan_io_read, _assuan_simple_read): Add hook feature.
(do_io_write): Take all code from _assuan_io_write.
(_assuan_io_write, _assuan_simple_write): Add hook feature.
* assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write)
(_assuan_io_read, _assuan_io_write): Add hook feature.
2007-10-05 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_assuan_error_is_eagain): Add prefix macro.
* assuan-defs.h (_assuan_error_is_eagain): New prototype.
* mkerrors (_assuan_error_is_eagain): New function.
* assuan-handler.c (process_next): Leave on EAGAIN.
* assuan-handler.c (process_request),
assuan-client.c (_assuan_read_from_server),
assuan-buffer.c (assuan_read_line): Busy loop over EAGAIN.
2007-10-05 Werner Koch <wk@g10code.com>
* assuan-socket.c (_assuan_sock_wsa2errno): Map WSANOTINITIALISED.
(_assuan_sock_new): Use assuan_fd_t.
* assuan.h (_assuan_sock_wsa2errno): Add prefix macro.
2007-10-05 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (_assuan_sock_wsa2errno) [HAVE_W32_SYSTEM]: Add prototype.
* assuan-uds.c (wsa2errno) [HAVE_W32_SYSTEM]: Move and rename to ...
* assuan-socket.c (_assuan_sock_wsa2errno) [HAVE_W32_SYSTEM]: ... this.
(_assuan_close, _assuan_sock_new, _assuan_sock_connect, _assuan_sock_bind):
Always set errno on error.
* assuan-uds.c (wsa2errno) [HAVE_W32_SYSTEM]: New function.
(uds_reader, uds_writer) [HAVE_W32_SYSTEM]: Set errno.
2007-10-04 Werner Koch <wk@g10code.com>
* mkerrors: Map EAGAIN to GPG_ERR_EAGAIN for read and write
errors.
2007-10-02 Werner Koch <wk@g10code.com>
* assuan-io.c (_assuan_io_read) [W32]: Map WSAEWOULDBLOCK to EAGAIN.
* assuan-socket.c (_assuan_sock_check_nonce): N needs to be signed.
* assuan-defs.h (struct assuan_context_s): Add LISTEN_NONCE.
* assuan-socket-server.c (assuan_set_sock_nonce): New.
(accept_connection): Check the nonce.
2007-10-01 Werner Koch <wk@g10code.com>
* assuan.h (ASSUAN_INT2FD, ASSUAN_FD2INT): New.
* assuan-socket.c: Rewritten.
(assuan_sock_new, assuan_sock_connect, assuan_sock_bind)
(assuan_sock_get_nonce, assuan_sock_check_nonce): New APIs.
* assuan-io.c (_assuan_simple_read, _assuan_simple_write):
Factored code out to ...
(_assuan_io_read, _assuan_io_write): .. new.
* assuan-io-pth.c (_assuan_io_read, _assuan_io_write): New.
2007-09-25 Werner Koch <wk@g10code.com>
* assuan.h (_assuan_gpg_strerror_r, _assuan_gpg_strsource): Add
wrappers for these new internal functions.
2007-09-24 Marcus Brinkmann <marcus@g10code.de>
* assuan-uds.c (uds_reader) [HAVE_W32_SYSTEM]: Do not touch the
UDS structure in the context. Reported by Frank Osterfeld.
(uds_writer): Clarify code.
2007-09-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (do_finish) [HAVE_W32_SYSTEM]: Close
ctx->pid as handle.
(pipe_connect_w32): Save the spawned processes handle.
2007-09-13 Werner Koch <wk@g10code.com>
* assuan-socket.c (_assuan_close): Add inactive debug outputs.
2007-09-11 Marcus Brinkmann <marcus@g10code.de>
* assuan.h: Use _WIN32 instead of HAVE_W32_SYSTEM.
2007-09-07 Marcus Brinkmann <marcus@g10code.de>
* assuan-inquire.c (assuan_inquire_ext): If MAXLEN is 0, still
initialize MEMBUF.
* assuan-inquire.c (_assuan_inquire_ext_cb): Clear CTX->in_inquire
before invoking callback and returning.
2007-09-05 Marcus Brinkmann <marcus@g10code.de>
* assuan-handler.c (dispatch_command): Return non-critical errors
with PROCESS_DONE ().
2007-09-03 Marcus Brinkmann <marcus@g10code.de>
* assuan.h [_ASSUAN_EXT_SYM_PREFIX]: Add missing symbol renames
with _ASSUAN_PREFIX.
2007-09-03 Marcus Brinkmann <marcus@g10code.de>
* assuan.h [_ASSUAN_EXT_SYM_PREFIX]: Add missing symbol renames
with _ASSUAN_PREFIX.
* assuan.h (assuan_inquire_ext): Move buffer and buffer_length
arguments callback in prototype.
* assuan-defs.h (struct assuan_context_s): Remove members
inquire_r_buffer and inquire_r_buffer_len. Add buffer and buffer
length arguments to inquire_cb.
* assuan-inquire.c (_assuan_inquire_ext_cb): Return buffer and
buffer length via callback.
(assuan_inquire_ext): Move buffer and buffer length arguments to
callback.
2007-08-24 Werner Koch <wk@g10code.com>
Switched license to back to LGPLv2.1.
2007-08-09 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (assuan_process_done, assuan_inquire_ext): New
prototypes.
* assuan-defs.h (struct assuan_context_s): New members
in_process_next, in_command, inquire_cb, inquire_cb_data,
inquire_r_buffer, inquire_r_buffer_len, inquire_membuf.
(_assuan_inquire_ext_cb, _assuan_inquire_release): New prototypes.
* assuan-handler.c (PROCESS_DONE): New macro.
(dummy_handler, std_handler_nop, std_handler_cancel)
(std_handler_option, std_handler_bye, std_handler_auth)
(std_handler_reset, std_handler_end): Use PROCESS_DONE to
optionally call assuan_process_done if CTX->in_process_next is
true.
(assuan_process_done, process_next): New functions.
(assuan_process_next): Rewritten to support external event
handling.
* mkerrors: Do not clear high bits of -1 for old style EOF.
* assuan-inquire.c (_assuan_inquire_release)
(_assuan_inquire_ext_cb, assuan_inquire_ext): New functions.
* assuan-pipe-server.c (_assuan_release_context): Call
_assuan_inquire_release.
2007-07-12 Werner Koch <wk@g10code.com>
* assuan.h (assuan_fd_t): New.
(ASSUAN_INVALID_FD): New. Use it everywhere.
* assuan-defs.h (SOCKET2HANDLE, HANDLE2SOCKET) [W32]: New. Use
them to cast descriptors for socket fucntions.
* assuan-pipe-connect.c (fd_to_handle, handle_to_fd): Remove
definition and all uses.
(pid_to_handle, handle_to_pid): Remove as they are ununsed.
* assuan-io.c (_assuan_simple_write, _assuan_simple_read) [W32]:
Make use of HANDLE2SOCKET.
* assuan-socket.c (_assuan_close) [W32]: Use CloseHandle and not
close.
* assuan-handler.c (assuan_get_active_fds) [W32]: Use
_get_osfhandle for the data fp.
* assuan-io.c (_assuan_simple_write): Return EPIPE on a closed pipe.
(_assuan_simple_read): Likewise
2007-07-08 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (struct assuan_context_s): Have full peercred
structure for HAVE_SO_PEERCRED.
* assuan-connect.c (assuan_get_peercred) [!HAVE_SO_PEERCRED]: Do
not try to set PID, UID and GID.
2007-07-05 Werner Koch <wk@g10code.com>
* assuan-defs.h (struct assuan_context_s): Have peercred.valid
even for Windows. This makes some other code cleaner.
* assuan.h (ASSUAN_CONFIDENTIAL): New flag.
* assuan-util.c (assuan_set_flag, assuan_get_flag): Support flag.
2007-07-04 Marcus Brinkmann <marcus@g10code.de>
Change _WIN32 to HAVE_W32_SYSTEM for consistency.
* assuan-defs.h (struct assuan_context_s): Have full peercred
structure even if not HAVE_SO_PEERCRED, but not if
HAVE_W32_SYSTEM.
2007-06-18 Werner Koch <wk@g10code.com>
* assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r)
(_assuan_gpg_strsource): New.
* assuan-handler.c (process_request) [W32]: Use these new
functions for human understable error codes.
2007-06-12 Werner Koch <wk@g10code.com>
* assuan-io.c (_assuan_simple_read): Hack to allow reading from a
socket.
(_assuan_simple_write): Likewise.
2007-06-11 Werner Koch <wk@g10code.com>
* assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use
pth versions also for W32.
2007-05-29 Werner Koch <wk@g10code.com>
* assuan-io-pth.c: Include sys/socket.h only if available. Remove
double inclusion of sys/wait.h
* assuan-pipe-connect.c (build_w32_commandline): Make ARGV const.
* assuan-pipe-server.c (is_valid_socket) [W32]: Do not define.
* assuan-socket-server.c [W32]: Include ws2tcpip.h to define
socklen_t.
* assuan-defs.h (struct assuan_context_s): Define most peercred
members only if we can really set them.
(_assuan_simple_sendmsg, _assuan_simple_recvmsg) [W32]: Use a
different prototype.
* assuan.h (assuan_get_peercred) [W32]: Do not define.
* assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg)
[w32]: Use another prototype.
2007-05-09 Werner Koch <wk@g10code.com>
* libassuan.m4: Print found version on success.
2007-05-01 Werner Koch <wk@g10code.com>
* assuan-uds.c (uds_reader): Cast void ptr for arithmetics.
Reported by Peter O'Gorman.
2006-12-03 Marcus Brinkmann <marcus@g10code.de>
* assuan-handler.c (assuan_command_parse_fd): Also allow white
space after FD.
2006-12-02 Marcus Brinkmann <marcus@g10code.de>
* assuan-uds.c (uds_reader): Return 0 if recvmsg returns 0.
2006-12-01 Marcus Brinkmann <marcus@g10code.de>
* assuan-client.c (assuan_transact): Also translate some of the
legacy error codes.
2006-11-22 Werner Koch <wk@g10code.com>
* assuan-handler.c (fun1_cookie_write, fun2_cookie_write): New.
(assuan_get_data_fp) [HAVE_FUNOPEN]: Use it.
2006-11-21 Werner Koch <wk@g10code.com>
* Makefile.am (libassuan_pth_a_CFLAGS): New.
* assuan-pipe-server.c (_assuan_release_context): Free CMDTBL.
2006-11-14 Werner Koch <wk@g10code.com>
* libassuan.m4 (AM_CHECK_LIBASSUAN): New.
* assuan-handler.c (assuan_register_post_cmd_notify)
(assuan_register_post_cmd_notify): New.
* assuan-util.c (assuan_set_io_monitor): New.
* assuan-buffer.c (_assuan_read_line): Use it.
(_assuan_write_line): Ditto.
(_assuan_cookie_write_data): Ditto.
(_assuan_cookie_write_flush): Ditto.
2006-10-18 Werner Koch <wk@g10code.com>
* libassuan.m4: Pass "pthread" to the common macro. Reported by
Rex Dieter.
2006-10-16 Werner Koch <wk@g10code.com>
* mkerrors: Map ASSUAN_Not_Confirmed.
2006-10-10 Werner Koch <wk@g10code.com>
* libassuan.m4 (AM_PATH_LIBASSUAN_PTH)
(AM_PATH_LIBASSUAN_PTHREAD): Fixed.
* assuan-buffer.c (assuan_sendfd): Implement a runtime detection
of implemented descripotr passing.
* assuan-uds.c: Take care of USE_DESCRIPTOR_PASSING.
* assuan-defs.h: Add missing semicolon.
2006-10-09 Werner Koch <wk@g10code.com>
* assuan-handler.c (process_request): Use weak pragma for the sake
of old gcc's. Reported by Alain Guibert.
* 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, 2007 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/assuan.h b/src/assuan.h
index a99e89b..f2d2feb 100644
--- a/src/assuan.h
+++ b/src/assuan.h
@@ -1,658 +1,659 @@
/* assuan.h - Definitions for the Assuan IPC library
* Copyright (C) 2001, 2002, 2003, 2005, 2007,
* 2008 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef ASSUAN_H
#define ASSUAN_H
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef _ASSUAN_NO_SOCKET_WRAPPER
#ifdef _WIN32
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#endif
#endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/
/* To use this file with libraries the following macros are useful:
#define _ASSUAN_EXT_SYM_PREFIX _foo_
This prefixes all external symbols with "_foo_".
#define _ASSUAN_ONLY_GPG_ERRORS
If this is defined all old-style Assuan error codes are made
inactive as well as other deprecated stuff.
#define _ASSUAN_NO_SOCKET_WRAPPER
Do not include the definitions for the socket wrapper feature.
The follwing macros are used internally in the implementation of
libassuan:
#define _ASSUAN_NO_PTH
This avoids inclusion of special GNU Pth hacks.
#define _ASSUAN_NO_FIXED_SIGNALS
This disables changing of certain signal handler; i.e. SIGPIPE.
#define _ASSUAN_USE_DOUBLE_FORK
Use a double fork approach when connecting to a server through
a pipe.
*/
#ifdef _ASSUAN_EXT_SYM_PREFIX
#define _ASSUAN_PREFIX1(x,y) x ## y
#define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y)
#define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
#define assuan_ _ASSUAN_PREFIX(assuan_)
#define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
#define assuan_register_post_cmd_notify \
_ASSUAN_PREFIX(assuan_register_post_cmd_notify)
#define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify)
#define assuan_register_reset_notify \
_ASSUAN_PREFIX(assuan_register_reset_notify)
#define assuan_register_cancel_notify \
_ASSUAN_PREFIX(assuan_register_cancel_notify)
#define assuan_register_input_notify \
_ASSUAN_PREFIX(assuan_register_input_notify)
#define assuan_register_output_notify \
_ASSUAN_PREFIX(assuan_register_output_notify)
#define assuan_register_option_handler \
_ASSUAN_PREFIX(assuan_register_option_handler)
#define assuan_process _ASSUAN_PREFIX(assuan_process)
#define assuan_process_next _ASSUAN_PREFIX(assuan_process_next)
#define assuan_process_done _ASSUAN_PREFIX(assuan_process_done)
#define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds)
#define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp)
#define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line)
#define assuan_write_status _ASSUAN_PREFIX(assuan_write_status)
#define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd)
#define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line)
#define assuan_accept _ASSUAN_PREFIX(assuan_accept)
#define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd)
#define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd)
#define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd)
#define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd)
#define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server)
#define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server)
#define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server)
#define assuan_init_connected_socket_server \
_ASSUAN_PREFIX(assuan_init_connected_socket_server)
#define assuan_init_socket_server_ext \
_ASSUAN_PREFIX(assuan_init_socket_server_ext)
#define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect)
#define assuan_pipe_connect_ext _ASSUAN_PREFIX(assuan_pipe_connect_ext)
#define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect)
#define assuan_socket_connect_ext _ASSUAN_PREFIX(assuan_socket_connect_ext)
#define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect)
#define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid)
#define assuan_get_peercred _ASSUAN_PREFIX(assuan_get_peercred)
#define assuan_transact _ASSUAN_PREFIX(assuan_transact)
#define assuan_inquire _ASSUAN_PREFIX(assuan_inquire)
#define assuan_inquire_ext _ASSUAN_PREFIX(assuan_inquire_ext)
#define assuan_read_line _ASSUAN_PREFIX(assuan_read_line)
#define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line)
#define assuan_write_line _ASSUAN_PREFIX(assuan_write_line)
#define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
#define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
#define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
#define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
#define assuan_set_io_hooks _ASSUAN_PREFIX(assuan_set_io_hooks)
#define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
#define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
#define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
#define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
#define assuan_set_io_monitor _ASSUAN_PREFIX(assuan_set_io_monitor)
#define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
#define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
#define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
#define assuan_set_assuan_err_source \
_ASSUAN_PREFIX(assuan_set_assuan_err_source)
#define assuan_set_assuan_log_stream \
_ASSUAN_PREFIX(assuan_set_assuan_log_stream)
#define assuan_get_assuan_log_stream \
_ASSUAN_PREFIX(assuan_get_assuan_log_stream)
#define assuan_get_assuan_log_prefix \
_ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
#define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag)
#define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag)
#define assuan_pipe_connect2 _ASSUAN_PREFIX(assuan_pipe_connect2)
#define assuan_set_assuan_log_prefix \
_ASSUAN_PREFIX(assuan_set_assuan_log_prefix)
#define assuan_sock_close _ASSUAN_PREFIX(assuan_sock_close)
#define assuan_sock_new _ASSUAN_PREFIX(assuan_sock_new)
#define assuan_sock_connect _ASSUAN_PREFIX(assuan_sock_connect)
#define assuan_sock_bind _ASSUAN_PREFIX(assuan_sock_bind)
#define assuan_sock_get_nonce _ASSUAN_PREFIX(assuan_sock_get_nonce)
#define assuan_sock_check_nonce _ASSUAN_PREFIX(assuan_sock_check_nonce)
/* And now the internal functions, argh... */
#define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
#define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
#define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
#define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
#define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
#define _assuan_register_std_commands \
_ASSUAN_PREFIX(_assuan_register_std_commands)
#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
#define _assuan_io_read _ASSUAN_PREFIX(_assuan_io_read)
#define _assuan_io_write _ASSUAN_PREFIX(_assuan_io_write)
#define _assuan_io_hooks _ASSUAN_PREFIX(_assuan_io_hooks)
#define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
#define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
#define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
#define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
#define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
#define _assuan_free _ASSUAN_PREFIX(_assuan_free)
#define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
#define _assuan_log_sanitized_string \
_ASSUAN_PREFIX(_assuan_log_sanitized_string)
#define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf)
#define _assuan_set_default_log_stream \
_ASSUAN_PREFIX(_assuan_set_default_log_stream)
#define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror)
#define _assuan_gpg_strerror_r _ASSUAN_PREFIX(_assuan_gpg_strerror_r)
#define _assuan_gpg_strsource _ASSUAN_PREFIX(_assuan_gpg_strsource)
#define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line)
#define _assuan_error _ASSUAN_PREFIX(_assuan_error)
#define _assuan_error_is_eagain _ASSUAN_PREFIX(_assuan_error_is_eagain)
#define _assuan_init_uds_io _ASSUAN_PREFIX(_assuan_init_uds_io)
#define _assuan_uds_close_fds _ASSUAN_PREFIX(_assuan_uds_close_fds)
#define _assuan_uds_deinit _ASSUAN_PREFIX(_assuan_uds_deinit)
#define _assuan_simple_recvmsg _ASSUAN_PREFIX(_assuan_simple_recvmsg)
#define _assuan_simple_sendmsg _ASSUAN_PREFIX(_assuan_simple_sendmsg)
#define _assuan_waitpid _ASSUAN_PREFIX(_assuan_waitpid)
#define _assuan_sock_wsa2errno _ASSUAN_PREFIX(_assuan_sock_wsa2errno)
#define _assuan_sock_close _ASSUAN_PREFIX(_assuan_sock_close)
#define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new)
#define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect)
#define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind)
#define _assuan_sock_get_nonce _ASSUAN_PREFIX(_assuan_sock_get_nonce)
#define _assuan_sock_check_nonce _ASSUAN_PREFIX(_assuan_sock_check_nonce)
#endif /*_ASSUAN_EXT_SYM_PREFIX*/
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
/* Check for compiler features. */
#if __GNUC__
#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#if _ASSUAN_GCC_VERSION > 30100
#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
#endif
#endif
#ifndef _ASSUAN_DEPRECATED
#define _ASSUAN_DEPRECATED
#endif
/* Assuan error codes. These are only used by old applications or
those applications which won't make use of libgpg-error. */
#ifndef _ASSUAN_ONLY_GPG_ERRORS
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_No_Error 0
#endif
#define ASSUAN_General_Error 1
#define ASSUAN_Out_Of_Core 2
#define ASSUAN_Invalid_Value 3
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Timeout 4
#endif
#define ASSUAN_Read_Error 5
#define ASSUAN_Write_Error 6
#define ASSUAN_Problem_Starting_Server 7
#define ASSUAN_Not_A_Server 8
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Not_A_Client 9
#endif
#define ASSUAN_Nested_Commands 10
#define ASSUAN_Invalid_Response 11
#define ASSUAN_No_Data_Callback 12
#define ASSUAN_No_Inquire_Callback 13
#define ASSUAN_Connect_Failed 14
#define ASSUAN_Accept_Failed 15
/* Error codes above 99 are meant as status codes */
#define ASSUAN_Not_Implemented 100
#define ASSUAN_Server_Fault 101
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Invalid_Command 102
#endif
#define ASSUAN_Unknown_Command 103
#define ASSUAN_Syntax_Error 104
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Parameter_Error 105
#endif
#define ASSUAN_Parameter_Conflict 106
#define ASSUAN_Line_Too_Long 107
#define ASSUAN_Line_Not_Terminated 108
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_No_Input 109
#define ASSUAN_No_Output 110
#endif
#define ASSUAN_Canceled 111
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Unsupported_Algorithm 112
#define ASSUAN_Server_Resource_Problem 113
#define ASSUAN_Server_IO_Error 114
#define ASSUAN_Server_Bug 115
#define ASSUAN_No_Data_Available 116
#define ASSUAN_Invalid_Data 117
#endif
#define ASSUAN_Unexpected_Command 118
#define ASSUAN_Too_Much_Data 119
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Inquire_Unknown 120
#define ASSUAN_Inquire_Error 121
#define ASSUAN_Invalid_Option 122
#define ASSUAN_Invalid_Index 123
#define ASSUAN_Unexpected_Status 124
#define ASSUAN_Unexpected_Data 125
#define ASSUAN_Invalid_Status 126
#define ASSUAN_Locale_Problem 127
#endif
#define ASSUAN_Not_Confirmed 128
/* Warning: Don't use the Error codes, below they are deprecated. */
#ifndef _ASSUAN_IN_LIBASSUAN
#define ASSUAN_Bad_Certificate 201
#define ASSUAN_Bad_Certificate_Chain 202
#define ASSUAN_Missing_Certificate 203
#define ASSUAN_Bad_Signature 204
#define ASSUAN_No_Agent 205
#define ASSUAN_Agent_Error 206
#define ASSUAN_No_Public_Key 207
#define ASSUAN_No_Secret_Key 208
#define ASSUAN_Invalid_Name 209
#define ASSUAN_Cert_Revoked 301
#define ASSUAN_No_CRL_For_Cert 302
#define ASSUAN_CRL_Too_Old 303
#define ASSUAN_Not_Trusted 304
#define ASSUAN_Card_Error 401
#define ASSUAN_Invalid_Card 402
#define ASSUAN_No_PKCS15_App 403
#define ASSUAN_Card_Not_Present 404
#define ASSUAN_Invalid_Id 405
/* Error codes in the range 1000 to 9999 may be used by applications
at their own discretion. */
#define ASSUAN_USER_ERROR_FIRST 1000
#define ASSUAN_USER_ERROR_LAST 9999
#endif
typedef int assuan_error_t;
typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED;
/* This is a list of pre-registered ASSUAN commands */
/* Note, these command IDs are now deprectated and solely exists for
compatibility reasons. */
typedef enum
{
ASSUAN_CMD_NOP = 0,
ASSUAN_CMD_CANCEL, /* cancel the current request */
ASSUAN_CMD_BYE,
ASSUAN_CMD_AUTH,
ASSUAN_CMD_RESET,
ASSUAN_CMD_OPTION,
ASSUAN_CMD_DATA,
ASSUAN_CMD_END,
ASSUAN_CMD_INPUT,
ASSUAN_CMD_OUTPUT,
ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
} AssuanCommand;
#else /*!_ASSUAN_ONLY_GPG_ERRORS*/
-typedef int assuan_error_t;
+/* Choose a type compatible with gpg_error_t. */
+typedef unsigned int assuan_error_t;
#endif /*!_ASSUAN_ONLY_GPG_ERRORS*/
/* Definitions of flags for assuan_set_flag(). */
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,
/* This flag indicates whether Assuan logging is in confidential
mode. Use assuan_{begin,end}_condidential to change the
mode. */
ASSUAN_CONFIDENTIAL = 2
}
assuan_flag_t;
#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
struct assuan_context_s;
typedef struct assuan_context_s *assuan_context_t;
#ifndef _ASSUAN_ONLY_GPG_ERRORS
typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED;
#endif /*_ASSUAN_ONLY_GPG_ERRORS*/
/* Because we use system handles and not libc low level file
descriptors on W32, we need to declare them as HANDLE (which
actually is a plain pointer). This is required to eventually
support 64 bit Windows systems. */
#ifdef _WIN32
typedef void *assuan_fd_t;
#define ASSUAN_INVALID_FD ((void*)(-1))
#define ASSUAN_INT2FD(s) ((void *)(s))
#define ASSUAN_FD2INT(h) ((unsigned int)(h))
#else
typedef int assuan_fd_t;
#define ASSUAN_INVALID_FD (-1)
#define ASSUAN_INT2FD(s) ((s))
#define ASSUAN_FD2INT(h) ((h))
#endif
/* Assuan features an emulation of Unix domain sockets based on a
local TCP connections. To implement access permissions based on
file permissions a nonce is used which is expected by th server as
the first bytes received. This structure is used by the server to
save the nonce created initially by bind. On POSIX systems this is
a dummy operation. */
struct assuan_sock_nonce_s
{
size_t length;
#ifdef _WIN32
char nonce[16];
#endif
};
typedef struct assuan_sock_nonce_s assuan_sock_nonce_t;
/* Define the Unix domain socket structure for Windows. */
#if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER)
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
#endif
#define EADDRINUSE WSAEADDRINUSE
struct sockaddr_un
{
short sun_family;
unsigned short sun_port;
struct in_addr sun_addr;
char sun_path[108-2-4];
};
#endif
/* Definition of hook functions used to conditionally replace the
default I/O functions. */
struct assuan_io_hooks
{
int (*read_hook)(assuan_context_t, assuan_fd_t, void *, size_t, ssize_t *);
int (*write_hook)(assuan_context_t, assuan_fd_t fd,
const void *, size_t, ssize_t *);
};
typedef struct assuan_io_hooks *assuan_io_hooks_t;
/*-- assuan-handler.c --*/
int assuan_register_command (assuan_context_t ctx,
const char *cmd_string,
int (*handler)(assuan_context_t, char *));
int assuan_register_post_cmd_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, int));
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);
int assuan_process_done (assuan_context_t ctx, int rc);
int assuan_get_active_fds (assuan_context_t ctx, int what,
assuan_fd_t *fdarray, int fdarraysize);
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). Under W32 the returned FD is
a libc-type one. */
assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
assuan_fd_t *rfd);
/*-- assuan-listen.c --*/
assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
assuan_error_t assuan_accept (assuan_context_t ctx);
assuan_fd_t assuan_get_input_fd (assuan_context_t ctx);
assuan_fd_t 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);
/*-- assuan-pipe-server.c --*/
int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]);
void assuan_deinit_server (assuan_context_t ctx);
/*-- assuan-socket-server.c --*/
int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd);
int assuan_init_connected_socket_server (assuan_context_t *r_ctx,
assuan_fd_t fd) _ASSUAN_DEPRECATED;
int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd,
unsigned int flags);
void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
/*-- assuan-pipe-connect.c --*/
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_DEPRECATED;
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-socket-connect.c --*/
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);
/*-- assuan-connect.c --*/
void assuan_disconnect (assuan_context_t ctx);
pid_t assuan_get_pid (assuan_context_t ctx);
#ifndef _WIN32
assuan_error_t assuan_get_peercred (assuan_context_t ctx,
pid_t *pid, uid_t *uid, gid_t *gid);
#endif
/*-- assuan-client.c --*/
assuan_error_t
assuan_transact (assuan_context_t ctx,
const char *command,
- int (*data_cb)(void *, const void *, size_t),
+ assuan_error_t (*data_cb)(void *, const void *, size_t),
void *data_cb_arg,
- int (*inquire_cb)(void*, const char *),
+ assuan_error_t (*inquire_cb)(void*, const char *),
void *inquire_cb_arg,
- int (*status_cb)(void*, const char *),
+ assuan_error_t (*status_cb)(void*, const char *),
void *status_cb_arg);
/*-- assuan-inquire.c --*/
assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
unsigned char **r_buffer, size_t *r_length,
size_t maxlen);
assuan_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
size_t maxlen,
int (*cb) (void *cb_data, int rc,
unsigned char *buf,
size_t buf_len),
void *cb_data);
/*-- assuan-buffer.c --*/
assuan_error_t assuan_read_line (assuan_context_t ctx,
char **line, size_t *linelen);
int assuan_pending_line (assuan_context_t ctx);
assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line );
assuan_error_t assuan_send_data (assuan_context_t ctx,
const void *buffer, size_t length);
/* 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")). */
assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd);
assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd);
/*-- assuan-util.c --*/
void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
void *(*new_realloc_func)(void *p, size_t n),
void (*new_free_func)(void*) );
void assuan_set_io_hooks (assuan_io_hooks_t io_hooks);
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);
void assuan_set_io_monitor (assuan_context_t ctx,
unsigned int (*monitor)(assuan_context_t ctx,
int direction,
const char *line,
size_t linelen));
/* 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);
/* Return the VALUE of FLAG in context CTX. */
int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
/*-- assuan-errors.c --*/
#ifndef _ASSUAN_ONLY_GPG_ERRORS
/* Return a string describing the assuan error. The use of this
function is deprecated; it is better to call
assuan_set_assuan_err_source once and then make use libgpg-error. */
const char *assuan_strerror (assuan_error_t err);
#endif /*_ASSUAN_ONLY_GPG_ERRORS*/
/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error
sources. Note, that this function is not thread-safe and should be
used right at startup. Switching back to the old style mode is not
supported. */
void assuan_set_assuan_err_source (int errsource);
/*-- assuan-logging.c --*/
/* Set the stream to which assuan should log message not associated
with a context. By default, this is stderr. The default value
will be changed when the first log stream is associated with a
context. Note, that this function is not thread-safe and should
in general be used right at startup. */
extern void assuan_set_assuan_log_stream (FILE *fp);
/* Return the stream which is currently being using for global logging. */
extern FILE *assuan_get_assuan_log_stream (void);
/* Set the prefix to be used at the start of a line emitted by assuan
on the log stream. The default is the empty string. Note, that
this function is not thread-safe and should in general be used
right at startup. */
void assuan_set_assuan_log_prefix (const char *text);
/* 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);
/*-- assuan-socket.c --*/
/* These are socket wrapper functions to support an emulation of Unix
domain sockets on Windows W32. */
int assuan_sock_close (assuan_fd_t fd);
assuan_fd_t assuan_sock_new (int domain, int type, int proto);
int assuan_sock_connect (assuan_fd_t sockfd,
struct sockaddr *addr, int addrlen);
int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen);
int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen,
assuan_sock_nonce_t *nonce);
int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce);
#ifdef __cplusplus
}
#endif
#endif /* ASSUAN_H */
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, May 10, 8:59 AM (13 h, 44 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
63/a0/54313314766f7d11b5c4888a2489
Attached To
rA Assuan
Event Timeline
Log In to Comment