X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=secnet.h;h=d9bd400f95f200105f630498470018ce38bd3cbb;hb=cf423c1b3196e98b0e2abaf56165baf65b6975d9;hp=cd2ea51e9212b96d1886d8ee158b052faf183a3b;hpb=b322d6cbd4fa140338d2f7af47ada689401a14e3;p=secnet.git diff --git a/secnet.h b/secnet.h index cd2ea51..d9bd400 100644 --- a/secnet.h +++ b/secnet.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -200,6 +201,16 @@ typedef int beforepoll_fn(void *st, struct pollfd *fds, int *nfds_io, int *timeout_io); typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds); +/* void BEFOREPOLL_WANT_FDS(int want); + * Expects: int *nfds_io; + * Can perform non-local exit. + * Checks whether there is space for want fds. If so, sets *nfds_io. + * If not, sets *nfds_io and returns. */ +#define BEFOREPOLL_WANT_FDS(want) do{ \ + if (*nfds_io<(want)) { *nfds_io=(want); return ERANGE; } \ + *nfds_io=(want); \ + }while(0) + /* Register interest in the main loop of the program. Before a call to poll() your supplied beforepoll function will be called. After the call to poll() the supplied afterpoll function will be called.