select.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_SELECT_H
00002 #define HEADER_CURL_SELECT_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 
00025 #include "curl_setup.h"
00026 
00027 #ifdef HAVE_SYS_POLL_H
00028 #include <sys/poll.h>
00029 #elif defined(HAVE_POLL_H)
00030 #include <poll.h>
00031 #endif
00032 
00033 /*
00034  * Definition of pollfd struct and constants for platforms lacking them.
00035  */
00036 
00037 #if !defined(HAVE_STRUCT_POLLFD) && \
00038     !defined(HAVE_SYS_POLL_H) && \
00039     !defined(HAVE_POLL_H)
00040 
00041 #define POLLIN      0x01
00042 #define POLLPRI     0x02
00043 #define POLLOUT     0x04
00044 #define POLLERR     0x08
00045 #define POLLHUP     0x10
00046 #define POLLNVAL    0x20
00047 
00048 struct pollfd
00049 {
00050     curl_socket_t fd;
00051     short   events;
00052     short   revents;
00053 };
00054 
00055 #endif
00056 
00057 #ifndef POLLRDNORM
00058 #define POLLRDNORM POLLIN
00059 #endif
00060 
00061 #ifndef POLLWRNORM
00062 #define POLLWRNORM POLLOUT
00063 #endif
00064 
00065 #ifndef POLLRDBAND
00066 #define POLLRDBAND POLLPRI
00067 #endif
00068 
00069 /* there are three CSELECT defines that are defined in the public header that
00070    are exposed to users, but this *IN2 bit is only ever used internally and
00071    therefore defined here */
00072 #define CURL_CSELECT_IN2 (CURL_CSELECT_ERR << 1)
00073 
00074 int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
00075                       curl_socket_t writefd,
00076                       time_t timeout_ms);
00077 
00078 #define SOCKET_READABLE(x,z) \
00079   Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
00080 #define SOCKET_WRITABLE(x,z) \
00081   Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
00082 
00083 int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
00084 
00085 /* On non-DOS and non-Winsock platforms, when Curl_ack_eintr is set,
00086  * EINTR condition is honored and function might exit early without
00087  * awaiting full timeout.  Otherwise EINTR will be ignored and full
00088  * timeout will elapse. */
00089 extern int Curl_ack_eintr;
00090 
00091 int Curl_wait_ms(int timeout_ms);
00092 
00093 #ifdef TPF
00094 int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
00095                        fd_set* excepts, struct timeval* tv);
00096 #endif
00097 
00098 /* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1], which
00099    unfortunately makes it impossible for us to easily check if they're valid
00100 */
00101 #if defined(USE_WINSOCK) || defined(TPF)
00102 #define VALID_SOCK(x) 1
00103 #define VERIFY_SOCK(x) Curl_nop_stmt
00104 #else
00105 #define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
00106 #define VERIFY_SOCK(x) do { \
00107   if(!VALID_SOCK(x)) { \
00108     SET_SOCKERRNO(EINVAL); \
00109     return -1; \
00110   } \
00111 } WHILE_FALSE
00112 #endif
00113 
00114 #endif /* HEADER_CURL_SELECT_H */
00115 


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06