[Pkg-gnupg-commit] [libassuan] 380/437: Update example code for pipe server.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:34:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 7cf99d04d864fb308159fb928057f59eb4e5a110
Author: W. Trevor King <wking at tremily.us>
Date:   Thu Apr 19 20:19:46 2012 -0400

    Update example code for pipe server.
    
    * doc/assuan.texi: Fix server example code to use assuan_new.
---
 doc/assuan.texi | 47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/doc/assuan.texi b/doc/assuan.texi
index 9ea7804..ddac37a 100644
--- a/doc/assuan.texi
+++ b/doc/assuan.texi
@@ -741,6 +741,7 @@ GPGME and an application using GPGME, the context is very extensive
 and covers utilitary information like memory allocation callbacks as
 well as specific information associated with client/server operations.
 
+ at anchor{function assuan_new}
 @deftypefun gpg_error_t assuan_new (@w{assuan_context_t *@var{ctx_p}})
 The function @code{assuan_new} creates a new context, using the global
 default memory allocation, log handler and @code{libgpg-error} source.
@@ -1230,16 +1231,24 @@ command_handler (int fd)
   int i;
   assuan_context_t ctx;
 
+  rc = assuan_new (&ctx);
+  if (rc)
+    @{
+      fprintf (stderr, "server context creation failed: %s\n",
+               gpg_strerror(rc));
+      return;
+    @}
+
   if (fd == -1)
     @{
       assuan_fd_t filedes[2];
 
-      filedes[0] = assuan_fd_from_posix (0);
-      filedes[1] = assuan_fd_from_posix (1);
-      rc = assuan_init_pipe_server (&ctx, filedes);
+      filedes[0] = assuan_fd_from_posix_fd (0);
+      filedes[1] = assuan_fd_from_posix_fd (1);
+      rc = assuan_init_pipe_server (ctx, filedes);
     @}
   else
-    rc = assuan_init_socket_server (&ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED);
+    rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED);
   if (rc)
     @{
       fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc));
@@ -1248,13 +1257,16 @@ command_handler (int fd)
 @end example
 
 @noindent
-This is the first part of the command handler.  In case this is called
-as a pipe based server, @var{fd} will be based as @var{fd} and the
-code assumes that the server's @code{stdin} and @code{stdout} file
-handles are connected to a pipe.  The initialization is thus done
-using the function:
+This is the first part of the command handler.  We start of by
+allocating a new Assuan context with @code{assuan_new}.
+ at xref{function assuan_new}.
+
+In case this is called as a pipe based server, @var{fd} will be based
+as @var{fd} and the code assumes that the server's @code{stdin} and
+ at code{stdout} file handles are connected to a pipe.  The
+initialization is thus done using the function:
 
- at deftypefun gpg_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{assuan_fd_t @var{filedes}[2]})
+ at deftypefun gpg_error_t assuan_init_pipe_server (@w{assuan_context_t @var{ctx}}, @w{assuan_fd_t @var{filedes}[2]})
 
 The function takes the two file descriptors from @var{filedes} and
 returns a new Assuan context at @var{r_ctx}.  As usual, a return value
@@ -1270,15 +1282,11 @@ by the client to connect to such a server, automagically sets this
 variable.
 @end deftypefun
 
- at noindent
-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{assuan_fd_t @var{fd}}, @w{unsigned int @var{flags}})
+ at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t @var{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
- at var{r_ctx}. The following bits are currently defined for @var{flags}:
+The function takes the file descriptor @var{fd} which is expected to
+be associated with a socket and an Assuan context @var{ctx}. The
+following bits are currently defined for @var{flags}:
 
 @table @code
 @item ASSUAN_SOCKET_SERVER_FDPASSING
@@ -1291,8 +1299,7 @@ bit as it allows better control of the connection state.
 @end table
 
 As usual, a return value of @code{0} indicates success and a failure
-is indicated by a returning an error value.  In case of error,
- at code{NULL} will be stored at @var{r_ctx}.
+is indicated by a returning an error value.
 @end deftypefun
 
 @noindent

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list