select.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * $Id$
  24. ***************************************************************************/
  25. #include "setup.h"
  26. #ifdef HAVE_SYS_POLL_H
  27. #include <sys/poll.h>
  28. #elif defined(HAVE_POLL_H)
  29. #include <poll.h>
  30. #endif
  31. /*
  32. * poll() function on Windows Vista and later is called WSAPoll()
  33. */
  34. #if defined(USE_WINSOCK) && (USE_WINSOCK > 1) && \
  35. defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
  36. # undef HAVE_POLL
  37. # define HAVE_POLL 1
  38. # undef HAVE_POLL_FINE
  39. # define HAVE_POLL_FINE 1
  40. # define poll(x,y,z) WSAPoll((x),(y),(z))
  41. # if defined(_MSC_VER) && defined(POLLRDNORM)
  42. # undef POLLPRI
  43. # define POLLPRI POLLRDBAND
  44. # define HAVE_STRUCT_POLLFD 1
  45. # endif
  46. #endif
  47. /*
  48. * Definition of pollfd struct and constants for platforms lacking them.
  49. */
  50. #if !defined(HAVE_STRUCT_POLLFD) && \
  51. !defined(HAVE_SYS_POLL_H) && \
  52. !defined(HAVE_POLL_H)
  53. #define POLLIN 0x01
  54. #define POLLPRI 0x02
  55. #define POLLOUT 0x04
  56. #define POLLERR 0x08
  57. #define POLLHUP 0x10
  58. #define POLLNVAL 0x20
  59. struct pollfd
  60. {
  61. curl_socket_t fd;
  62. short events;
  63. short revents;
  64. };
  65. #endif
  66. #ifndef POLLRDNORM
  67. #define POLLRDNORM POLLIN
  68. #endif
  69. #ifndef POLLWRNORM
  70. #define POLLWRNORM POLLOUT
  71. #endif
  72. #ifndef POLLRDBAND
  73. #define POLLRDBAND POLLPRI
  74. #endif
  75. int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
  76. int timeout_ms);
  77. int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
  78. #ifdef TPF
  79. int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
  80. fd_set* excepts, struct timeval* tv);
  81. #endif
  82. #endif /* __SELECT_H */