From 8255dd8965cde43311d6e89ca9e9644fe29d4bca Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 22 Feb 2016 14:54:55 +0100 Subject: Handle optional features (capabilities, status socket) more consistently --- src/capabilities.c | 13 +------------ src/fastd.h | 40 ++++++++++++++++++++++++++-------------- src/poll.c | 3 --- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/capabilities.c b/src/capabilities.c index 6865097..4da1ef2 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -102,15 +102,4 @@ void fastd_cap_drop(void) { } - -#else /* WITH_CAPABILITIES */ - -void fastd_cap_init(void) { -} - -void fastd_cap_drop(void) { -} - -#endif /* WITH_CAPABILITIES */ - - +#endif diff --git a/src/fastd.h b/src/fastd.h index bc5433c..58c7e0f 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -371,12 +371,6 @@ fastd_socket_t * fastd_socket_open(fastd_peer_t *peer, int af); void fastd_socket_close(fastd_socket_t *sock); void fastd_socket_error(fastd_socket_t *sock); -#ifdef __ANDROID__ -int fastd_android_receive_tunfd(void); -void fastd_android_send_pid(void); -bool fastd_android_protect_socket(int fd); -#endif - void fastd_resolve_peer(fastd_peer_t *peer, fastd_remote_t *remote); fastd_iface_t * fastd_iface_open(fastd_peer_t *peer); @@ -384,10 +378,30 @@ void fastd_iface_handle(fastd_iface_t *iface); void fastd_iface_write(fastd_iface_t *iface, fastd_buffer_t buffer); void fastd_iface_close(fastd_iface_t *iface); +void fastd_random_bytes(void *buffer, size_t len, bool secure); + + +#ifdef __ANDROID__ + +int fastd_android_receive_tunfd(void); +void fastd_android_send_pid(void); +bool fastd_android_protect_socket(int fd); + +#endif /* __ANDROID__ */ + + +#ifdef WITH_CAPABILITIES + void fastd_cap_init(void); void fastd_cap_drop(void); -void fastd_random_bytes(void *buffer, size_t len, bool secure); +#else /* WITH_CAPABILITIES */ + +static inline void fastd_cap_init(void) {} +static inline void fastd_cap_drop(void) {} + +#endif /* WITH_CAPABILITIES */ + #ifdef WITH_STATUS_SOCKET @@ -395,15 +409,13 @@ void fastd_status_init(void); void fastd_status_close(void); void fastd_status_handle(void); -#else - -static inline void fastd_status_init(void) { -} +#else /* WITH_STATUS_SOCKET */ -static inline void fastd_status_close(void) { -} +static inline void fastd_status_init(void) {} +static inline void fastd_status_close(void) {} +static inline void fastd_status_handle(void) {} -#endif +#endif /* WITH_STATUS_SOCKET */ /** Returns a random number between \a min (inclusively) and \a max (exclusively) */ diff --git a/src/poll.c b/src/poll.c index 02ee00b..123db6f 100644 --- a/src/poll.c +++ b/src/poll.c @@ -73,12 +73,10 @@ static inline void handle_fd(fastd_poll_fd_t *fd, bool input, bool error) { fastd_async_handle(); break; -#ifdef WITH_STATUS_SOCKET case POLL_TYPE_STATUS: if (input) fastd_status_handle(); break; -#endif case POLL_TYPE_IFACE: { @@ -318,4 +316,3 @@ void fastd_poll_handle(void) { } #endif - -- cgit v1.2.3