From ac502d12ad8b762ff920452683888a385b3d03f8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 3 Jun 2010 20:47:53 +0000 Subject: [PATCH] add native setting capability --- src/include/gnunet_network_lib.h | 16 +++++++++++++++- src/util/network.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 37c8cf319..1666abc90 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h @@ -285,10 +285,14 @@ void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, void GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, const struct GNUNET_NETWORK_FDSet *from); -/* +/** * Return file descriptor for this network handle + * + * @param desc wrapper to process + * @return POSIX file descriptor */ int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc); + /** * Copy a native fd set * @param to destination @@ -298,6 +302,16 @@ int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc); void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, const fd_set * from, int nfds); + +/** + * Set a native fd in a set + * + * @param to destination + * @param nfd native FD to set + */ +void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, + int nfd); + /** * Add a file handle to the fd set * @param fds fd set diff --git a/src/util/network.c b/src/util/network.c index c4fb73049..0b4168034 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -723,6 +723,21 @@ GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, to->nsds = nfds; } + +/** + * Set a native fd in a set + * + * @param to destination + * @param nfd native FD to set + */ +void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, + int nfd) +{ + FD_SET (nfd, &to->sds); + to->nsds = GNUNET_MAX (nfd + 1, to->nsds); +} + + /** * Add a file handle to the fd set * @param fds fd set -- 2.25.1