gmime r1510 - in trunk: . gmime
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1510 - in trunk: . gmime
- Date: Wed, 18 Mar 2009 13:36:25 +0000 (UTC)
Author: fejj
Date: Wed Mar 18 13:36:25 2009
New Revision: 1510
URL: http://svn.gnome.org/viewvc/gmime?rev=1510&view=rev
Log:
2009-03-18 Jeffrey Stedfast <fejj novell com>
* configure.in: Check for select() and poll() as well as poll.h
* gmime/gmime-gpg-context.c (poll): Implement our own poll()
function using select() for portability to MacOS 10.2, which
apparently doesn't have poll().
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/gmime/gmime-gpg-context.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Wed Mar 18 13:36:25 2009
@@ -87,11 +87,13 @@
dnl Checks for header files.
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/param.h)
+AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(ctype.h)
AC_CHECK_HEADERS(time.h)
+AC_CHECK_HEADERS(poll.h)
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
@@ -119,6 +121,9 @@
AC_FUNC_MMAP
AC_CHECK_FUNCS(munmap msync)
+dnl Check for select() and poll()
+AC_CHECK_FUNCS(select poll)
+
dnl ************************************
dnl Checks for gtk-doc and docbook-tools
dnl ************************************
Modified: trunk/gmime/gmime-gpg-context.c
==============================================================================
--- trunk/gmime/gmime-gpg-context.c (original)
+++ trunk/gmime/gmime-gpg-context.c Wed Mar 18 13:36:25 2009
@@ -37,7 +37,9 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
+#ifdef HAVE_POLL_H
#include <poll.h>
+#endif
#include "gmime-gpg-context.h"
#include "gmime-filter-charset.h"
@@ -1243,6 +1245,83 @@
GPG_N_FDS
};
+#ifndef HAVE_POLL
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#define POLLIN (1 << 0)
+#define POLLPRI (1 << 1)
+#define POLLOUT (1 << 2)
+#define POLLERR (1 << 3)
+#define POLLHUP (1 << 4)
+#define POLLNVAL (1 << 5)
+
+#ifdef HAVE_SELECT
+static int
+poll (struct pollfd *pfds, nfds_t nfds, int timeout)
+{
+ fd_set rset, wset, xset;
+ struct timeval tv;
+ int maxfd = 0;
+ int ready;
+ nfds_t i;
+
+ if (nfds == 0)
+ return 0;
+
+ /* initialize our select() timeout */
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+
+ /* initialize our select() fd sets */
+ FD_ZERO (&rset);
+ FD_ZERO (&wset);
+ FD_ZERO (&xset);
+
+ for (i = 0; i < nfds; i++) {
+ if (pfds[i].events & POLLIN)
+ FD_SET (pfds[i].fd, &rset);
+ if (pfds[i].events & POLLOUT)
+ FD_SET (pfds[i].fd, &wset);
+ if (pfds[i].events & POLLPRI)
+ FD_SET (pfds[i].fd, &xset);
+ if (pfds[i].fd > maxfd && (pfds[i].events & (POLLIN | POLLOUT | POLLPRI)))
+ maxfd = pfds[i].fd;
+ pfds[i].revents = 0;
+ }
+
+ /* poll our fds... */
+ if ((ready = select (maxfd + 1, &rset, &wset, &xset, timeout != -1 ? &tv : NULL)) > 0) {
+ ready = 0;
+
+ for (i = 0; i < nfds; i++) {
+ if (FD_ISSET (pfds[i].fd, &rset))
+ pfds[i].revents |= POLLIN;
+ if (FD_ISSET (pfds[i].fd, &wset))
+ pfds[i].revents |= POLLOUT;
+ if (FD_ISSET (pfds[i].fd, &xset))
+ pfds[i].revents |= POLLPRI;
+
+ if (pfds[i].revents != 0)
+ ready++;
+ }
+ }
+
+ return ready;
+}
+#else
+static int
+poll (struct pollfd *pfds, nfds_t nfds, int timeout)
+{
+ errno = EIO;
+ return -1;
+}
+#endif /* HAVE_SELECT */
+#endif /* ! HAVE_POLL */
+
static int
gpg_ctx_op_step (struct _GpgCtx *gpg, GError **err)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]