diff options
author | kikht <kikht@yandex-team.ru> | 2022-02-10 16:45:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:14 +0300 |
commit | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/libevent/include/event2/util.h | |
parent | 194cae0e8855b11be2005e1eff12c660c3ee9774 (diff) | |
download | ydb-778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5.tar.gz |
Restoring authorship annotation for <kikht@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/libevent/include/event2/util.h')
-rw-r--r-- | contrib/libs/libevent/include/event2/util.h | 496 |
1 files changed, 248 insertions, 248 deletions
diff --git a/contrib/libs/libevent/include/event2/util.h b/contrib/libs/libevent/include/event2/util.h index f54f93ef4f..02aa7ba9da 100644 --- a/contrib/libs/libevent/include/event2/util.h +++ b/contrib/libs/libevent/include/event2/util.h @@ -23,8 +23,8 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENT2_UTIL_H_INCLUDED_ -#define EVENT2_UTIL_H_INCLUDED_ +#ifndef EVENT2_UTIL_H_INCLUDED_ +#define EVENT2_UTIL_H_INCLUDED_ /** @file event2/util.h @@ -32,53 +32,53 @@ related socket manipulations. */ -#include <event2/visibility.h> +#include <event2/visibility.h> #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> -#ifdef EVENT__HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif -#ifdef EVENT__HAVE_STDINT_H +#ifdef EVENT__HAVE_STDINT_H #include <stdint.h> -#elif defined(EVENT__HAVE_INTTYPES_H) +#elif defined(EVENT__HAVE_INTTYPES_H) #include <inttypes.h> #endif -#ifdef EVENT__HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef EVENT__HAVE_STDDEF_H +#ifdef EVENT__HAVE_STDDEF_H #include <stddef.h> #endif #ifdef _MSC_VER #include <BaseTsd.h> #endif #include <stdarg.h> -#ifdef EVENT__HAVE_NETDB_H +#ifdef EVENT__HAVE_NETDB_H #include <netdb.h> #endif -#ifdef _WIN32 +#ifdef _WIN32 #include <winsock2.h> -#ifdef EVENT__HAVE_GETADDRINFO -/* for EAI_* definitions. */ -#include <ws2tcpip.h> -#endif -#else -#ifdef EVENT__HAVE_ERRNO_H -#include <errno.h> -#endif +#ifdef EVENT__HAVE_GETADDRINFO +/* for EAI_* definitions. */ +#include <ws2tcpip.h> +#endif +#else +#ifdef EVENT__HAVE_ERRNO_H +#include <errno.h> +#endif #include <sys/socket.h> #endif -#include <time.h> - +#include <time.h> + /* Some openbsd autoconf versions get the name of this macro wrong. */ -#if defined(EVENT__SIZEOF_VOID__) && !defined(EVENT__SIZEOF_VOID_P) -#define EVENT__SIZEOF_VOID_P EVENT__SIZEOF_VOID__ +#if defined(EVENT__SIZEOF_VOID__) && !defined(EVENT__SIZEOF_VOID_P) +#define EVENT__SIZEOF_VOID_P EVENT__SIZEOF_VOID__ #endif /** @@ -110,67 +110,67 @@ extern "C" { * * @{ */ -#ifdef EVENT__HAVE_UINT64_T +#ifdef EVENT__HAVE_UINT64_T #define ev_uint64_t uint64_t #define ev_int64_t int64_t -#elif defined(_WIN32) +#elif defined(_WIN32) #define ev_uint64_t unsigned __int64 #define ev_int64_t signed __int64 -#elif EVENT__SIZEOF_LONG_LONG == 8 +#elif EVENT__SIZEOF_LONG_LONG == 8 #define ev_uint64_t unsigned long long #define ev_int64_t long long -#elif EVENT__SIZEOF_LONG == 8 +#elif EVENT__SIZEOF_LONG == 8 #define ev_uint64_t unsigned long #define ev_int64_t long -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define ev_uint64_t ... #define ev_int64_t ... #else #error "No way to define ev_uint64_t" #endif -#ifdef EVENT__HAVE_UINT32_T +#ifdef EVENT__HAVE_UINT32_T #define ev_uint32_t uint32_t #define ev_int32_t int32_t -#elif defined(_WIN32) +#elif defined(_WIN32) #define ev_uint32_t unsigned int #define ev_int32_t signed int -#elif EVENT__SIZEOF_LONG == 4 +#elif EVENT__SIZEOF_LONG == 4 #define ev_uint32_t unsigned long #define ev_int32_t signed long -#elif EVENT__SIZEOF_INT == 4 +#elif EVENT__SIZEOF_INT == 4 #define ev_uint32_t unsigned int #define ev_int32_t signed int -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define ev_uint32_t ... #define ev_int32_t ... #else #error "No way to define ev_uint32_t" #endif -#ifdef EVENT__HAVE_UINT16_T +#ifdef EVENT__HAVE_UINT16_T #define ev_uint16_t uint16_t #define ev_int16_t int16_t -#elif defined(_WIN32) +#elif defined(_WIN32) #define ev_uint16_t unsigned short #define ev_int16_t signed short -#elif EVENT__SIZEOF_INT == 2 +#elif EVENT__SIZEOF_INT == 2 #define ev_uint16_t unsigned int #define ev_int16_t signed int -#elif EVENT__SIZEOF_SHORT == 2 +#elif EVENT__SIZEOF_SHORT == 2 #define ev_uint16_t unsigned short #define ev_int16_t signed short -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define ev_uint16_t ... #define ev_int16_t ... #else #error "No way to define ev_uint16_t" #endif -#ifdef EVENT__HAVE_UINT8_T +#ifdef EVENT__HAVE_UINT8_T #define ev_uint8_t uint8_t #define ev_int8_t int8_t -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define ev_uint8_t ... #define ev_int8_t ... #else @@ -178,43 +178,43 @@ extern "C" { #define ev_int8_t signed char #endif -#ifdef EVENT__HAVE_UINTPTR_T +#ifdef EVENT__HAVE_UINTPTR_T #define ev_uintptr_t uintptr_t #define ev_intptr_t intptr_t -#elif EVENT__SIZEOF_VOID_P <= 4 +#elif EVENT__SIZEOF_VOID_P <= 4 #define ev_uintptr_t ev_uint32_t #define ev_intptr_t ev_int32_t -#elif EVENT__SIZEOF_VOID_P <= 8 +#elif EVENT__SIZEOF_VOID_P <= 8 #define ev_uintptr_t ev_uint64_t #define ev_intptr_t ev_int64_t -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define ev_uintptr_t ... #define ev_intptr_t ... #else #error "No way to define ev_uintptr_t" #endif -#ifdef EVENT__ssize_t -#define ev_ssize_t EVENT__ssize_t +#ifdef EVENT__ssize_t +#define ev_ssize_t EVENT__ssize_t #else #define ev_ssize_t ssize_t #endif -/* Note that we define ev_off_t based on the compile-time size of off_t that - * we used to build Libevent, and not based on the current size of off_t. - * (For example, we don't define ev_off_t to off_t.). We do this because - * some systems let you build your software with different off_t sizes - * at runtime, and so putting in any dependency on off_t would risk API - * mismatch. - */ -#ifdef _WIN32 +/* Note that we define ev_off_t based on the compile-time size of off_t that + * we used to build Libevent, and not based on the current size of off_t. + * (For example, we don't define ev_off_t to off_t.). We do this because + * some systems let you build your software with different off_t sizes + * at runtime, and so putting in any dependency on off_t would risk API + * mismatch. + */ +#ifdef _WIN32 #define ev_off_t ev_int64_t -#elif EVENT__SIZEOF_OFF_T == 8 -#define ev_off_t ev_int64_t -#elif EVENT__SIZEOF_OFF_T == 4 -#define ev_off_t ev_int32_t -#elif defined(EVENT_IN_DOXYGEN_) -#define ev_off_t ... +#elif EVENT__SIZEOF_OFF_T == 8 +#define ev_off_t ev_int64_t +#elif EVENT__SIZEOF_OFF_T == 4 +#define ev_off_t ev_int32_t +#elif defined(EVENT_IN_DOXYGEN_) +#define ev_off_t ... #else #define ev_off_t off_t #endif @@ -235,7 +235,7 @@ extern "C" { @{ */ -#ifndef EVENT__HAVE_STDINT_H +#ifndef EVENT__HAVE_STDINT_H #define EV_UINT64_MAX ((((ev_uint64_t)0xffffffffUL) << 32) | 0xffffffffUL) #define EV_INT64_MAX ((((ev_int64_t) 0x7fffffffL) << 32) | 0xffffffffL) #define EV_INT64_MIN ((-EV_INT64_MAX) - 1) @@ -248,35 +248,35 @@ extern "C" { #define EV_UINT8_MAX 255 #define EV_INT8_MAX 127 #define EV_INT8_MIN ((-EV_INT8_MAX) - 1) -#else -#define EV_UINT64_MAX UINT64_MAX -#define EV_INT64_MAX INT64_MAX -#define EV_INT64_MIN INT64_MIN -#define EV_UINT32_MAX UINT32_MAX -#define EV_INT32_MAX INT32_MAX -#define EV_INT32_MIN INT32_MIN -#define EV_UINT16_MAX UINT16_MAX -#define EV_INT16_MIN INT16_MIN -#define EV_INT16_MAX INT16_MAX -#define EV_UINT8_MAX UINT8_MAX -#define EV_INT8_MAX INT8_MAX -#define EV_INT8_MIN INT8_MIN +#else +#define EV_UINT64_MAX UINT64_MAX +#define EV_INT64_MAX INT64_MAX +#define EV_INT64_MIN INT64_MIN +#define EV_UINT32_MAX UINT32_MAX +#define EV_INT32_MAX INT32_MAX +#define EV_INT32_MIN INT32_MIN +#define EV_UINT16_MAX UINT16_MAX +#define EV_INT16_MIN INT16_MIN +#define EV_INT16_MAX INT16_MAX +#define EV_UINT8_MAX UINT8_MAX +#define EV_INT8_MAX INT8_MAX +#define EV_INT8_MIN INT8_MIN /** @} */ -#endif +#endif + - /** @name Limits for SIZE_T and SSIZE_T @{ */ -#if EVENT__SIZEOF_SIZE_T == 8 +#if EVENT__SIZEOF_SIZE_T == 8 #define EV_SIZE_MAX EV_UINT64_MAX #define EV_SSIZE_MAX EV_INT64_MAX -#elif EVENT__SIZEOF_SIZE_T == 4 +#elif EVENT__SIZEOF_SIZE_T == 4 #define EV_SIZE_MAX EV_UINT32_MAX #define EV_SSIZE_MAX EV_INT32_MAX -#elif defined(EVENT_IN_DOXYGEN_) +#elif defined(EVENT_IN_DOXYGEN_) #define EV_SIZE_MAX ... #define EV_SSIZE_MAX ... #else @@ -286,16 +286,16 @@ extern "C" { #define EV_SSIZE_MIN ((-EV_SSIZE_MAX) - 1) /**@}*/ -#ifdef _WIN32 +#ifdef _WIN32 #define ev_socklen_t int -#elif defined(EVENT__socklen_t) -#define ev_socklen_t EVENT__socklen_t +#elif defined(EVENT__socklen_t) +#define ev_socklen_t EVENT__socklen_t #else #define ev_socklen_t socklen_t #endif -#ifdef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY -#if !defined(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) \ +#ifdef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY +#if !defined(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) \ && !defined(ss_family) #define ss_family __ss_family #endif @@ -304,77 +304,77 @@ extern "C" { /** * A type wide enough to hold the output of "socket()" or "accept()". On * Windows, this is an intptr_t; elsewhere, it is an int. */ -#ifdef _WIN32 +#ifdef _WIN32 #define evutil_socket_t intptr_t #else #define evutil_socket_t int #endif -/** - * Structure to hold information about a monotonic timer - * - * Use this with evutil_configure_monotonic_time() and - * evutil_gettime_monotonic(). - * - * This is an opaque structure; you can allocate one using - * evutil_monotonic_timer_new(). - * - * @see evutil_monotonic_timer_new(), evutil_monotonic_timer_free(), - * evutil_configure_monotonic_time(), evutil_gettime_monotonic() - */ -struct evutil_monotonic_timer -#ifdef EVENT_IN_DOXYGEN_ -{/*Empty body so that doxygen will generate documentation here.*/} -#endif -; - -#define EV_MONOT_PRECISE 1 -#define EV_MONOT_FALLBACK 2 - -/** Format a date string using RFC 1123 format (used in HTTP). - * If `tm` is NULL, current system's time will be used. - * The number of characters written will be returned. - * One should check if the return value is smaller than `datelen` to check if - * the result is truncated or not. - */ -EVENT2_EXPORT_SYMBOL int -evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm); - -/** Allocate a new struct evutil_monotonic_timer for use with the - * evutil_configure_monotonic_time() and evutil_gettime_monotonic() - * functions. You must configure the timer with - * evutil_configure_monotonic_time() before using it. - */ -EVENT2_EXPORT_SYMBOL -struct evutil_monotonic_timer * evutil_monotonic_timer_new(void); - -/** Free a struct evutil_monotonic_timer that was allocated using - * evutil_monotonic_timer_new(). - */ -EVENT2_EXPORT_SYMBOL -void evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer); - -/** Set up a struct evutil_monotonic_timer; flags can include - * EV_MONOT_PRECISE and EV_MONOT_FALLBACK. - */ -EVENT2_EXPORT_SYMBOL -int evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer, - int flags); - -/** Query the current monotonic time from a struct evutil_monotonic_timer - * previously configured with evutil_configure_monotonic_time(). Monotonic - * time is guaranteed never to run in reverse, but is not necessarily epoch- - * based, or relative to any other definite point. Use it to make reliable - * measurements of elapsed time between events even when the system time - * may be changed. - * - * It is not safe to use this funtion on the same timer from multiple - * threads. - */ -EVENT2_EXPORT_SYMBOL -int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer, - struct timeval *tp); - +/** + * Structure to hold information about a monotonic timer + * + * Use this with evutil_configure_monotonic_time() and + * evutil_gettime_monotonic(). + * + * This is an opaque structure; you can allocate one using + * evutil_monotonic_timer_new(). + * + * @see evutil_monotonic_timer_new(), evutil_monotonic_timer_free(), + * evutil_configure_monotonic_time(), evutil_gettime_monotonic() + */ +struct evutil_monotonic_timer +#ifdef EVENT_IN_DOXYGEN_ +{/*Empty body so that doxygen will generate documentation here.*/} +#endif +; + +#define EV_MONOT_PRECISE 1 +#define EV_MONOT_FALLBACK 2 + +/** Format a date string using RFC 1123 format (used in HTTP). + * If `tm` is NULL, current system's time will be used. + * The number of characters written will be returned. + * One should check if the return value is smaller than `datelen` to check if + * the result is truncated or not. + */ +EVENT2_EXPORT_SYMBOL int +evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm); + +/** Allocate a new struct evutil_monotonic_timer for use with the + * evutil_configure_monotonic_time() and evutil_gettime_monotonic() + * functions. You must configure the timer with + * evutil_configure_monotonic_time() before using it. + */ +EVENT2_EXPORT_SYMBOL +struct evutil_monotonic_timer * evutil_monotonic_timer_new(void); + +/** Free a struct evutil_monotonic_timer that was allocated using + * evutil_monotonic_timer_new(). + */ +EVENT2_EXPORT_SYMBOL +void evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer); + +/** Set up a struct evutil_monotonic_timer; flags can include + * EV_MONOT_PRECISE and EV_MONOT_FALLBACK. + */ +EVENT2_EXPORT_SYMBOL +int evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer, + int flags); + +/** Query the current monotonic time from a struct evutil_monotonic_timer + * previously configured with evutil_configure_monotonic_time(). Monotonic + * time is guaranteed never to run in reverse, but is not necessarily epoch- + * based, or relative to any other definite point. Use it to make reliable + * measurements of elapsed time between events even when the system time + * may be changed. + * + * It is not safe to use this funtion on the same timer from multiple + * threads. + */ +EVENT2_EXPORT_SYMBOL +int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer, + struct timeval *tp); + /** Create two new sockets that are connected to each other. On Unix, this simply calls socketpair(). On Windows, it uses the @@ -386,14 +386,14 @@ int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer, Parameters and return values are as for socketpair() */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_socketpair(int d, int type, int protocol, evutil_socket_t sv[2]); /** Do platform-specific operations as needed to make a socket nonblocking. @param sock The socket to make nonblocking @return 0 on success, -1 on failure */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_make_socket_nonblocking(evutil_socket_t sock); /** Do platform-specific operations to make a listener socket reusable. @@ -407,82 +407,82 @@ int evutil_make_socket_nonblocking(evutil_socket_t sock); @param sock The socket to make reusable @return 0 on success, -1 on failure */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_make_listen_socket_reuseable(evutil_socket_t sock); -/** Do platform-specific operations to make a listener port reusable. - - Specifically, we want to make sure that multiple programs which also - set the same socket option will be able to bind, listen at the same time. - - This is a feature available only to Linux 3.9+ - - @param sock The socket to make reusable - @return 0 on success, -1 on failure - */ -EVENT2_EXPORT_SYMBOL -int evutil_make_listen_socket_reuseable_port(evutil_socket_t sock); - -/** Set ipv6 only bind socket option to make listener work only in ipv6 sockets. - - According to RFC3493 and most Linux distributions, default value for the - sockets is to work in IPv4-mapped mode. In IPv4-mapped mode, it is not possible - to bind same port from different IPv4 and IPv6 handlers. - - @param sock The socket to make in ipv6only working mode - @return 0 on success, -1 on failure - */ -EVENT2_EXPORT_SYMBOL -int evutil_make_listen_socket_ipv6only(evutil_socket_t sock); - +/** Do platform-specific operations to make a listener port reusable. + + Specifically, we want to make sure that multiple programs which also + set the same socket option will be able to bind, listen at the same time. + + This is a feature available only to Linux 3.9+ + + @param sock The socket to make reusable + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_listen_socket_reuseable_port(evutil_socket_t sock); + +/** Set ipv6 only bind socket option to make listener work only in ipv6 sockets. + + According to RFC3493 and most Linux distributions, default value for the + sockets is to work in IPv4-mapped mode. In IPv4-mapped mode, it is not possible + to bind same port from different IPv4 and IPv6 handlers. + + @param sock The socket to make in ipv6only working mode + @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int evutil_make_listen_socket_ipv6only(evutil_socket_t sock); + /** Do platform-specific operations as needed to close a socket upon a successful execution of one of the exec*() functions. @param sock The socket to be closed @return 0 on success, -1 on failure */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_make_socket_closeonexec(evutil_socket_t sock); /** Do the platform-specific call needed to close a socket returned from socket() or accept(). @param sock The socket to be closed - @return 0 on success (whether the operation is supported or not), - -1 on failure + @return 0 on success (whether the operation is supported or not), + -1 on failure */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_closesocket(evutil_socket_t sock); #define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s) -/** Do platform-specific operations, if possible, to make a tcp listener - * socket defer accept()s until there is data to read. - * - * Not all platforms support this. You don't want to do this for every - * listener socket: only the ones that implement a protocol where the - * client transmits before the server needs to respond. - * - * @param sock The listening socket to to make deferred - * @return 0 on success (whether the operation is supported or not), - * -1 on failure -*/ -EVENT2_EXPORT_SYMBOL -int evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock); - -#ifdef _WIN32 +/** Do platform-specific operations, if possible, to make a tcp listener + * socket defer accept()s until there is data to read. + * + * Not all platforms support this. You don't want to do this for every + * listener socket: only the ones that implement a protocol where the + * client transmits before the server needs to respond. + * + * @param sock The listening socket to to make deferred + * @return 0 on success (whether the operation is supported or not), + * -1 on failure +*/ +EVENT2_EXPORT_SYMBOL +int evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock); + +#ifdef _WIN32 /** Return the most recent socket error. Not idempotent on all platforms. */ #define EVUTIL_SOCKET_ERROR() WSAGetLastError() /** Replace the most recent socket error with errcode */ #define EVUTIL_SET_SOCKET_ERROR(errcode) \ do { WSASetLastError(errcode); } while (0) /** Return the most recent socket error to occur on sock. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_socket_geterror(evutil_socket_t sock); /** Convert a socket error to a string. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL const char *evutil_socket_error_to_string(int errcode); -#define EVUTIL_INVALID_SOCKET INVALID_SOCKET -#elif defined(EVENT_IN_DOXYGEN_) +#define EVUTIL_INVALID_SOCKET INVALID_SOCKET +#elif defined(EVENT_IN_DOXYGEN_) /** @name Socket error functions @@ -505,16 +505,16 @@ const char *evutil_socket_error_to_string(int errcode); #define evutil_socket_geterror(sock) ... /** Convert a socket error to a string. */ #define evutil_socket_error_to_string(errcode) ... -#define EVUTIL_INVALID_SOCKET -1 +#define EVUTIL_INVALID_SOCKET -1 /**@}*/ -#else /** !EVENT_IN_DOXYGEN_ && !_WIN32 */ +#else /** !EVENT_IN_DOXYGEN_ && !_WIN32 */ #define EVUTIL_SOCKET_ERROR() (errno) #define EVUTIL_SET_SOCKET_ERROR(errcode) \ do { errno = (errcode); } while (0) #define evutil_socket_geterror(sock) (errno) #define evutil_socket_error_to_string(errcode) (strerror(errcode)) -#define EVUTIL_INVALID_SOCKET -1 -#endif /** !_WIN32 */ +#define EVUTIL_INVALID_SOCKET -1 +#endif /** !_WIN32 */ /** @@ -525,7 +525,7 @@ const char *evutil_socket_error_to_string(int errcode); * * @{ */ -#ifdef EVENT__HAVE_TIMERADD +#ifdef EVENT__HAVE_TIMERADD #define evutil_timeradd(tvp, uvp, vvp) timeradd((tvp), (uvp), (vvp)) #define evutil_timersub(tvp, uvp, vvp) timersub((tvp), (uvp), (vvp)) #else @@ -547,9 +547,9 @@ const char *evutil_socket_error_to_string(int errcode); (vvp)->tv_usec += 1000000; \ } \ } while (0) -#endif /* !EVENT__HAVE_TIMERADD */ +#endif /* !EVENT__HAVE_TIMERADD */ -#ifdef EVENT__HAVE_TIMERCLEAR +#ifdef EVENT__HAVE_TIMERCLEAR #define evutil_timerclear(tvp) timerclear(tvp) #else #define evutil_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 @@ -563,7 +563,7 @@ const char *evutil_socket_error_to_string(int errcode); ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#ifdef EVENT__HAVE_TIMERISSET +#ifdef EVENT__HAVE_TIMERISSET #define evutil_timerisset(tvp) timerisset(tvp) #else #define evutil_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) @@ -578,22 +578,22 @@ const char *evutil_socket_error_to_string(int errcode); /* big-int related functions */ /** Parse a 64-bit value from a string. Arguments are as for strtol. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL ev_int64_t evutil_strtoll(const char *s, char **endptr, int base); /** Replacement for gettimeofday on platforms that lack it. */ -#ifdef EVENT__HAVE_GETTIMEOFDAY +#ifdef EVENT__HAVE_GETTIMEOFDAY #define evutil_gettimeofday(tv, tz) gettimeofday((tv), (tz)) #else struct timezone; -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_gettimeofday(struct timeval *tv, struct timezone *tz); #endif /** Replacement for snprintf to get consistent behavior on platforms for which the return value of snprintf does not conform to C99. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) #ifdef __GNUC__ __attribute__((format(printf, 3, 4))) @@ -602,7 +602,7 @@ int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) /** Replacement for vsnprintf to get consistent behavior on platforms for which the return value of snprintf does not conform to C99. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) #ifdef __GNUC__ __attribute__((format(printf, 3, 0))) @@ -610,7 +610,7 @@ int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) ; /** Replacement for inet_ntop for platforms which lack it. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len); /** Variation of inet_pton that also parses IPv6 scopes. Public for unit tests. No reason to call this directly. @@ -619,7 +619,7 @@ EVENT2_EXPORT_SYMBOL int evutil_inet_pton_scope(int af, const char *src, void *dst, unsigned *indexp); /** Replacement for inet_pton for platforms which lack it. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_inet_pton(int af, const char *src, void *dst); struct sockaddr; @@ -643,7 +643,7 @@ struct sockaddr; or if out is not large enough to hold the result. Otherwise returns 0 on success. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_parse_sockaddr_port(const char *str, struct sockaddr *out, int *outlen); /** Compare two sockaddrs; return 0 if they are equal, or less than 0 if sa1 @@ -651,24 +651,24 @@ int evutil_parse_sockaddr_port(const char *str, struct sockaddr *out, int *outle * true, consider the port as well as the address. Only implemented for * AF_INET and AF_INET6 addresses. The ordering is not guaranteed to remain * the same between Libevent versions. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_sockaddr_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2, int include_port); /** As strcasecmp, but always compares the characters in locale-independent ASCII. That's useful if you're handling data in ASCII-based protocols. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_ascii_strcasecmp(const char *str1, const char *str2); /** As strncasecmp, but always compares the characters in locale-independent ASCII. That's useful if you're handling data in ASCII-based protocols. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_ascii_strncasecmp(const char *str1, const char *str2, size_t n); /* Here we define evutil_addrinfo to the native addrinfo type, or redefine it * if this system has no getaddrinfo(). */ -#ifdef EVENT__HAVE_STRUCT_ADDRINFO +#ifdef EVENT__HAVE_STRUCT_ADDRINFO #define evutil_addrinfo addrinfo #else /** A definition of struct addrinfo for systems that lack it. @@ -694,32 +694,32 @@ struct evutil_addrinfo { @{ */ -#if defined(EAI_ADDRFAMILY) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_ADDRFAMILY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_ADDRFAMILY EAI_ADDRFAMILY #else #define EVUTIL_EAI_ADDRFAMILY -901 #endif -#if defined(EAI_AGAIN) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_AGAIN) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_AGAIN EAI_AGAIN #else #define EVUTIL_EAI_AGAIN -902 #endif -#if defined(EAI_BADFLAGS) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_BADFLAGS) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_BADFLAGS EAI_BADFLAGS #else #define EVUTIL_EAI_BADFLAGS -903 #endif -#if defined(EAI_FAIL) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_FAIL) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_FAIL EAI_FAIL #else #define EVUTIL_EAI_FAIL -904 #endif -#if defined(EAI_FAMILY) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_FAMILY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_FAMILY EAI_FAMILY #else #define EVUTIL_EAI_FAMILY -905 #endif -#if defined(EAI_MEMORY) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_MEMORY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_MEMORY EAI_MEMORY #else #define EVUTIL_EAI_MEMORY -906 @@ -727,27 +727,27 @@ struct evutil_addrinfo { /* This test is a bit complicated, since some MS SDKs decide to * remove NODATA or redefine it to be the same as NONAME, in a * fun interpretation of RFC 2553 and RFC 3493. */ -#if defined(EAI_NODATA) && defined(EVENT__HAVE_GETADDRINFO) && (!defined(EAI_NONAME) || EAI_NODATA != EAI_NONAME) +#if defined(EAI_NODATA) && defined(EVENT__HAVE_GETADDRINFO) && (!defined(EAI_NONAME) || EAI_NODATA != EAI_NONAME) #define EVUTIL_EAI_NODATA EAI_NODATA #else #define EVUTIL_EAI_NODATA -907 #endif -#if defined(EAI_NONAME) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_NONAME) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_NONAME EAI_NONAME #else #define EVUTIL_EAI_NONAME -908 #endif -#if defined(EAI_SERVICE) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_SERVICE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SERVICE EAI_SERVICE #else #define EVUTIL_EAI_SERVICE -909 #endif -#if defined(EAI_SOCKTYPE) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_SOCKTYPE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SOCKTYPE EAI_SOCKTYPE #else #define EVUTIL_EAI_SOCKTYPE -910 #endif -#if defined(EAI_SYSTEM) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(EAI_SYSTEM) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SYSTEM EAI_SYSTEM #else #define EVUTIL_EAI_SYSTEM -911 @@ -755,37 +755,37 @@ struct evutil_addrinfo { #define EVUTIL_EAI_CANCEL -90001 -#if defined(AI_PASSIVE) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_PASSIVE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_PASSIVE AI_PASSIVE #else #define EVUTIL_AI_PASSIVE 0x1000 #endif -#if defined(AI_CANONNAME) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_CANONNAME) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_CANONNAME AI_CANONNAME #else #define EVUTIL_AI_CANONNAME 0x2000 #endif -#if defined(AI_NUMERICHOST) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_NUMERICHOST) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_NUMERICHOST AI_NUMERICHOST #else #define EVUTIL_AI_NUMERICHOST 0x4000 #endif -#if defined(AI_NUMERICSERV) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_NUMERICSERV) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_NUMERICSERV AI_NUMERICSERV #else #define EVUTIL_AI_NUMERICSERV 0x8000 #endif -#if defined(AI_V4MAPPED) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_V4MAPPED) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_V4MAPPED AI_V4MAPPED #else #define EVUTIL_AI_V4MAPPED 0x10000 #endif -#if defined(AI_ALL) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_ALL) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_ALL AI_ALL #else #define EVUTIL_AI_ALL 0x20000 #endif -#if defined(AI_ADDRCONFIG) && defined(EVENT__HAVE_GETADDRINFO) +#if defined(AI_ADDRCONFIG) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_ADDRCONFIG AI_ADDRCONFIG #else #define EVUTIL_AI_ADDRCONFIG 0x40000 @@ -804,15 +804,15 @@ struct evutil_addrinfo; * * For a nonblocking variant, see evdns_getaddrinfo. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_getaddrinfo(const char *nodename, const char *servname, const struct evutil_addrinfo *hints_in, struct evutil_addrinfo **res); /** Release storage allocated by evutil_getaddrinfo or evdns_getaddrinfo. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL void evutil_freeaddrinfo(struct evutil_addrinfo *ai); -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL const char *evutil_gai_strerror(int err); /** Generate n bytes of secure pseudorandom data, and store them in buf. @@ -824,7 +824,7 @@ const char *evutil_gai_strerror(int err); * provides only rudimentary prediction- and backtracking-resistance. Don't * use this for serious cryptographic applications. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL void evutil_secure_rng_get_bytes(void *buf, size_t n); /** @@ -843,7 +843,7 @@ void evutil_secure_rng_get_bytes(void *buf, size_t n); * whatever), and you want to make sure that seeding happens before your * program loses the ability to do it. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_secure_rng_init(void); /** @@ -859,10 +859,10 @@ int evutil_secure_rng_init(void); * * This API is unstable, and might change in a future libevent version. */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL int evutil_secure_rng_set_urandom_device_file(char *fname); -#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) +#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) /** Seed the random number generator with extra random bytes. You should almost never need to call this function; it should be @@ -877,12 +877,12 @@ int evutil_secure_rng_set_urandom_device_file(char *fname); @param dat a buffer full of a strong source of random numbers @param datlen the number of bytes to read from datlen */ -EVENT2_EXPORT_SYMBOL +EVENT2_EXPORT_SYMBOL void evutil_secure_rng_add_bytes(const char *dat, size_t datlen); -#endif +#endif #ifdef __cplusplus } #endif -#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ +#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ |