summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-02-22 14:54:55 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-02-22 14:54:55 +0100
commit8255dd8965cde43311d6e89ca9e9644fe29d4bca (patch)
tree5e0bae3ecf37e9b0067e04b4f7ff188803e041c9 /src
parent38b71290e4140464ac196fbc7a1fcd291729215b (diff)
downloadfastd-8255dd8965cde43311d6e89ca9e9644fe29d4bca.tar
fastd-8255dd8965cde43311d6e89ca9e9644fe29d4bca.zip
Handle optional features (capabilities, status socket) more consistently
Diffstat (limited to 'src')
-rw-r--r--src/capabilities.c13
-rw-r--r--src/fastd.h40
-rw-r--r--src/poll.c3
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
-