Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F36623028
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
101 KB
Subscribers
None
View Options
diff --git a/NEWS b/NEWS
index 615039e..039149f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,201 +1,203 @@
Noteworthy changes in version 1.0.4
------------------------------------------------
- * New socket wrapper fucntions to support Unix domain sockets under
+ * New socket wrapper functions to support Unix domain sockets under
Windows.
+ * New hook feature to enhance the internal I/O functions.
+
Noteworthy changes in version 1.0.3 (2007-08-24)
------------------------------------------------
* New type assuan_fd_t and constant ASSUAN_INVALID_FD for better W32
support. It does not change the semantics under Unix. Under W32
all file descriptors are now guaranteed to be system handles.
* New functions assuan_process_done and assuan_inquire_ext to support
external event loops.
* Changed the license of the library code back to LGPLv2.1 to support
a bunch of GPLv2(only) software which does not allow the use of
LGPLv3. Note that this is only a temporary change and authors of
GPLv2(only) software are asked to switch to GPLv3 or to add an
exception which allow the use of LPGLv3 software.
Noteworthy changes in version 1.0.2 (2007-07-05)
------------------------------------------------
* Changed license to LGPLv3.
* New flag ASSUAN_CONFIDENTIAL to return the state of
confidential logging.
* Better support for W32.
* Assorted bug fixed and code cleanups.
Noteworthy changes in version 1.0.1 (2006-11-22)
------------------------------------------------
* New function: assuan_set_io_monitor.
* New function: assuan_register_post_cmd_notify.
* Fixed a memory leak.
Noteworthy changes in version 1.0.0 (2006-10-31)
------------------------------------------------
* Finished the manual.
Noteworthy changes in version 0.9.3 (2006-10-10)
------------------------------------------------
* Portability fixes.
* Pth is not anymore linked by means of weak symbol tricks. It is
now required to link to the pth version of libassuan. New autoconf
macros are provided to to check for this. The pth version is only
build if Pth is available.
* configure does now check that descripotor passing is available. A
way to check at runtime for this is also provided
Noteworthy changes in version 0.9.2 (2006-10-04)
------------------------------------------------
* A fix to make CANCEL work again in Pinentries.
Noteworthy changes in version 0.9.1 (2006-10-04)
------------------------------------------------
* Minor bug fixes
* Portability fixes.
Noteworthy changes in version 0.9.0 (2006-09-14)
------------------------------------------------
* Internal cleanups to make inclusion of the code into libraries
easier.
* Made clear that the software is under the LGPL.
* New function assuan_set_assuan_err_source. All gpg-error enabled
software should call this right at startup to switch libassuan into
the gpg-error style mode. All error codes are then returned as
gpg-error style codes (GPG_ERR_ASS_* as well as others).
If the new macro _ASSUAN_ONLY_GPG_ERRORS is defned all old
definitions are excluded from assuan.h.
* Logging of hex strings is now limited to 16 bytes. To enable
printing of the full data, a new environment variable
ASSUAN_FULL_LOGGING may be set to any value.
* Removed the assuan_domain_* functions.
* New functions assuan_pipe_connect_ext and assuan_socket_connect_ext
to allow connections on a socketpair and to pass descriptors.
* New function assuan_get_peercred.
Noteworthy changes in version 0.6.10 (2005-06-20)
-------------------------------------------------
* New functions assuan_get_flag and assuan_set_flag.
* Add flag ASSUAN_NO_WAITPID.
Noteworthy changes in version 0.6.9 (2004-12-22)
------------------------------------------------
* Ported to W32 based systems.
Noteworthy changes in version 0.6.8 (2004-11-25)
------------------------------------------------
* assuan_write_status does now return an error code.
* Fixes for C89 compatibility and some first takes on a W32 port.
Noteworthy changes in version 0.6.7 (2004-09-27)
------------------------------------------------
* Minor build fixes.
Noteworthy changes in version 0.6.6 (2004-06-08)
------------------------------------------------
* assuan_set_hello_line may now take a multi line argument where the
first lines are send as comment lines and the last one as a OK
line.
Noteworthy changes in version 0.6.5 (2004-04-29)
------------------------------------------------
* Pass the client's pid to a pipe server.
Noteworthy changes in version 0.6.4 (2004-02-20)
------------------------------------------------
* Will now also build on systems not providing funopen or
fopencookie.
* Some smaller build fixes.
Noteworthy changes in version 0.6.3 (2004-01-29)
------------------------------------------------
* Fixed a data corruption bug in assuan_get_data_fp.
* New function assuan_pipe_connect2.
Noteworthy changes in version 0.6.2 (2003-12-18)
------------------------------------------------
* New function assuan_set_assuan_log_prefix to store a log prefix to
be used when no context is available. The existing function
assuan_get_assuan_log_context is not anymore declared as user
overridable.
* Documentation cleanups.
Noteworthy changes in version 0.6.1 (2003-11-17)
------------------------------------------------
* Fixed a bug in assuan_inquire which led to an Invalid_Value error
for large inquiry parameters.
* Fixed a bug in the client socket connect code.
Noteworthy changes in version 0.6.0 (2003-08-06)
------------------------------------------------
* Initial release as a standalone library.
Copyright 2003, 2004, 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/ChangeLog b/src/ChangeLog
index d3202c4..fa9bd23 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,1230 +1,1243 @@
+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-defs.h b/src/assuan-defs.h
index f17e906..b299435 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -1,354 +1,358 @@
/* assuan-defs.c - Internal definitions to Assuan
* Copyright (C) 2001, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
* Assuan is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* Assuan is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef ASSUAN_DEFS_H
#define ASSUAN_DEFS_H
#include <sys/types.h>
#ifndef HAVE_W32_SYSTEM
#include <sys/socket.h>
#include <sys/un.h>
#else
#include <windows.h>
#endif
#include <unistd.h>
#include "assuan.h"
#ifndef HAVE_W32_SYSTEM
#define DIRSEP_C '/'
#else
#define DIRSEP_C '\\'
#endif
#ifdef HAVE_W32_SYSTEM
/* Not needed anymore because the current mingw32 defines this in
sys/types.h */
/* typedef int ssize_t; */
/* Missing W32 functions */
int putc_unlocked (int c, FILE *stream);
void * memrchr (const void *block, int c, size_t size);
char * stpcpy (char *dest, const char *src);
#endif
#define LINELENGTH ASSUAN_LINELENGTH
struct cmdtbl_s
{
const char *name;
int (*handler)(assuan_context_t, char *line);
};
/* A structure to dispatch I/O functions. All these functions need to
return 0 on success and set ERRNO on failure. */
struct assuan_io
{
/* Routine to read from input_fd. */
ssize_t (*readfnc) (assuan_context_t, void *, size_t);
/* Routine to write to output_fd. */
ssize_t (*writefnc) (assuan_context_t, const void *, size_t);
/* Send a file descriptor. */
assuan_error_t (*sendfd) (assuan_context_t, assuan_fd_t);
/* Receive a file descriptor. */
assuan_error_t (*receivefd) (assuan_context_t, assuan_fd_t *);
};
+/* The global variable with the optional hook fucntions. */
+extern struct assuan_io_hooks _assuan_io_hooks;
+
+
/* The context we use with most functions. */
struct assuan_context_s
{
assuan_error_t err_no;
const char *err_str;
int os_errno; /* Last system error number used with certain
error codes. */
/* Context specific flags (cf. assuan_flag_t). */
struct
{
unsigned int no_waitpid:1; /* See ASSUAN_NO_WAITPID. */
} flags;
int confidential;
int is_server; /* Set if this is context belongs to a server */
int in_inquire;
int in_process_next;
int in_command;
/* The following members are used by assuan_inquire_ext. */
int (*inquire_cb) (void *cb_data, int rc, unsigned char *buf, size_t len);
void *inquire_cb_data;
void *inquire_membuf;
char *hello_line;
char *okay_line; /* See assuan_set_okay_line() */
void *user_pointer; /* For assuan_get_pointer and assuan_set_pointer (). */
FILE *log_fp;
struct {
assuan_fd_t fd;
int eof;
char line[LINELENGTH];
int linelen; /* w/o CR, LF - might not be the same as
strlen(line) due to embedded nuls. However a nul
is always written at this pos. */
struct {
char line[LINELENGTH];
int linelen ;
int pending; /* i.e. at least one line is available in the attic */
} attic;
} inbound;
struct {
assuan_fd_t fd;
struct {
FILE *fp;
char line[LINELENGTH];
int linelen;
int error;
} data;
} outbound;
int pipe_mode; /* We are in pipe mode, i.e. we can handle just one
connection and must terminate then. */
pid_t pid; /* The pid of the peer. */
assuan_fd_t listen_fd; /* The fd we are listening on (used by
socket servers) */
assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */
assuan_fd_t connected_fd; /* helper */
struct {
int valid; /* Whether this structure has valid information. */
#ifdef HAVE_SO_PEERCRED
pid_t pid; /* The pid of the peer. */
uid_t uid; /* The uid of the peer. */
gid_t gid; /* The gid of the peer. */
#endif /* HAVE_SO_PEERCRED */
} peercred;
/* Used for Unix domain sockets. */
struct sockaddr_un myaddr;
struct sockaddr_un serveraddr;
/* Structure used for unix domain socket buffering. FIXME: We don't
use datagrams anymore thus we could get away with a simpler
buffering approach. */
struct {
void *buffer; /* Malloced buffer. */
int bufferallocated; /* Memory allocated. */
int bufferoffset; /* Offset of start of buffer. */
int buffersize; /* Bytes buffered. */
assuan_fd_t pendingfds[5]; /* Array to save received descriptors. */
int pendingfdscount; /* Number of received descriptors. */
} uds;
void (*deinit_handler)(assuan_context_t);
int (*accept_handler)(assuan_context_t);
int (*finish_handler)(assuan_context_t);
struct cmdtbl_s *cmdtbl;
size_t cmdtbl_used; /* used entries */
size_t cmdtbl_size; /* allocated size of table */
void (*bye_notify_fnc)(assuan_context_t);
void (*reset_notify_fnc)(assuan_context_t);
void (*cancel_notify_fnc)(assuan_context_t);
int (*option_handler_fnc)(assuan_context_t,const char*, const char*);
void (*input_notify_fnc)(assuan_context_t, const char *);
void (*output_notify_fnc)(assuan_context_t, const char *);
/* This function is called right after a command has been processed.
It may be used to command related cleanup. */
void (*post_cmd_notify_fnc)(assuan_context_t, int);
/* If set, this is called right before logging an I/O line. With
DIRECTION set to 1 it is called for an output oeration; 0 means
an input operation. If bit 0 is set in the return value, the
logging of the line will be suppressed. With bit 1 set, the
entire line will be ignored. */
unsigned int (*io_monitor)(assuan_context_t ctx,
int direction,
const char *line,
size_t linelen);
assuan_fd_t input_fd; /* Set by the INPUT command. */
assuan_fd_t output_fd; /* Set by the OUTPUT command. */
/* io routines. */
struct assuan_io *io;
};
/*-- assuan-pipe-server.c --*/
int _assuan_new_context (assuan_context_t *r_ctx);
void _assuan_release_context (assuan_context_t ctx);
/*-- assuan-uds.c --*/
void _assuan_uds_close_fds (assuan_context_t ctx);
void _assuan_uds_deinit (assuan_context_t ctx);
void _assuan_init_uds_io (assuan_context_t ctx);
/*-- assuan-handler.c --*/
int _assuan_register_std_commands (assuan_context_t ctx);
/*-- assuan-buffer.c --*/
assuan_error_t _assuan_read_line (assuan_context_t ctx);
int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size);
int _assuan_cookie_write_flush (void *cookie);
assuan_error_t _assuan_write_line (assuan_context_t ctx, const char *prefix,
const char *line, size_t len);
/*-- assuan-client.c --*/
assuan_error_t _assuan_read_from_server (assuan_context_t ctx,
int *okay, int *off);
/*-- assuan-error.c --*/
/*-- assuan-inquire.c --*/
int _assuan_inquire_ext_cb (assuan_context_t ctx);
void _assuan_inquire_release (assuan_context_t ctx);
/* Map error codes as used in this implementation to the libgpg-error
codes. */
assuan_error_t _assuan_error (int oldcode);
/* Check if ERR means EAGAIN. */
int _assuan_error_is_eagain (assuan_error_t err);
/* Extract the error code from A. This works for both the old and the
new style error codes. This needs to be used whenever an error
code is compared. */
#define err_code(a) ((a) & 0x00ffffff)
/* Check whether A is the erro code for EOF. We allow for old and new
style EOF error codes here. */
#define err_is_eof(a) ((a) == (-1) || err_code (a) == 16383)
/*-- assuan-util.c --*/
void *_assuan_malloc (size_t n);
void *_assuan_calloc (size_t n, size_t m);
void *_assuan_realloc (void *p, size_t n);
void _assuan_free (void *p);
#define xtrymalloc(a) _assuan_malloc ((a))
#define xtrycalloc(a,b) _assuan_calloc ((a),(b))
#define xtryrealloc(a,b) _assuan_realloc((a),(b))
#define xfree(a) _assuan_free ((a))
#define set_error(c,e,t) \
assuan_set_error ((c), _assuan_error (ASSUAN_ ## e), (t))
#ifdef HAVE_W32_SYSTEM
const char *_assuan_w32_strerror (int ec);
#define w32_strerror(e) _assuan_w32_strerror ((e))
int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen);
const char *_assuan_gpg_strsource (unsigned int err);
#endif /*HAVE_W32_SYSTEM*/
/*-- assuan-logging.c --*/
void _assuan_set_default_log_stream (FILE *fp);
void _assuan_log_printf (const char *format, ...)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
__attribute__ ((format (printf,1,2)))
#endif
;
void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length);
void _assuan_log_sanitized_string (const char *string);
/*-- assuan-io.c --*/
pid_t _assuan_waitpid (pid_t pid, int *status, int options);
ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size);
ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer,
size_t size);
ssize_t _assuan_io_read (assuan_fd_t fd, void *buffer, size_t size);
ssize_t _assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size);
#ifdef HAVE_W32_SYSTEM
int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg);
int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg);
#else
ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg);
ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg);
#endif
/*-- assuan-socket.c --*/
int _assuan_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 HAVE_W32_SYSTEM
int _assuan_sock_wsa2errno (int err);
#endif
#ifdef HAVE_FOPENCOOKIE
/* We have to implement funopen in terms of glibc's fopencookie. */
FILE *_assuan_funopen(void *cookie,
cookie_read_function_t *readfn,
cookie_write_function_t *writefn,
cookie_seek_function_t *seekfn,
cookie_close_function_t *closefn);
#define funopen(a,r,w,s,c) _assuan_funopen ((a), (r), (w), (s), (c))
#endif /*HAVE_FOPENCOOKIE*/
/* Prototypes for replacement functions. */
#ifndef HAVE_MEMRCHR
void *memrchr (const void *block, int c, size_t size);
#endif
#ifndef HAVE_STPCPY
char *stpcpy (char *dest, const char *src);
#endif
#ifndef HAVE_SETENV
#define setenv _assuan_setenv
#define unsetenv _assuan_unsetenv
#define clearenv _assuan_clearenv
int setenv (const char *name, const char *value, int replace);
#endif
#ifndef HAVE_PUTC_UNLOCKED
int putc_unlocked (int c, FILE *stream);
#endif
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
#define DIMof(type,member) DIM(((type *)0)->member)
#if HAVE_W32_SYSTEM
#define SOCKET2HANDLE(s) ((void *)(s))
#define HANDLE2SOCKET(h) ((unsigned int)(h))
#else
#define SOCKET2HANDLE(s) (s)
#define HANDLE2SOCKET(h) (h)
#endif
#endif /*ASSUAN_DEFS_H*/
diff --git a/src/assuan-io-pth.c b/src/assuan-io-pth.c
index 6b287c0..5b60cc7 100644
--- a/src/assuan-io-pth.c
+++ b/src/assuan-io-pth.c
@@ -1,161 +1,184 @@
/* assuan-io-pth.c - Pth version of assua-io.c.
- * Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2004, 2006, 2007 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/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_W32_SYSTEM
# include <windows.h>
#else
# include <sys/wait.h>
#endif
#include <pth.h>
#include "assuan-defs.h"
#ifndef HAVE_W32_SYSTEM
pid_t
_assuan_waitpid (pid_t pid, int *status, int options)
{
return pth_waitpid (pid, status, options);
}
#endif
ssize_t
_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
{
/* Fixme: For W32 we should better not cast the HANDLE type to int.
However, this requires changes in w32pth too. */
+ ssize_t retval;
+
+ if (_assuan_io_hooks.read_hook
+ && _assuan_io_hooks.read_hook (ctx, ctx->inbound.fd,
+ buffer, size, &retval) == 1)
+ return retval;
+
return _assuan_io_read (ctx->inbound.fd, buffer, size);
}
ssize_t
_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
{
+ ssize_t retval;
+
+ if (_assuan_io_hooks.write_hook
+ && _assuan_io_hooks.write_hook (ctx, ctx->outbound.fd,
+ buffer, size, &retval) == 1)
+ return retval;
return _assuan_io_write (ctx->outbound.fd, buffer, size);
}
ssize_t
_assuan_io_read (assuan_fd_t fd, void *buffer, size_t size)
{
+ ssize_t retval;
+
+ if (_assuan_io_hooks.read_hook
+ && _assuan_io_hooks.read_hook (NULL, fd, buffer, size, &retval) == 1)
+ return retval;
return pth_read ((int)fd, buffer, size);
}
ssize_t
_assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size)
{
+ ssize_t retval;
+
+ if (_assuan_io_hooks.write_hook
+ && _assuan_io_hooks.write_hook (NULL, fd, buffer, size, &retval) == 1)
+ return retval;
return pth_write ((int)fd, buffer, size);
}
#ifdef HAVE_W32_SYSTEM
int
_assuan_simple_sendmsg (assuan_context_t ctx, void *msg)
#else
ssize_t
_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
#endif
{
#if defined(HAVE_W32_SYSTEM)
return _assuan_error (ASSUAN_Not_Implemented);
#else
/* Pth does not provide a sendmsg function. Thus we implement it here. */
int ret;
int fd = ctx->outbound.fd;
int fdmode;
fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
if (fdmode == PTH_FDMODE_ERROR)
{
errno = EBADF;
return -1;
}
if (fdmode == PTH_FDMODE_BLOCK)
{
fd_set fds;
FD_ZERO (&fds);
FD_SET (fd, &fds);
while ( (ret = pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
&& errno == EINTR)
;
if (ret < 0)
return -1;
}
while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
#ifdef HAVE_W32_SYSTEM
int
_assuan_simple_recvmsg (assuan_context_t ctx, void *msg)
#else
ssize_t
_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
#endif
{
#if defined(HAVE_W32_SYSTEM)
return _assuan_error (ASSUAN_Not_Implemented);
#else
/* Pth does not provide a recvmsg function. Thus we implement it here. */
int ret;
int fd = ctx->inbound.fd;
int fdmode;
fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
if (fdmode == PTH_FDMODE_ERROR)
{
errno = EBADF;
return -1;
}
if (fdmode == PTH_FDMODE_BLOCK)
{
fd_set fds;
FD_ZERO (&fds);
FD_SET (fd, &fds);
while ( (ret = pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
&& errno == EINTR)
;
if (ret < 0)
return -1;
}
while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
diff --git a/src/assuan-io.c b/src/assuan-io.c
index eb50f7a..1ff4ecb 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -1,178 +1,215 @@
/* assuan-io.c - Wraps the read and write functions.
- * Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2004, 2006, 2007 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/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_W32_SYSTEM
# include <windows.h>
#else
# include <sys/wait.h>
#endif
#include "assuan-defs.h"
#ifndef HAVE_W32_SYSTEM
pid_t
_assuan_waitpid (pid_t pid, int *status, int options)
{
return waitpid (pid, status, options);
}
#endif
-ssize_t
-_assuan_io_read (assuan_fd_t fd, void *buffer, size_t size)
+static ssize_t
+do_io_read (assuan_fd_t fd, void *buffer, size_t size)
{
#ifdef HAVE_W32_SYSTEM
/* Due to the peculiarities of the W32 API we can't use read for a
network socket and thus we try to use recv first and fallback to
read if recv detects that it is not a network socket. */
int n;
n = recv (HANDLE2SOCKET(fd), buffer, size, 0);
if (n == -1)
{
switch (WSAGetLastError ())
{
case WSAENOTSOCK:
{
DWORD nread = 0;
n = ReadFile (fd, buffer, size, &nread, NULL);
if (!n)
{
switch (GetLastError())
{
case ERROR_BROKEN_PIPE: errno = EPIPE; break;
default: errno = EIO;
}
n = -1;
}
else
n = (int)nread;
}
break;
case WSAEWOULDBLOCK: errno = EAGAIN; break;
case ERROR_BROKEN_PIPE: errno = EPIPE; break;
default: errno = EIO; break;
}
}
return n;
#else /*!HAVE_W32_SYSTEM*/
return read (fd, buffer, size);
#endif /*!HAVE_W32_SYSTEM*/
}
+ssize_t
+_assuan_io_read (assuan_fd_t fd, void *buffer, size_t size)
+{
+ ssize_t retval;
+
+ if (_assuan_io_hooks.read_hook
+ && _assuan_io_hooks.read_hook (NULL, fd, buffer, size, &retval) == 1)
+ return retval;
+
+ return do_io_read (fd, buffer, size);
+}
+
ssize_t
_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
{
- return _assuan_io_read (ctx->inbound.fd, buffer, size);
+ ssize_t retval;
+
+ if (_assuan_io_hooks.read_hook
+ && _assuan_io_hooks.read_hook (ctx, ctx->inbound.fd,
+ buffer, size, &retval) == 1)
+ return retval;
+
+ return do_io_read (ctx->inbound.fd, buffer, size);
}
-ssize_t
-_assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size)
+
+static ssize_t
+do_io_write (assuan_fd_t fd, const void *buffer, size_t size)
{
#ifdef HAVE_W32_SYSTEM
/* Due to the peculiarities of the W32 API we can't use write for a
network socket and thus we try to use send first and fallback to
write if send detects that it is not a network socket. */
int n;
n = send (HANDLE2SOCKET(fd), buffer, size, 0);
if (n == -1 && WSAGetLastError () == WSAENOTSOCK)
{
DWORD nwrite;
n = WriteFile (fd, buffer, size, &nwrite, NULL);
if (!n)
{
switch (GetLastError ())
{
case ERROR_BROKEN_PIPE:
case ERROR_NO_DATA: errno = EPIPE; break;
default: errno = EIO; break;
}
n = -1;
}
else
n = (int)nwrite;
}
return n;
#else /*!HAVE_W32_SYSTEM*/
return write (fd, buffer, size);
#endif /*!HAVE_W32_SYSTEM*/
}
+ssize_t
+_assuan_io_write (assuan_fd_t fd, const void *buffer, size_t size)
+{
+ ssize_t retval;
+
+ if (_assuan_io_hooks.write_hook
+ && _assuan_io_hooks.write_hook (NULL, fd, buffer, size, &retval) == 1)
+ return retval;
+ return do_io_write (fd, buffer, size);
+}
ssize_t
_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
{
- return _assuan_io_write (ctx->outbound.fd, buffer, size);
+ ssize_t retval;
+
+ if (_assuan_io_hooks.write_hook
+ && _assuan_io_hooks.write_hook (ctx, ctx->outbound.fd,
+ buffer, size, &retval) == 1)
+ return retval;
+
+ return do_io_write (ctx->outbound.fd, buffer, size);
}
#ifdef HAVE_W32_SYSTEM
int
_assuan_simple_sendmsg (assuan_context_t ctx, void *msg)
#else
ssize_t
_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
#endif
{
#ifdef HAVE_W32_SYSTEM
return _assuan_error (ASSUAN_Not_Implemented);
#else
int ret;
while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
#ifdef HAVE_W32_SYSTEM
int
_assuan_simple_recvmsg (assuan_context_t ctx, void *msg)
#else
ssize_t
_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
#endif
{
#ifdef HAVE_W32_SYSTEM
return _assuan_error (ASSUAN_Not_Implemented);
#else
int ret;
while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR)
;
return ret;
#endif
}
diff --git a/src/assuan-util.c b/src/assuan-util.c
index 430b346..cefefcb 100644
--- a/src/assuan-util.c
+++ b/src/assuan-util.c
@@ -1,171 +1,188 @@
/* assuan-util.c - Utility functions for Assuan
* Copyright (C) 2001, 2002, 2003, 2004, 2005 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/>.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "assuan-defs.h"
static void *(*alloc_func)(size_t n) = malloc;
static void *(*realloc_func)(void *p, size_t n) = realloc;
static void (*free_func)(void*) = free;
+struct assuan_io_hooks _assuan_io_hooks;
+
+
+
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*) )
{
alloc_func = new_alloc_func;
realloc_func = new_realloc_func;
free_func = new_free_func;
}
+
+void
+assuan_set_io_hooks (assuan_io_hooks_t io_hooks)
+{
+ _assuan_io_hooks.read_hook = NULL;
+ _assuan_io_hooks.write_hook = NULL;
+ if (io_hooks)
+ {
+ _assuan_io_hooks.read_hook = io_hooks->read_hook;
+ _assuan_io_hooks.write_hook = io_hooks->write_hook;
+ }
+}
+
+
void *
_assuan_malloc (size_t n)
{
return alloc_func (n);
}
void *
_assuan_realloc (void *a, size_t n)
{
return realloc_func (a, n);
}
void *
_assuan_calloc (size_t n, size_t m)
{
void *p;
size_t nbytes;
nbytes = n * m;
if (m && nbytes / m != n)
{
errno = ENOMEM;
return NULL;
}
p = _assuan_malloc (nbytes);
if (p)
memset (p, 0, nbytes);
return p;
}
void
_assuan_free (void *p)
{
if (p)
free_func (p);
}
/* Store the error in the context so that the error sending function
can take out a descriptive text. Inside the assuan code, use the
macro set_error instead of this function. */
int
assuan_set_error (assuan_context_t ctx, int err, const char *text)
{
ctx->err_no = err;
ctx->err_str = text;
return err;
}
void
assuan_set_pointer (assuan_context_t ctx, void *pointer)
{
if (ctx)
ctx->user_pointer = pointer;
}
void *
assuan_get_pointer (assuan_context_t ctx)
{
return ctx? ctx->user_pointer : NULL;
}
void
assuan_begin_confidential (assuan_context_t ctx)
{
if (ctx)
{
ctx->confidential = 1;
}
}
void
assuan_end_confidential (assuan_context_t ctx)
{
if (ctx)
{
ctx->confidential = 0;
}
}
void
assuan_set_io_monitor (assuan_context_t ctx,
unsigned int (*monitor)(assuan_context_t ctx,
int direction,
const char *line,
size_t linelen))
{
if (ctx)
{
ctx->io_monitor = monitor;
}
}
/* 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)
{
if (!ctx)
return;
switch (flag)
{
case ASSUAN_NO_WAITPID: ctx->flags.no_waitpid = value; break;
case ASSUAN_CONFIDENTIAL: ctx->confidential = value; break;
}
}
/* Return the VALUE of FLAG in context CTX. */
int
assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag)
{
if (!ctx)
return 0;
switch (flag)
{
case ASSUAN_NO_WAITPID: return ctx->flags.no_waitpid;
case ASSUAN_CONFIDENTIAL: return ctx->confidential;
}
return 0;
}
-
diff --git a/src/assuan.h b/src/assuan.h
index 6ea41d9..d1a72c6 100644
--- a/src/assuan.h
+++ b/src/assuan.h
@@ -1,642 +1,657 @@
/* assuan.h - Definitions for the Assuan IPC library
* Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
* 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;
#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),
void *data_cb_arg,
int (*inquire_cb)(void*, const char *),
void *inquire_cb_arg,
int (*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
Thu, Feb 26, 6:32 PM (11 h, 59 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fb/de/abbdc43216214980356a6c3ee653
Attached To
rA Assuan
Event Timeline
Log In to Comment