aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_sockets.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_sockets.h')
-rw-r--r--src/microhttpd/mhd_sockets.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index acffaa57..13b90d2e 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -204,6 +204,53 @@
204# define MHD_socket_close_(fd) closesocket((fd)) 204# define MHD_socket_close_(fd) closesocket((fd))
205#endif 205#endif
206 206
207/**
208 * Check whether FD can be added to fd_set with specified FD_SETSIZE.
209 * @param fd the fd to check
210 * @param pset the pointer to fd_set to check or NULL to check
211 * whether FD can be used with fd_sets.
212 * @param setsize the value of FD_SETSIZE.
213 * @return boolean true if FD can be added to fd_set,
214 * boolean false otherwise.
215 */
216#if defined(MHD_POSIX_SOCKETS)
217# define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) ((fd) < (setsize))
218#elif defined(MHD_WINSOCK_SOCKETS)
219# define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) ( ((void*)(pset)==(void*)0) || \
220 (((fd_set*)(pset))->fd_count < (setsize)) || \
221 (FD_ISSET((fd),(pset))) )
222#endif
223
224/**
225 * Check whether FD can be added to fd_set with current FD_SETSIZE.
226 * @param fd the fd to check
227 * @param pset the pointer to fd_set to check or NULL to check
228 * whether FD can be used with fd_sets.
229 * @return boolean true if FD can be added to fd_set,
230 * boolean false otherwise.
231 */
232#define MHD_SCKT_FD_FITS_FDSET_(fd,pset) MHD_SCKT_FD_FITS_FDSET_SETSIZE_((fd),(pset),FD_SETSIZE)
233
234/**
235 * Add FD to fd_set with specified FD_SETSIZE.
236 * @param fd the fd to add
237 * @param pset the valid pointer to fd_set.
238 * @param setsize the value of FD_SETSIZE.
239 * @note To work on W32 with value of FD_SETSIZE different from currently defined value,
240 * system definition of FD_SET() is not used.
241 */
242#if defined(MHD_POSIX_SOCKETS)
243# define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) FD_SET((fd),(pset))
244#elif defined(MHD_WINSOCK_SOCKETS)
245# define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) \
246 do { \
247 u_int _i_ = 0; \
248 fd_set* const _s_ = (fd_set*)(pset); \
249 while((_i_ < _s_->fd_count) && ((fd) != _s_->fd_array[_i_])) {++_i_;} \
250 if ((_i_ == _s_->fd_count)) {_s_->fd_array[_s_->fd_count++] = (fd);} \
251 } while(0)
252#endif
253
207 /* MHD_SYS_select_ is wrapper macro for system select() function */ 254 /* MHD_SYS_select_ is wrapper macro for system select() function */
208#if !defined(MHD_WINSOCK_SOCKETS) 255#if !defined(MHD_WINSOCK_SOCKETS)
209# define MHD_SYS_select_(n,r,w,e,t) select((n),(r),(w),(e),(t)) 256# define MHD_SYS_select_(n,r,w,e,t) select((n),(r),(w),(e),(t))