| 9487f7f | 2011-08-03 07:05:30 -0700 | [diff] [blame^] | 1 | #ifndef __SELECT_H |
| 2 | #define __SELECT_H |
| 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
| 10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 11 | * |
| 12 | * This software is licensed as described in the file COPYING, which |
| 13 | * you should have received as part of this distribution. The terms |
| 14 | * are also available at http://curl.haxx.se/docs/copyright.html. |
| 15 | * |
| 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 17 | * copies of the Software, and permit persons to whom the Software is |
| 18 | * furnished to do so, under the terms of the COPYING file. |
| 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #include "setup.h" |
| 26 | |
| 27 | #ifdef HAVE_SYS_POLL_H |
| 28 | #include <sys/poll.h> |
| 29 | #elif defined(HAVE_POLL_H) |
| 30 | #include <poll.h> |
| 31 | #endif |
| 32 | |
| 33 | /* |
| 34 | * poll() function on Windows Vista and later is called WSAPoll() |
| 35 | */ |
| 36 | |
| 37 | #if defined(USE_WINSOCK) && (USE_WINSOCK > 1) && \ |
| 38 | defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) |
| 39 | # undef HAVE_POLL |
| 40 | # define HAVE_POLL 1 |
| 41 | # undef HAVE_POLL_FINE |
| 42 | # define HAVE_POLL_FINE 1 |
| 43 | # define poll(x,y,z) WSAPoll((x),(y),(z)) |
| 44 | # if defined(_MSC_VER) && defined(POLLRDNORM) |
| 45 | # undef POLLPRI |
| 46 | # define POLLPRI POLLRDBAND |
| 47 | # define HAVE_STRUCT_POLLFD 1 |
| 48 | # endif |
| 49 | #endif |
| 50 | |
| 51 | /* |
| 52 | * Definition of pollfd struct and constants for platforms lacking them. |
| 53 | */ |
| 54 | |
| 55 | #if !defined(HAVE_STRUCT_POLLFD) && \ |
| 56 | !defined(HAVE_SYS_POLL_H) && \ |
| 57 | !defined(HAVE_POLL_H) |
| 58 | |
| 59 | #define POLLIN 0x01 |
| 60 | #define POLLPRI 0x02 |
| 61 | #define POLLOUT 0x04 |
| 62 | #define POLLERR 0x08 |
| 63 | #define POLLHUP 0x10 |
| 64 | #define POLLNVAL 0x20 |
| 65 | |
| 66 | struct pollfd |
| 67 | { |
| 68 | curl_socket_t fd; |
| 69 | short events; |
| 70 | short revents; |
| 71 | }; |
| 72 | |
| 73 | #endif |
| 74 | |
| 75 | #ifndef POLLRDNORM |
| 76 | #define POLLRDNORM POLLIN |
| 77 | #endif |
| 78 | |
| 79 | #ifndef POLLWRNORM |
| 80 | #define POLLWRNORM POLLOUT |
| 81 | #endif |
| 82 | |
| 83 | #ifndef POLLRDBAND |
| 84 | #define POLLRDBAND POLLPRI |
| 85 | #endif |
| 86 | |
| 87 | int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd, |
| 88 | int timeout_ms); |
| 89 | |
| 90 | int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms); |
| 91 | |
| 92 | #ifdef TPF |
| 93 | int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, |
| 94 | fd_set* excepts, struct timeval* tv); |
| 95 | #endif |
| 96 | |
| 97 | #endif /* __SELECT_H */ |