From: Marcus Brinkmann Date: Thu, 12 May 2011 12:45:46 +0000 (+0200) Subject: Fix I/O callback example. X-Git-Tag: gpgme-1.3.1~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5f3de0bfff43ce4ed9852673ab1a2ed24d1e8628;p=gpgme.git Fix I/O callback example. --- diff --git a/doc/ChangeLog b/doc/ChangeLog index 638df32..1dce16b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,7 @@ 2011-05-12 Marcus Brinkmann + * gpgme.texi (I/O Callback Example): Fix example code. + * gpgme.texi (Generating Keys): Fix OpenPGP parameters and reference GPG and GPGSM manual. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index c2bb309..72b9e22 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -5318,6 +5318,9 @@ structure because the number of file descriptors needed for a crypto operation in @acronym{GPGME} is not predictable. @example +#include +#include +#include #include #include #include @@ -5337,6 +5340,7 @@ struct one_fd int dir; gpgme_io_cb_t fnc; void *fnc_data; + void *loop; @}; struct event_loop @@ -5368,6 +5372,7 @@ add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, fds[i].dir = dir; fds[i].fnc = fnc; fds[i].fnc_data = fnc_data; + fds[i].loop = loop; break; @} @} @@ -5382,6 +5387,7 @@ void remove_io_cb (void *tag) @{ struct one_fd *fd = tag; + struct event_loop *loop = fd->loop; pthread_mutex_lock (&loop->lock); fd->fd = -1; @@ -5413,11 +5419,12 @@ do_select (struct event_loop *loop) fd_set wfds; int i, n; int any = 0; + struct one_fd *fdlist = loop->fds; pthread_mutex_lock (&loop->lock); FD_ZERO (&rfds); FD_ZERO (&wfds); - for (i = 0; i < FDLIST_MAX; i++) + for (i = 0; i < MAX_FDS; i++) if (fdlist[i].fd != -1) FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds); pthread_mutex_unlock (&loop->unlock); @@ -5432,7 +5439,7 @@ do_select (struct event_loop *loop) return n; /* Error or timeout. */ pthread_mutex_lock (&loop->lock); - for (i = 0; i < FDLIST_MAX && n; i++) + for (i = 0; i < MAX_FDS && n; i++) @{ if (fdlist[i].fd != -1) @{ @@ -5463,7 +5470,6 @@ wait_for_op (struct event_loop *loop, struct op_result *result) ret = do_select (loop); @} while (ret >= 0 && !result->done); - return ret; @} @end example @@ -5478,7 +5484,6 @@ main (int argc, char *argv[]) gpgme_ctx_t ctx; gpgme_error_t err; gpgme_data_t sig, text; - gpgme_sig_stat_t status; int i; struct gpgme_io_cb_ts io_cbs = @{ @@ -5492,7 +5497,7 @@ main (int argc, char *argv[]) init_gpgme (void); /* Initialize the loop structure. */ - loop.lock = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_init (&loop.lock, NULL); for (i = 0; i < MAX_FDS; i++) loop->fds[i].fd = -1; @@ -5507,7 +5512,7 @@ main (int argc, char *argv[]) if (!err) @{ gpgme_set_io_cbs (ctx, &io_cbs); - err = gpgme_op_verify_start (ctx, sig, text, &status); + err = gpgme_op_verify_start (ctx, sig, text, NULL); @} if (err) @{ @@ -5528,7 +5533,7 @@ main (int argc, char *argv[]) gpgme_strsource (result.err), gpgme_strerror (result.err)); exit (1); @} - /* Evaluate STATUS. */ + /* Evaluate verify result. */ @dots{} return 0; @}