[svn] assuan - r321 - in trunk: doc src

svn author marcus cvs at cvs.gnupg.org
Tue Nov 24 18:46:57 CET 2009


Author: marcus
Date: 2009-11-24 18:46:57 +0100 (Tue, 24 Nov 2009)
New Revision: 321

Modified:
   trunk/doc/ChangeLog
   trunk/doc/assuan.texi
   trunk/src/ChangeLog
   trunk/src/assuan-pipe-server.c
   trunk/src/assuan-socket.c
   trunk/src/assuan.h
Log:
doc/
2009-11-24  Marcus Brinkmann  <marcus at g10code.de>

	* assuan.texi: Remove assuan_disconnect, assuan_deinit_server.
	Many smaller API fixes.

src/
2009-11-24  Marcus Brinkmann  <marcus at g10code.de>

	* assuan.h (struct _assuan_peercred) [_WIN32]: Define dummy member
	so struct is not empty.
	* assuan-socket.c (assuan_sock_deinit): Set sock_ctx to NULL.


Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/doc/ChangeLog	2009-11-24 17:46:57 UTC (rev 321)
@@ -1,3 +1,8 @@
+2009-11-24  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan.texi: Remove assuan_disconnect, assuan_deinit_server.
+	Many smaller API fixes.
+
 2009-11-10  Marcus Brinkmann  <marcus at g10code.de>
 
 	* assuan.texi: Various fixes and updates for the new interface.

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/src/ChangeLog	2009-11-24 17:46:57 UTC (rev 321)
@@ -1,3 +1,9 @@
+2009-11-24  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan.h (struct _assuan_peercred) [_WIN32]: Define dummy member
+	so struct is not empty.
+	* assuan-socket.c (assuan_sock_deinit): Set sock_ctx to NULL.
+
 2009-11-19  Marcus Brinkmann  <marcus at g10code.de>
 
 	* Makefile.am (common_sources): Remove assuan-connect.c and add

Modified: trunk/doc/assuan.texi
===================================================================
--- trunk/doc/assuan.texi	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/doc/assuan.texi	2009-11-24 17:46:57 UTC (rev 321)
@@ -594,9 +594,6 @@
 This is a pointer to a @code{struct assuan_malloc_hooks}.
 @end deftp
 
-/* Get the default malloc hooks.  */
-assuan_malloc_hooks_t assuan_get_malloc_hooks (void);
-
 @deftypefun void assuan_set_malloc_hooks (@w{assuan_malloc_hooks_t @var{malloc_hooks}})
 This function sets the default allocation hooks for new contexts
 allocated with @code{assuan_new}.  You need to provide all three
@@ -808,7 +805,7 @@
 @table @code
 @item ASSUAN_NO_WAITPID 
 When using a pipe server, by default Libassuan will wait for the forked
-process to die in @code{assuan_disconnect}.  In certain cases this is
+process to die in @code{assuan_release}.  In certain cases this is
 not desirable.  By setting this flag, a call to @code{waitpid} will be
 suppressed and the caller is responsible to cleanup the child process.
 @item ASSUAN_CONFIDENTIAL
@@ -937,6 +934,10 @@
 @table @code
 @item ASSUAN_SYSTEM_PTH
 System hooks suitable for use with the GNU Pth library.
+ at item ASSUAN_SYSTEM_PTH_IMPL
+The implementation of system hooks for use with the GNU Pth library.
+This must be invoked once somewhere in the application, and defines
+the structure that is referenced by @code{ASSUAN_SYSTEM_PTH}.
 @end table
 
 
@@ -1058,17 +1059,16 @@
 
 @table @code
 @item ASSUAN_PIPE_CONNECT_FDPASSING
-If cleared a simple pipe based server is expected and the function
-behaves similar to @code{assuan_pipe_connect}.  
-
-If set a server based on full-duplex pipes is expected. Such pipes are
-usually created using the @code{socketpair} function.  It also enables
+If cleared a simple pipe based server is expected.  If set a server
+based on full-duplex pipes is expected.  Such pipes are usually
+created using the @code{socketpair} function.  It also enables
 features only available with such servers.
 
 @item ASSUAN_PIPE_CONNECT_DETACHED
 If set and there is a need to start the server it will be started as a
 background process.  This flag is useful under W32 systems, so that no
-new console is created and pops up a console window when starting the server
+new console is created and pops up a console window when starting the
+server.
 @end table
 @end deftypefun
 
@@ -1081,26 +1081,15 @@
 Make a connection to the Unix domain socket @var{name} and return a
 new Assuan context at @var{ctx}.  @var{server_pid} is currently not
 used but may become handy in the future; if you don't know the
-server's process ID (PID), pass @code{-1}.  With @var{flags} set to
- at code{ASSUAN_SOCKET_CONNECT_FDPASSIN}, @code{sendmsg} and
- at code{recvmesg} are used for input and output and thereby enable the
-use of descriptor passing.
+server's process ID (PID), pass @code{ASSUAN_INVALID_PID}.  With
+ at var{flags} set to @code{ASSUAN_SOCKET_CONNECT_FDPASSIN},
+ at code{sendmsg} and @code{recvmesg} are used for input and output and
+thereby enable the use of descriptor passing.
 
 Connecting to a TCP server is not yet implemented.  Standard URL
 schemes are reserved for @var{name} specifying a TCP server.
 @end deftypefun
 
-Eventually, after using the Assuan connection, the resources should be
-deallocated:
-
- at deftypefun void assuan_disconnect (@w{assuan_context_t @var{ctx}})
-
-Close the connection described by the Assuan context @var{ctx} and
-release all resources.  This function also tries to send the BYE command
-to the server but won't fail on error.  It is explicitly allowed to pass
- at code{NULL} for @var{ctx}, in which case the function does nothing.
- at end deftypefun
-
 Now that we have a connection to the server, all work may be
 conveniently done using a couple of callbacks and the transact
 function:
@@ -1247,7 +1236,7 @@
 If a file descriptor has been passed, the assuan context gets
 initialized by the function:
 
- at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}})
+ at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{assuan_fd_t @var{fd}}, @w{unsigned int @var{flags}})
 
 The function takes the file descriptor @var{fd} which is expected to be
 associated with a socket and returns a new Assuan context at
@@ -1292,11 +1281,11 @@
     @{
       rc = assuan_register_command (ctx,
                                     command_table[i].name,
-                                    command_table[i].handler);
+                                    command_table[i].handler, NULL);
       if (rc)
         @{
           fprintf (stderr, "register failed: %s\n", gpg_strerror (rc));
-          assuan_deinit_server (ctx);
+          assuan_release (ctx);
           return;
         @}
     @} 
@@ -1419,7 +1408,7 @@
           continue;
         @}
     @}
-  assuan_deinit_server (ctx);
+  assuan_release (ctx);
 @}
 @end example
 
@@ -1449,18 +1438,7 @@
 individual command handlers, i.e. operational error, are not seen here.
 @end deftypefun
 
-
 @noindent
-After the loop has terminated, the Assuan context needs to be released:
-
- at deftypefun void assuan_deinit_server (@w{assuan_context_t @var{ctx}})
-
-Releases the resources described by the Assuan context @var{ctx} It is
-explicitly allowed to pass @code{NULL} for @var{ctx}, in which case the
-function does nothing.
- at end deftypefun
-
- at noindent
 That is all needed for the server code.  You only need to come up with
 the code for the individual command handlers.  Take care that the line
 passed to the command handlers is allocated statically within the
@@ -1558,8 +1536,7 @@
 You should close and unregister the bulk data FDs when you wrote all
 data (for outbound FDs) or receive an EOF (for inbound FDs).  When you
 receive an ERR from the server, or an OK for the final operation, you
-can unregister the inbound status FD and call @code{assuan_disconnect}
-to close it.
+can unregister the inbound status FD and call @code{assuan_release}.
 
 @item
 As noted above, all send operations on the outbound status FD are done
@@ -1733,7 +1710,7 @@
 @end deftypefun
 
 
- at deftypefun gpg_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{int *@var{rfd}})
+ at deftypefun gpg_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{assuan_fd_t *@var{rfd}})
 
 This is the core of the default @code{INPUT} and @code{OUTPUT}
 handler.  It may be used in custom commands as well to negotiate a
@@ -1888,23 +1865,29 @@
 and fully transparent for the client.  Server code needs to utilize two
 extra functions to check the permissions.
 
+ at deftypefun gpg_error_t assuan_sock_init (void)
+Initialize the socket wrappers.  Must be called once at startup if any
+of the socket wrapper functions are used.
+ at end deftypefun
 
- at deftypefun int assuan_sock_close (@w{assuan_fd_t @var{fd}})
+ at deftypefun gpg_error_t assuan_sock_init (void)
+Deinitialize the socket wrappers.
+ at end deftypefun
 
+ at deftypefun int assuan_sock_close (@w{assuan_fd_t @var{fd}})
 Wrapper for close which does a closesocket on Windows if needed.
 @end deftypefun
 
 @deftypefun assuan_fd_t assuan_sock_new (@w{int @var{domain}}, @w{int @var{type}}, @w{int @var{proto}});
-
 Wrapper around socket.
 @end deftypefun
 
 @deftypefun int assuan_sock_connect (@w{assuan_fd_t @var{sockfd}}, @
-         @w{struct sockaddr *@var{addr}},  @
+         @w{struct sockaddr *@var{addr}}, @
          @w{int @var{addrlen}})
 
 Wrapper around connect.  For Unix domain sockets under Windows this
-function also does a write immediatley after the the connect to send the
+function also does a write immediately after the the connect to send the
 nonce as read from the socket's file.
 @end deftypefun
 

Modified: trunk/src/assuan-pipe-server.c
===================================================================
--- trunk/src/assuan-pipe-server.c	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/src/assuan-pipe-server.c	2009-11-24 17:46:57 UTC (rev 321)
@@ -48,6 +48,8 @@
 #endif /*!HAVE_W32_SYSTEM*/
 
 
+/* This actually is a int file descriptor (and not assuan_fd_t) as
+   _get_osfhandle is called on W32 systems.  */
 gpg_error_t
 assuan_init_pipe_server (assuan_context_t ctx, int filedes[2])
 {

Modified: trunk/src/assuan-socket.c
===================================================================
--- trunk/src/assuan-socket.c	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/src/assuan-socket.c	2009-11-24 17:46:57 UTC (rev 321)
@@ -426,6 +426,7 @@
 #endif
 
   assuan_release (sock_ctx);
+  sock_ctx = NULL;
 }
   
 

Modified: trunk/src/assuan.h
===================================================================
--- trunk/src/assuan.h	2009-11-19 23:57:35 UTC (rev 320)
+++ trunk/src/assuan.h	2009-11-24 17:46:57 UTC (rev 321)
@@ -337,7 +337,7 @@
 FILE *assuan_get_data_fp (assuan_context_t ctx);
 gpg_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
 gpg_error_t assuan_write_status (assuan_context_t ctx,
-                                    const char *keyword, const char *text);
+				 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
@@ -388,7 +388,10 @@
 pid_t assuan_get_pid (assuan_context_t ctx);
 struct _assuan_peercred
 {
-#ifndef _WIN32
+#ifdef _WIN32
+  /* Empty struct not allowed on some compilers.  */
+  unsigned int _dummy;
+#else
   pid_t pid;
   uid_t uid;
   gid_t gid;
@@ -416,17 +419,17 @@
                                unsigned char **r_buffer, size_t *r_length,
                                size_t maxlen);
 gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword,
-				   size_t maxlen,
-				   gpg_error_t (*cb) (void *cb_data,
-						      gpg_error_t rc,
-						      unsigned char *buf,
-						      size_t buf_len),
-				   void *cb_data);
+				size_t maxlen,
+				gpg_error_t (*cb) (void *cb_data,
+						   gpg_error_t rc,
+						   unsigned char *buf,
+						   size_t buf_len),
+				void *cb_data);
 /*-- assuan-buffer.c --*/
 gpg_error_t assuan_read_line (assuan_context_t ctx,
                               char **line, size_t *linelen);
 int assuan_pending_line (assuan_context_t ctx);
-gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line );
+gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line);
 gpg_error_t assuan_send_data (assuan_context_t ctx,
                               const void *buffer, size_t length);
 
@@ -438,7 +441,8 @@
 
 
 /*-- assuan-util.c --*/
-gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text);
+gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err,
+			      const char *text);
 
 
 




More information about the Gnupg-commits mailing list