operation in @acronym{GPGME} is not predictable.
@example
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
#include <pthread.h>
#include <sys/types.h>
#include <gpgme.h>
int dir;
gpgme_io_cb_t fnc;
void *fnc_data;
+ void *loop;
@};
struct event_loop
fds[i].dir = dir;
fds[i].fnc = fnc;
fds[i].fnc_data = fnc_data;
+ fds[i].loop = loop;
break;
@}
@}
remove_io_cb (void *tag)
@{
struct one_fd *fd = tag;
+ struct event_loop *loop = fd->loop;
pthread_mutex_lock (&loop->lock);
fd->fd = -1;
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);
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)
@{
ret = do_select (loop);
@}
while (ret >= 0 && !result->done);
- return ret;
@}
@end example
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 =
@{
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;
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)
@{
gpgme_strsource (result.err), gpgme_strerror (result.err));
exit (1);
@}
- /* Evaluate STATUS. */
+ /* Evaluate verify result. */
@dots{}
return 0;
@}