if (WIN32 OR APPLE)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
else()
- cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
+ cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(EVENT_VERSION
"${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-${EVENT_STAGE_NAME}")
-option(EVENT__BUILD_SHARED_LIBRARIES
- "Define if libevent should be built with shared libraries instead of archives" OFF)
-
option(EVENT__DISABLE_DEBUG_MODE
"Define if libevent should build without support for a debug mode" OFF)
include_directories(${OPENSSL_INCLUDE_DIR})
- list(APPEND SRC_CORE bufferevent_openssl.c)
+ list(APPEND SRC_OPENSSL bufferevent_openssl.c)
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
list(APPEND LIB_APPS ${OPENSSL_LIBRARIES})
endif()
find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR
- "Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to disable")
+ "Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to disable")
endif()
set(EVENT__HAVE_PTHREADS 1)
- list(APPEND SRC_CORE evthread_pthread.c)
list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
include_directories(./WIN32-Code)
endif()
-if (UNIX)
- list(APPEND LIB_PLATFORM m)
-endif()
-
if (SOLARIS)
list(APPEND LIB_PLATFORM socket nsl)
endif()
# (Place them in the build dir so we don't polute the source tree with generated files).
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include)
-if (EVENT__BUILD_SHARED_LIBRARIES)
- set(EVENT__LIBRARY_TYPE SHARED)
-
- if ((CMAKE_COMPILER_IS_GNUCC) OR (${CMAKE_C_COMPILER_ID} STREQUAL "Clang"))
- add_compiler_flags(-fvisibility=hidden)
- elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
- add_compiler_flags(-xldscope=hidden)
- endif()
-
- set(EVENT__NEED_DLLIMPORT 1)
-else (EVENT__BUILD_SHARED_LIBRARIES)
- set(EVENT__LIBRARY_TYPE STATIC)
-endif (EVENT__BUILD_SHARED_LIBRARIES)
+if ((CMAKE_COMPILER_IS_GNUCC) OR
+ (${CMAKE_C_COMPILER_ID} STREQUAL "Clang") OR
+ (${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang"))
+ set(EVENT_SHARED_FLAGS -fvisibility=hidden)
+elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
+ set(EVENT_SHARED_FLAGS -xldscope=hidden)
+endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake
#
# Create the libraries.
#
+include(AddEventLibrary)
+add_event_library(event_core SOURCES ${SRC_CORE})
+add_event_library(event_extra
+ LIBRARIES event_core_shared
+ SOURCES ${SRC_EXTRA})
-# TODO: Add dynamic versions of the libraries as well.
-add_library(event_core ${EVENT__LIBRARY_TYPE}
- ${HDR_PRIVATE}
- ${HDR_COMPAT}
- ${HDR_PUBLIC}
- ${SRC_CORE})
+if (NOT EVENT__DISABLE_OPENSSL)
+ add_event_library(event_openssl
+ LIBRARIES event_core_shared ${OPENSSL_LIBRARIES}
+ SOURCES ${SRC_OPENSSL})
+endif()
-add_library(event_extra ${EVENT__LIBRARY_TYPE}
- ${HDR_PRIVATE}
- ${HDR_COMPAT}
- ${HDR_PUBLIC}
- ${SRC_CORE}
- ${SRC_EXTRA})
+if (CMAKE_USE_PTHREADS_INIT)
+ set(SRC_PTHREADS evthread_pthread.c)
+ add_event_library(event_pthreads
+ LIBRARIES event_core_shared
+ SOURCES ${SRC_PTHREADS})
+endif()
# library exists for historical reasons; it contains the contents of
# both libevent_core and libevent_extra. You shouldn’t use it; it may
# go away in a future version of Libevent.
-add_library(event ${EVENT__LIBRARY_TYPE}
- ${HDR_PRIVATE}
- ${HDR_COMPAT}
- ${HDR_PUBLIC}
- ${SRC_CORE}
- ${SRC_EXTRA})
-
-if (EVENT__BUILD_SHARED_LIBRARIES)
- # Prepare static library to be linked to tests that need hidden symbols
- add_library(event_extra_static STATIC
- ${HDR_PRIVATE}
- ${HDR_COMPAT}
- ${HDR_PUBLIC}
- ${SRC_CORE}
- ${SRC_EXTRA})
-
- set(EVENT_EXTRA_FOR_TEST event_extra_static)
-
- target_link_libraries(event_core ${OPENSSL_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- ${LIB_PLATFORM})
-
- target_link_libraries(event ${OPENSSL_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- ${LIB_PLATFORM})
-
- target_link_libraries(event_extra ${OPENSSL_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- ${LIB_PLATFORM})
-
- set_target_properties(event
- PROPERTIES SOVERSION
- ${EVENT_ABI_LIBVERSION})
-
- set_target_properties(event_core
- PROPERTIES SOVERSION
- ${EVENT_ABI_LIBVERSION})
-
- set_target_properties(event_extra
- PROPERTIES SOVERSION
- ${EVENT_ABI_LIBVERSION})
-
-else (EVENT__BUILD_SHARED_LIBRARIES)
- set(EVENT_EXTRA_FOR_TEST event_extra)
-endif (EVENT__BUILD_SHARED_LIBRARIES)
+add_event_library(event SOURCES ${SRC_CORE} ${SRC_EXTRA})
#
# Samples.
#
-
+macro(add_sample_prog ssl name)
+ add_executable(${name} ${ARGN})
+
+ target_link_libraries(${name}
+ event_extra_static
+ event_core_static
+ ${LIB_APPS}
+ ${LIB_PLATFORM})
+ add_dependencies(${name}
+ event_core_static
+ event_extra_static)
+
+ if (${ssl})
+ target_link_libraries(${name} event_openssl_static)
+ add_dependencies(${name} event_openssl_static)
+ endif()
+endmacro()
if (NOT EVENT__DISABLE_SAMPLES)
set(SAMPLES
dns-example
http-connect
time-test)
- if (NOT EVENT__DISABLE_OPENSSL AND OPENSSL_LIBRARIES)
- # Special sample with more than one file.
- add_executable(https-client
- sample/https-client.c
- sample/openssl_hostname_validation.c
- sample/hostcheck.c)
-
- target_link_libraries(https-client
- event_extra
- ${LIB_APPS}
- ${LIB_PLATFORM})
-
- add_dependencies(https-client event_extra)
-
- # Requires OpenSSL.
- list(APPEND SAMPLES le-proxy)
- endif()
-
foreach(SAMPLE ${SAMPLES})
- add_executable(${SAMPLE}
- sample/${SAMPLE}.c)
-
- target_link_libraries(${SAMPLE}
- event_extra
- ${LIB_APPS}
- ${LIB_PLATFORM})
-
- add_dependencies(${SAMPLE} event_extra)
+ add_sample_prog(OFF ${SAMPLE} sample/${SAMPLE}.c)
endforeach()
+ if (NOT EVENT__DISABLE_OPENSSL)
+ add_sample_prog(ON https-client
+ sample/https-client.c
+ sample/openssl_hostname_validation.c
+ sample/hostcheck.c)
+ add_sample_prog(ON le-proxy
+ sample/le-proxy.c)
+ endif()
+
if (WIN32)
+ # requires cmake 3.1
target_sources(dns-example PUBLIC
WIN32-Code/getopt.c
WIN32-Code/getopt_long.c)
endif()
endif()
+#
+# Benchmarks
+#
+macro(add_bench_prog prog)
+ add_executable(${prog} test/${prog}.c)
+ if (WIN32)
+ list(APPEND BENCH_SRC
+ WIN32-Code/getopt.c
+ WIN32-Code/getopt_long.c)
+ endif()
+ target_link_libraries(${BENCHMARK}
+ event_extra_static
+ event_core_static
+ ${LIB_APPS}
+ ${LIB_PLATFORM})
+ add_dependencies(${BENCHMARK}
+ event_extra_static
+ event_core_static)
+endmacro()
if (NOT EVENT__DISABLE_BENCHMARK)
foreach (BENCHMARK bench bench_cascade bench_http bench_httpclient)
- set(BENCH_SRC test/${BENCHMARK}.c)
-
- if (WIN32)
- list(APPEND BENCH_SRC
- WIN32-Code/getopt.c
- WIN32-Code/getopt_long.c)
- endif()
-
- add_executable(${BENCHMARK} ${BENCH_SRC})
-
- target_link_libraries(${BENCHMARK}
- event_extra
- ${LIB_PLATFORM})
-
- add_dependencies(${BENCHMARK} event_extra)
+ add_bench_prog(${BENCHMARK})
endforeach()
endif()
+#
+# Tests
+#
+macro(add_test_prog prog)
+ add_executable(${prog} test/${prog}.c)
+ target_link_libraries(${prog}
+ ${LIB_APPS}
+ ${LIB_PLATFORM}
+ event_core_shared
+ event_extra_shared
+ ${ARGN})
+ add_dependencies(${prog}
+ event_core_shared
+ event_extra_shared)
+endmacro()
if (NOT EVENT__DISABLE_TESTS)
#
# Generate Regress tests.
#
if (NOT EVENT__DISABLE_REGRESS)
-
# (We require python2 to generate the regress tests)
foreach (PY python2.6 python2.7 python2)
unset(FIND_PYTHON2 CACHE)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
list(APPEND SRC_REGRESS
- test/regress.c
- test/regress.gen.c
- test/regress.gen.h
- test/regress_buffer.c
- test/regress_bufferevent.c
- test/regress_dns.c
- test/regress_et.c
- test/regress_finalize.c
- test/regress_http.c
- test/regress_listener.c
- test/regress_main.c
- test/regress_minheap.c
- test/regress_rpc.c
- test/regress_testutils.c
- test/regress_testutils.h
- test/regress_util.c
- test/tinytest.c
- ${SRC_CORE}
- ${SRC_EXTRA})
+ test/regress.c
+ test/regress.gen.c
+ test/regress.gen.h
+ test/regress_buffer.c
+ test/regress_bufferevent.c
+ test/regress_dns.c
+ test/regress_et.c
+ test/regress_finalize.c
+ test/regress_http.c
+ test/regress_listener.c
+ test/regress_main.c
+ test/regress_minheap.c
+ test/regress_rpc.c
+ test/regress_testutils.c
+ test/regress_testutils.h
+ test/regress_util.c
+ test/tinytest.c)
if (WIN32)
list(APPEND SRC_REGRESS test/regress_iocp.c)
if (NOT EVENT__DISABLE_THREAD_SUPPORT)
list(APPEND SRC_REGRESS test/regress_thread.c)
endif()
- endif()
-
- if (CMAKE_USE_PTHREADS_INIT)
+ elseif (CMAKE_USE_PTHREADS_INIT)
list(APPEND SRC_REGRESS test/regress_thread.c)
endif()
list(APPEND SRC_REGRESS test/regress_zlib.c)
endif()
- if (OPENSSL_LIBRARIES)
+ if (NOT EVENT__DISABLE_OPENSSL)
list(APPEND SRC_REGRESS test/regress_ssl.c)
endif()
# header trying to "dllimport" the symbols on windows (it
# generates a ton of warnings due to different link
# attributes for all of the symbols)
- SET_TARGET_PROPERTIES(regress
- PROPERTIES COMPILE_DEFINITIONS
- "EVENT_BUILDING_REGRESS_TEST=1")
+ set_target_properties(regress
+ PROPERTIES COMPILE_DEFINITIONS
+ "EVENT_BUILDING_REGRESS_TEST=1")
target_link_libraries(regress
- ${LIB_APPS}
- ${LIB_PLATFORM})
+ ${LIB_APPS}
+ ${LIB_PLATFORM}
+ event_core_shared
+ event_extra_static)
+ if (NOT EVENT__DISABLE_OPENSSL)
+ target_link_libraries(regress event_openssl_shared)
+ endif()
+ if (CMAKE_USE_PTHREADS_INIT)
+ target_link_libraries(regress event_pthreads_shared)
+ endif()
else()
message(WARNING "No suitable Python interpreter found, cannot generate regress tests!")
endif()
#
# Test programs.
#
- # all of these, including the cmakelists.txt should be moved
- # into the dirctory 'tests' first.
- #
- # doing this, we can remove all the DISABLE_TESTS stuff, and simply
- # do something like:
- #
- # add_custom_targets(tests)
- # add_executable(... EXCLUDE_FROM_ALL ...c)
- # add_dependencis(tests testa testb testc)
- # add_test(....)
- #
- # then you can just run 'make tests' instead of them all
- # auto-compile|running
- # - ellzey
- set(TESTPROGS test-changelist
- test-eof
- test-fdleak
- test-init
- test-time
- test-weof)
+ # all of these, including the cmakelists.txt should be moved
+ # into the dirctory 'tests' first.
+ #
+ # doing this, we can remove all the DISABLE_TESTS stuff, and simply
+ # do something like:
+ #
+ # add_custom_targets(tests)
+ # add_executable(... EXCLUDE_FROM_ALL ...c)
+ # add_dependencis(tests testa testb testc)
+ # add_test(....)
+ #
+ # then you can just run 'make tests' instead of them all
+ # auto-compile|running
+ # - ellzey
+ set(TESTPROGS test-changelist
+ test-eof
+ test-fdleak
+ test-init
+ test-time
+ test-weof)
+
+ foreach (TESTPROG ${TESTPROGS} test-dumpevents)
+ add_test_prog(${TESTPROG})
+ endforeach()
+ if (UNIX)
+ add_test_prog(test-ratelim m)
+ else()
+ add_test_prog(test-ratelim)
+ endif()
set(ALL_TESTPROGS
- ${TESTPROGS}
- test-dumpevents
- test-ratelim)
-
- # Create test program executables.
- foreach (TESTPROG ${ALL_TESTPROGS})
- add_executable(${TESTPROG}
- test/${TESTPROG}.c)
-
- target_link_libraries(${TESTPROG}
- ${EVENT_EXTRA_FOR_TEST}
- ${LIB_PLATFORM})
-
- add_dependencies(${TESTPROG}
- ${EVENT_EXTRA_FOR_TEST})
- endforeach()
+ ${TESTPROGS}
+ test-dumpevents
+ test-ratelim
+ )
#
# We run all tests with the different backends turned on one at a time.
set(TEST_NAME ${TESTPROG}__${BACKEND_TEST_NAME})
add_test(${TEST_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG})
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG})
list(APPEND TEST_NAMES ${TEST_NAME})
set_tests_properties(${TEST_NAME}
- PROPERTIES ENVIRONMENT "${ENV_VARS}")
+ PROPERTIES ENVIRONMENT "${ENV_VARS}")
endforeach()
# Dump events test.
set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME})
add_test(${TEST_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents |
- ${PYTHON_EXECUTABLE}
- ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py)
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents |
+ ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py)
set_tests_properties(${TEST_NAME}
- PROPERTIES ENVIRONMENT "${ENV_VARS}")
+ PROPERTIES ENVIRONMENT "${ENV_VARS}")
else()
message(WARNING "test-dumpevents will be run without output check since python was not found!")
set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}_no_check)
add_test(${TEST_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents)
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents)
set_tests_properties(${TEST_NAME}
- PROPERTIES ENVIRONMENT "${ENV_VARS}")
+ PROPERTIES ENVIRONMENT "${ENV_VARS}")
endif()
# Regress tests.
set(TEST_NAME regress__${BACKEND_TEST_NAME})
add_test(${TEST_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
set_tests_properties(${TEST_NAME}
- PROPERTIES ENVIRONMENT "${ENV_VARS}")
+ PROPERTIES ENVIRONMENT "${ENV_VARS}")
add_test(${TEST_NAME}_debug
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress)
set_tests_properties(${TEST_NAME}_debug
- PROPERTIES ENVIRONMENT "${ENV_VARS};EVENT_DEBUG_MODE=1")
+ PROPERTIES ENVIRONMENT "${ENV_VARS};EVENT_DEBUG_MODE=1")
endif()
endmacro()
#
# Group limits, no connection limit.
- set(RL_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim)
+ set(RL_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim)
add_test(test-ratelim__group_lim
- ${RL_BIN}
- -g 30000
- -n 30
- -t 100
- --check-grouplimit 1000
- --check-stddev 100)
+ ${RL_BIN}
+ -g 30000
+ -n 30
+ -t 100
+ --check-grouplimit 1000
+ --check-stddev 100)
# Connection limit, no group limit.
add_test(test-ratelim__con_lim
- ${RL_BIN}
- -c 1000
- -n 30
- -t 100
- --check-connlimit 50
- --check-stddev 50)
+ ${RL_BIN}
+ -c 1000
+ -n 30
+ -t 100
+ --check-connlimit 50
+ --check-stddev 50)
# Connection limit and group limit.
add_test(test-ratelim__group_con_lim
- ${RL_BIN}
- -c 1000
- -g 30000
- -n 30
- -t 100
- --check-grouplimit 1000
- --check-connlimit 50
- --check-stddev 50)
+ ${RL_BIN}
+ -c 1000
+ -g 30000
+ -n 30
+ -t 100
+ --check-grouplimit 1000
+ --check-connlimit 50
+ --check-stddev 50)
# Connection limit and group limit with independent drain.
add_test(test-ratelim__group_con_lim_drain
- ${RL_BIN}
- -c 1000
- -g 35000
- -n 30
- -t 100
- -G 500
- --check-grouplimit 1000
- --check-connlimit 50
- --check-stddev 50)
+ ${RL_BIN}
+ -c 1000
+ -g 35000
+ -n 30
+ -t 100
+ -G 500
+ --check-grouplimit 1000
+ --check-connlimit 50
+ --check-stddev 50)
# Add a "make verify" target, same as for autoconf.
# (Important! This will unset all EVENT_NO* environment variables.
message(STATUS "${WINDOWS_CTEST_COMMAND}")
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.bat
- DESTINATION
- ${CMAKE_CURRENT_BINARY_DIR}
- FILE_PERMISSIONS
- OWNER_READ
- OWNER_WRITE
- OWNER_EXECUTE
- GROUP_READ
- GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE)
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ FILE_PERMISSIONS
+ OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
file(TO_NATIVE_PATH
"${CMAKE_CURRENT_BINARY_DIR}/verify_tests.bat" VERIFY_PATH)
add_custom_target(verify COMMAND "${VERIFY_PATH}"
- DEPENDS event ${ALL_TESTPROGS})
+ DEPENDS event ${ALL_TESTPROGS})
else()
# On some platforms doing exec(unset) as CMake does won't work, so make sure
# we run the unset command in a shell instead.
# Then we copy the file (this allows us to set execute permission on it)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh
- DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
- FILE_PERMISSIONS
- OWNER_READ
- OWNER_WRITE
- OWNER_EXECUTE
- GROUP_READ
- GROUP_EXECUTE
- WORLD_READ
- WORLD_EXECUTE)
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ FILE_PERMISSIONS
+ OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ GROUP_EXECUTE
+ WORLD_READ
+ WORLD_EXECUTE)
# Create the target that runs the script.
add_custom_target(verify
- COMMAND
- ${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh
- DEPENDS
- event
- ${ALL_TESTPROGS})
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh
+ DEPENDS event ${ALL_TESTPROGS})
endif()
if (NOT EVENT__DISABLE_REGRESS AND __FOUND_USABLE_PYTHON)
# Installation preparation.
#
-# Allow the user to override installation directories.
-set(EVENT_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
-set(EVENT_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
-set(EVENT_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
-
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR cmake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/libevent)
endif()
-set(EVENT_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
-
-# Make sure the paths are absolute.
-foreach(p LIB BIN INCLUDE CMAKE)
- set(var EVENT_INSTALL_${p}_DIR)
- if(NOT IS_ABSOLUTE "${${var}}")
- set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
- endif()
-endforeach()
+set(EVENT_INSTALL_CMAKE_DIR
+ "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}"
+ CACHE PATH "Installation directory for CMake files")
-# Export targets (This is used for other CMake projects to easily find the libraries and include files).
-export(TARGETS event event_extra event_core
- FILE "${PROJECT_BINARY_DIR}/LibeventTargets.cmake")
export(PACKAGE libevent)
# Generate the config file for the build-tree.
CACHE PATH "Libevent include directories")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigBuildTree.cmake.in
- ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
- @ONLY)
+ ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
+ @ONLY)
# Generate the config file for the installation tree.
+# Calculate the relative directory from the Cmake dir.
file(RELATIVE_PATH
- REL_INCLUDE_DIR
- "${EVENT_INSTALL_CMAKE_DIR}"
- "${EVENT_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir.
+ REL_INCLUDE_DIR
+ "${EVENT_INSTALL_CMAKE_DIR}"
+ "${CMAKE_INSTALL_PREFIX}/include")
# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in,
# we escape it here so it's evaluated when it is included instead
# so that the include dirs are givenrelative to where the
# config file is located.
-set(EVENT__INCLUDE_DIRS
- "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
+set(EVENT__INCLUDE_DIRS "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in
- ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
- @ONLY)
+ ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
+ @ONLY)
# Generate version info for both build-tree and install-tree.
configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in
- ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
- @ONLY)
-
-# Define the public headers.
-set_target_properties(event event_core event_extra
- PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}")
-
-#
-# Install targets.
-#
-install(TARGETS event event_core event_extra
- EXPORT LibeventTargets
- RUNTIME DESTINATION "${EVENT_INSTALL_BIN_DIR}" COMPONENT bin
- LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
- ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
- PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev)
+ ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
+ @ONLY)
# Install compat headers
install(FILES ${HDR_COMPAT}
- DESTINATION
- "${EVENT_INSTALL_INCLUDE_DIR}"
- COMPONENT dev)
+ DESTINATION "include"
+ COMPONENT dev)
# Install the configs.
install(FILES
- ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
- ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
- DESTINATION
- "${EVENT_INSTALL_CMAKE_DIR}"
+ ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
+ ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
+ DESTINATION "${EVENT_INSTALL_CMAKE_DIR}"
COMPONENT dev)
# Install exports for the install-tree.
install(EXPORT LibeventTargets
- DESTINATION
- "${EVENT_INSTALL_CMAKE_DIR}"
- COMPONENT dev)
-
-set(LIBEVENT_LIBRARIES
- event
- event_core
- event_extra
- CACHE STRING "Libevent libraries")
+ DESTINATION "${DEF_INSTALL_CMAKE_DIR}"
+ COMPONENT dev)
message(STATUS "")
message(STATUS " ---( Libevent " ${EVENT_VERSION} " )---")
the default).
```
-# Installation directory for executables
-EVENT_INSTALL_BIN_DIR:PATH=bin
-
# Installation directory for CMake files
EVENT_INSTALL_CMAKE_DIR:PATH=lib/cmake/libevent
-## Installation directory for header files
-EVENT_INSTALL_INCLUDE_DIR:PATH=include
-
-## Installation directory for libraries
-EVENT_INSTALL_LIB_DIR:PATH=lib
-
-## Define if libevent should be built with shared libraries instead of archives
-EVENT__BUILD_SHARED_LIBRARIES:BOOL=OFF
-
# Enable running gcov to get a test coverage report (only works with
# GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well.
EVENT__COVERAGE:BOOL=OFF
#endif
/** Initialize the shared parts of a bufferevent. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_init_common_(struct bufferevent_private *, struct event_base *, const struct bufferevent_ops *, enum bufferevent_options options);
/** For internal use: temporarily stop all reads on bufev, until the conditions
* in 'what' are over. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
/** For internal use: clear the conditions 'what' on bufev, and re-enable
* reading if there are no conditions left. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
/** For internal use: temporarily stop all writes on bufev, until the conditions
@return 0 if successful, or -1 if an error occurred
@see bufferevent_disable()
*/
+EVENT2_EXPORT_SYMBOL
int bufferevent_disable_hard_(struct bufferevent *bufev, short event);
/** Internal: Set up locking on a bufferevent. If lock is set, use it.
* Otherwise, use a new lock. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_enable_locking_(struct bufferevent *bufev, void *lock);
/** Internal: backwards compat macro for the now public function
* Increment the reference count on bufev. */
#define bufferevent_incref_(bufev) bufferevent_incref(bufev)
/** Internal: Lock bufev and increase its reference count.
* unlocking it otherwise. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_incref_and_lock_(struct bufferevent *bufev);
/** Internal: backwards compat macro for the now public function
* Decrement the reference count on bufev. Returns 1 if it freed
/** Internal: Drop the reference count on bufev, freeing as necessary, and
* unlocking it otherwise. Returns 1 if it freed the bufferevent. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_decref_and_unlock_(struct bufferevent *bufev);
/** Internal: If callbacks are deferred and we have a read callback, schedule
* a readcb. Otherwise just run the readcb. Ignores watermarks. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_run_readcb_(struct bufferevent *bufev, int options);
/** Internal: If callbacks are deferred and we have a write callback, schedule
* a writecb. Otherwise just run the writecb. Ignores watermarks. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_run_writecb_(struct bufferevent *bufev, int options);
/** Internal: If callbacks are deferred and we have an eventcb, schedule
* it to run with events "what". Otherwise just run the eventcb.
* See bufferevent_trigger_event for meaning of "options". */
+EVENT2_EXPORT_SYMBOL
void bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options);
/** Internal: Run or schedule (if deferred or options contain
/** Internal: Add the event 'ev' with timeout tv, unless tv is set to 0, in
* which case add ev with no timeout. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_add_event_(struct event *ev, const struct timeval *tv);
/* =========
/** Internal use: Set up the ev_read and ev_write callbacks so that
* the other "generic_timeout" functions will work on it. Call this from
* the constructor function. */
+EVENT2_EXPORT_SYMBOL
void bufferevent_init_generic_timeout_cbs_(struct bufferevent *bev);
/** Internal use: Add or delete the generic timeout events as appropriate.
* (If an event is enabled and a timeout is set, we add the event. Otherwise
* we delete it.) Call this from anything that changes the timeout values,
* that enabled EV_READ or EV_WRITE, or that disables EV_READ or EV_WRITE. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_generic_adj_timeouts_(struct bufferevent *bev);
+EVENT2_EXPORT_SYMBOL
int bufferevent_generic_adj_existing_timeouts_(struct bufferevent *bev);
+EVENT2_EXPORT_SYMBOL
enum bufferevent_options bufferevent_get_options_(struct bufferevent *bev);
+EVENT2_EXPORT_SYMBOL
const struct sockaddr*
bufferevent_socket_get_conn_address_(struct bufferevent *bev);
/* ==== For rate-limiting. */
+EVENT2_EXPORT_SYMBOL
int bufferevent_decrement_write_buckets_(struct bufferevent_private *bev,
ev_ssize_t bytes);
+EVENT2_EXPORT_SYMBOL
int bufferevent_decrement_read_buckets_(struct bufferevent_private *bev,
ev_ssize_t bytes);
+EVENT2_EXPORT_SYMBOL
ev_ssize_t bufferevent_get_read_max_(struct bufferevent_private *bev);
+EVENT2_EXPORT_SYMBOL
ev_ssize_t bufferevent_get_write_max_(struct bufferevent_private *bev);
int bufferevent_ratelim_init_(struct bufferevent_private *bev);
--- /dev/null
+include(CMakeParseArguments)
+
+set(LIBEVENT_SHARED_LIBRARIES "")
+set(LIBEVENT_STATIC_LIBRARIES "")
+
+macro(set_event_lib_properties LIB_NAME)
+ set_target_properties("${LIB_NAME}_static" PROPERTIES ${ARGN})
+ set_target_properties("${LIB_NAME}_shared" PROPERTIES ${ARGN})
+endmacro()
+
+macro(set_event_shared_lib_flags LIB_NAME)
+ set_target_properties("${LIB_NAME}_shared" PROPERTIES
+ COMPILE_FLAGS ${ARGN})
+ set_target_properties("${LIB_NAME}_shared" PROPERTIES
+ LINK_FLAGS ${ARGN})
+endmacro()
+
+macro(generate_pkgconfig LIB_NAME)
+ set(prefix ${CMAKE_INSTALL_PREFIX})
+ set(exec_prefix ${CMAKE_INSTALL_PREFIX})
+ set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
+ set(includedir ${CMAKE_INSTALL_PREFIX}/include)
+
+ set(VERSION ${EVENT_ABI_LIBVERSION})
+
+ set(LIBS "")
+ foreach (LIB ${LIB_PLATFORM})
+ set(OPENSSL_LIBS "${LIBS} -L${LIB}")
+ endforeach()
+
+ set(OPENSSL_LIBS "")
+ foreach(LIB ${OPENSSL_LIBRARIES})
+ set(OPENSSL_LIBS "${LIBS} -L${LIB}")
+ endforeach()
+
+ configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc"
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
+ )
+endmacro()
+
+
+# Global variables that it uses:
+# - EVENT_ABI_LIBVERSION
+# - CMAKE_THREAD_LIBS_INIT LIB_PLATFORM
+# - OPENSSL_LIBRARIES
+# - HDR_PUBLIC
+# - EVENT_INSTALL_INCLUDE_DIR
+# - EVENT_SHARED_FLAGS
+#
+# Exported variables:
+# - LIBEVENT_SHARED_LIBRARIES
+# - LIBEVENT_STATIC_LIBRARIES
+macro(add_event_library LIB_NAME)
+ cmake_parse_arguments(LIB
+ "" # Options
+ "VERSION" # One val
+ "SOURCES;LIBRARIES" # Multi val
+ ${ARGN}
+ )
+
+ add_library("${LIB_NAME}_static" STATIC ${LIB_SOURCES})
+ add_library("${LIB_NAME}_shared" SHARED ${LIB_SOURCES})
+
+ target_link_libraries("${LIB_NAME}_shared"
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${LIB_PLATFORM}
+ ${LIB_LIBRARIES})
+
+ if (EVENT_SHARED_FLAGS)
+ set_event_shared_lib_flags("${LIB_NAME}" "${EVENT_SHARED_FLAGS}")
+ endif()
+
+ set_event_lib_properties("${LIB_NAME}"
+ OUTPUT_NAME "${LIB_NAME}"
+ CLEAN_DIRECT_OUTPUT 1
+ )
+
+ set_target_properties(
+ "${LIB_NAME}_shared" PROPERTIES
+ PUBLIC_HEADER "${HDR_PUBLIC}")
+ set_target_properties(
+ "${LIB_NAME}_static" PROPERTIES
+ PUBLIC_HEADER "${HDR_PUBLIC}")
+
+ set_target_properties(
+ "${LIB_NAME}_shared" PROPERTIES
+ SOVERSION ${EVENT_ABI_LIBVERSION}
+ )
+
+ export(TARGETS "${LIB_NAME}_static" "${LIB_NAME}_shared"
+ FILE "${PROJECT_BINARY_DIR}/LibeventTargets.cmake"
+ )
+
+ install(TARGETS "${LIB_NAME}_static" "${LIB_NAME}_shared"
+ EXPORT LibeventTargets
+ LIBRARY DESTINATION "lib" COMPONENT lib
+ ARCHIVE DESTINATION "lib" COMPONENT lib
+ PUBLIC_HEADER DESTINATION "include/event2"
+ COMPONENT dev
+ )
+
+ list(APPEND LIBEVENT_SHARED_LIBRARIES "${LIB_NAME}_shared")
+ list(APPEND LIBEVENT_STATIC_LIBRARIES "${LIB_NAME}_static")
+
+ generate_pkgconfig("${LIB_NAME}")
+endmacro()
# - Config file for the Libevent package
# It defines the following variables
-# LIBEVENT_INCLUDE_DIRS - include directories for FooBar
-# LIBEVENT_LIBRARIES - libraries to link against
+# LIBEVENT_INCLUDE_DIRS - include directories
+# LIBEVENT_STATIC_LIBRARIES - libraries to link against (archive/static)
+# LIBEVENT_SHARED_LIBRARIES - libraries to link against (shared)
# Get the path of the current file.
get_filename_component(LIBEVENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${LIBEVENT_CMAKE_DIR}/LibeventTargets.cmake)
# IMPORTED targets from LibeventTargets.cmake
-set(LIBEVENT_LIBRARIES event event_core event_extra)
-
+set(LIBEVENT_STATIC_LIBRARIES "@LIBEVENT_STATIC_LIBRARIES@")
+set(LIBEVENT_SHARED_LIBRARIES "@LIBEVENT_SHARED_LIBRARIES@")
@param cb The function to run when the struct event_callback executes.
@param arg The function's second argument.
*/
+EVENT2_EXPORT_SYMBOL
void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *);
/**
Change the priority of a non-pending event_callback.
/**
Cancel a struct event_callback if it is currently scheduled in an event_base.
*/
+EVENT2_EXPORT_SYMBOL
void event_deferred_cb_cancel_(struct event_base *, struct event_callback *);
/**
Activate a struct event_callback if it is not currently scheduled in an event_base.
Return true if it was not previously scheduled.
*/
+EVENT2_EXPORT_SYMBOL
int event_deferred_cb_schedule_(struct event_base *, struct event_callback *);
#ifdef __cplusplus
/* Define to `int' if <sys/types.h> does not define. */
#define EVENT__ssize_t @EVENT__ssize_t@
-#cmakedefine EVENT__NEED_DLLIMPORT 1
-
#endif /* \EVENT2_EVENT_CONFIG_H_INCLUDED_ */
int event_remove_timer_nolock_(struct event *ev);
void event_active_nolock_(struct event *ev, int res, short count);
+EVENT2_EXPORT_SYMBOL
int event_callback_activate_(struct event_base *, struct event_callback *);
int event_callback_activate_nolock_(struct event_base *, struct event_callback *);
int event_callback_cancel_(struct event_base *base,
struct event_callback *evcb);
void event_callback_finalize_nolock_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *));
+EVENT2_EXPORT_SYMBOL
void event_callback_finalize_(struct event_base *base, unsigned flags, struct event_callback *evcb, void (*cb)(struct event_callback *, void *));
int event_callback_finalize_many_(struct event_base *base, int n_cbs, struct event_callback **evcb, void (*cb)(struct event_callback *, void *));
+EVENT2_EXPORT_SYMBOL
void event_active_later_(struct event *ev, int res);
void event_active_later_nolock_(struct event *ev, int res);
int event_callback_activate_later_nolock_(struct event_base *base,
struct event_callback *cb);
/* FIXME document. */
+EVENT2_EXPORT_SYMBOL
void event_base_add_virtual_(struct event_base *base);
void event_base_del_virtual_(struct event_base *base);
Returns on success; aborts on failure.
*/
+EVENT2_EXPORT_SYMBOL
void event_base_assert_ok_(struct event_base *base);
void event_base_assert_ok_nolock_(struct event_base *base);
};
/* Global state; deprecated */
+EVENT2_EXPORT_SYMBOL
struct event_base *event_global_current_base_ = NULL;
#define current_base event_global_current_base_
a final padding nibble with value 0 is appended.
*/
+EVENT2_EXPORT_SYMBOL
int evtag_decode_int(ev_uint32_t *pnumber, struct evbuffer *evbuf);
+EVENT2_EXPORT_SYMBOL
int evtag_decode_int64(ev_uint64_t *pnumber, struct evbuffer *evbuf);
+EVENT2_EXPORT_SYMBOL
int evtag_encode_tag(struct evbuffer *evbuf, ev_uint32_t tag);
+EVENT2_EXPORT_SYMBOL
int evtag_decode_tag(ev_uint32_t *ptag, struct evbuffer *evbuf);
void
#if ! defined(EVENT__DISABLE_THREAD_SUPPORT) && defined(EVTHREAD_EXPOSE_STRUCTS)
/* Global function pointers to lock-related functions. NULL if locking isn't
enabled. */
+EVENT2_EXPORT_SYMBOL
extern struct evthread_lock_callbacks evthread_lock_fns_;
+EVENT2_EXPORT_SYMBOL
extern struct evthread_condition_callbacks evthread_cond_fns_;
extern unsigned long (*evthread_id_fn_)(void);
+EVENT2_EXPORT_SYMBOL
extern int evthread_lock_debugging_enabled_;
/** Return the ID of the current thread, or 1 if threading isn't enabled. */
EVLOCK_UNLOCK(lock1_tmplock_,mode1); \
} while (0)
+EVENT2_EXPORT_SYMBOL
int evthread_is_debug_lock_held_(void *lock);
void *evthread_debug_get_real_lock_(void *lock);
int evutil_secure_rng_global_setup_locks_(const int enable_locks);
/** Return current evthread_lock_callbacks */
+EVENT2_EXPORT_SYMBOL
struct evthread_lock_callbacks *evthread_get_lock_callbacks(void);
/** Return current evthread_condition_callbacks */
struct evthread_condition_callbacks *evthread_get_condition_callbacks(void);
#endif
#ifndef EVENT__DISABLE_DEBUG_MODE
-extern int event_debug_created_threadable_ctx_;
+extern int event_debug_created_threadable_ctx_;
extern int event_debug_mode_on_;
#endif
enum evhttp_request_error;
/* notifies the current request that it failed; resets connection */
+EVENT2_EXPORT_SYMBOL
void evhttp_connection_fail_(struct evhttp_connection *,
enum evhttp_request_error error);
enum message_read_status;
+EVENT2_EXPORT_SYMBOL
enum message_read_status evhttp_parse_firstline_(struct evhttp_request *, struct evbuffer*);
+EVENT2_EXPORT_SYMBOL
enum message_read_status evhttp_parse_headers_(struct evhttp_request *, struct evbuffer*);
void evhttp_start_read_(struct evhttp_connection *);
void evhttp_response_code_(struct evhttp_request *, int, const char *);
void evhttp_send_page_(struct evhttp_request *, struct evbuffer *);
+EVENT2_EXPORT_SYMBOL
int evhttp_decode_uri_internal(const char *uri, size_t length,
char *ret, int decode_plus);
#ifndef EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_
#define EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_
+#include <event2/visibility.h>
+
#define evbuffercb bufferevent_data_cb
#define everrorcb bufferevent_event_cb
error occurred
@see bufferevent_base_set(), bufferevent_free()
*/
+EVENT2_EXPORT_SYMBOL
struct bufferevent *bufferevent_new(evutil_socket_t fd,
evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
@param timeout_read the read timeout
@param timeout_write the write timeout
*/
+EVENT2_EXPORT_SYMBOL
void bufferevent_settimeout(struct bufferevent *bufev,
int timeout_read, int timeout_write);
/* For int types. */
#include <event2/util.h>
+#include <event2/visibility.h>
/**
Initialize the asynchronous DNS library.
@return 0 if successful, or -1 if an error occurred
@see evdns_shutdown()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_init(void);
struct evdns_base;
@deprecated This function is deprecated because use of the global
evdns_base is error-prone.
*/
+EVENT2_EXPORT_SYMBOL
struct evdns_base *evdns_get_global_base(void);
/**
active requests will return DNS_ERR_SHUTDOWN.
@see evdns_init()
*/
+EVENT2_EXPORT_SYMBOL
void evdns_shutdown(int fail_requests);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_nameserver_ip_add()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_nameserver_add(unsigned long int address);
/**
@return the number of configured nameservers
@see evdns_nameserver_add()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_count_nameservers(void);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_resume()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_clear_nameservers_and_suspend(void);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_clear_nameservers_and_suspend()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resume(void);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_nameserver_add()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_nameserver_ip_add(const char *ip_as_string);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr);
struct in_addr;
@return 0 if successful, or -1 if an error occurred
@see evdns_resolve_reverse_ipv6()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
/**
@return 0 if successful, or -1 if an error occurred
@see evdns_resolve_reverse_ipv6()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
/**
@param flags Ignored.
@return 0 if successful, or -1 if an error occurred
*/
+EVENT2_EXPORT_SYMBOL
int evdns_set_option(const char *option, const char *val, int flags);
/**
occurred (see above)
@see resolv.conf(3), evdns_config_windows_nameservers()
*/
+EVENT2_EXPORT_SYMBOL
int evdns_resolv_conf_parse(int flags, const char *const filename);
/**
caller to specify which evdns_base it applies to. The recommended
function is evdns_base_search_clear().
*/
+EVENT2_EXPORT_SYMBOL
void evdns_search_clear(void);
/**
@param domain the domain to be added to the search list
*/
+EVENT2_EXPORT_SYMBOL
void evdns_search_add(const char *domain);
/**
@param ndots the new ndots parameter
*/
+EVENT2_EXPORT_SYMBOL
void evdns_search_ndots_set(const int ndots);
/**
function is evdns_add_server_port_with_base().
*/
-struct evdns_server_port *evdns_add_server_port(evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data);
+EVENT2_EXPORT_SYMBOL
+struct evdns_server_port *
+evdns_add_server_port(evutil_socket_t socket, int flags,
+ evdns_request_callback_fn_type callback, void *user_data);
#ifdef _WIN32
+EVENT2_EXPORT_SYMBOL
int evdns_config_windows_nameservers(void);
#define EVDNS_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED
#endif
* @param port the port number on which the HTTP server should listen
* @return an struct evhttp object
*/
+EVENT2_EXPORT_SYMBOL
struct evhttp *evhttp_start(const char *address, ev_uint16_t port);
/**
*
* @deprecated It does not allow an event base to be specified
*/
+EVENT2_EXPORT_SYMBOL
struct evhttp_connection *evhttp_connection_new(
const char *address, ev_uint16_t port);
*
* @deprecated XXXX Why?
*/
+EVENT2_EXPORT_SYMBOL
void evhttp_connection_set_base(struct evhttp_connection *evcon,
struct event_base *base);
#ifndef EVENT2_RPC_H_INCLUDED_
#define EVENT2_RPC_H_INCLUDED_
+#include <event2/visibility.h>
+
#ifdef __cplusplus
extern "C" {
#endif
struct evhttp_request* http_req; \
struct evbuffer* rpc_data; \
}; \
+EVENT2_EXPORT_SYMBOL \
int evrpc_send_request_##rpcname(struct evrpc_pool *, \
struct reqstruct *, struct rplystruct *, \
void (*)(struct evrpc_status *, \
struct evrpc_pool;
/** use EVRPC_GENERATE instead */
+EVENT2_EXPORT_SYMBOL
struct evrpc_request_wrapper *evrpc_make_request_ctx(
struct evrpc_pool *pool, void *request, void *reply,
const char *rpcname,
#define EVRPC_REQUEST_HTTP(rpc_req) (rpc_req)->http_req
/** completes the server response to an rpc request */
+EVENT2_EXPORT_SYMBOL
void evrpc_request_done(struct evrpc_req_generic *req);
/** accessors for request and reply */
+EVENT2_EXPORT_SYMBOL
void *evrpc_get_request(struct evrpc_req_generic *req);
+EVENT2_EXPORT_SYMBOL
void *evrpc_get_reply(struct evrpc_req_generic *req);
/** Creates the reply to an RPC request
* @return a newly allocated evrpc_base struct
* @see evrpc_free()
*/
+EVENT2_EXPORT_SYMBOL
struct evrpc_base *evrpc_init(struct evhttp *server);
/**
* @param base the evrpc_base object to be freed
* @see evrpc_init
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_free(struct evrpc_base *base);
/** register RPCs with the HTTP Server
@see EVRPC_REGISTER()
*/
+EVENT2_EXPORT_SYMBOL
int evrpc_register_rpc(struct evrpc_base *, struct evrpc *,
void (*)(struct evrpc_req_generic*, void *), void *);
*/
#define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name)
+EVENT2_EXPORT_SYMBOL
int evrpc_unregister_rpc(struct evrpc_base *base, const char *name);
/*
@returns 0 on success, -1 otherwise.
@see EVRPC_MAKE_REQUEST(), EVRPC_MAKE_CTX()
*/
+EVENT2_EXPORT_SYMBOL
int evrpc_make_request(struct evrpc_request_wrapper *ctx);
/** creates an rpc connection pool
* @return a newly allocated struct evrpc_pool object
* @see evrpc_pool_free()
*/
+EVENT2_EXPORT_SYMBOL
struct evrpc_pool *evrpc_pool_new(struct event_base *base);
/** frees an rpc connection pool
*
* @param pool a pointer to an evrpc_pool allocated via evrpc_pool_new()
* @see evrpc_pool_new()
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_pool_free(struct evrpc_pool *pool);
/**
* @param pool the pool to which to add the connection
* @param evcon the connection to add to the pool.
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_pool_add_connection(struct evrpc_pool *pool,
struct evhttp_connection *evcon);
* @param pool the pool from which to remove the connection
* @param evcon the connection to remove from the pool.
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_pool_remove_connection(struct evrpc_pool *pool,
struct evhttp_connection *evcon);
* @param timeout_in_secs the number of seconds after which a request should
* timeout and a failure be returned to the callback.
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs);
/**
* @return a handle to the hook so it can be removed later
* @see evrpc_remove_hook()
*/
+EVENT2_EXPORT_SYMBOL
void *evrpc_add_hook(void *vbase,
enum EVRPC_HOOK_TYPE hook_type,
int (*cb)(void *, struct evhttp_request *, struct evbuffer *, void *),
* @return 1 on success or 0 on failure
* @see evrpc_add_hook()
*/
+EVENT2_EXPORT_SYMBOL
int evrpc_remove_hook(void *vbase,
enum EVRPC_HOOK_TYPE hook_type,
void *handle);
* @param vbase a pointer to either struct evrpc_base or struct evrpc_pool
* @param ctx the context pointer provided to the original hook call
*/
-int
-evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res);
+EVENT2_EXPORT_SYMBOL
+int evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res);
/** adds meta data to request
*
* @param data the data to be associated with the key
* @param data_size the size of the data
*/
+EVENT2_EXPORT_SYMBOL
void evrpc_hook_add_meta(void *ctx, const char *key,
const void *data, size_t data_size);
* @param data_size pointer to the size of the data
* @return 0 on success or -1 on failure
*/
+EVENT2_EXPORT_SYMBOL
int evrpc_hook_find_meta(void *ctx, const char *key,
void **data, size_t *data_size);
* @param ctx the context provided to the hook call
* @return a pointer to the evhttp_connection object
*/
+EVENT2_EXPORT_SYMBOL
struct evhttp_connection *evrpc_hook_get_connection(void *ctx);
/**
@see EVRPC_MAKE_REQUEST()
*/
+EVENT2_EXPORT_SYMBOL
int evrpc_send_request_generic(struct evrpc_pool *pool,
void *request, void *reply,
void (*cb)(struct evrpc_status *, void *, void *, void *),
@see EVRPC_REGISTER()
*/
-int
-evrpc_register_generic(struct evrpc_base *base, const char *name,
+EVENT2_EXPORT_SYMBOL
+int evrpc_register_generic(struct evrpc_base *base, const char *name,
void (*callback)(struct evrpc_req_generic *, void *), void *cbarg,
void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *),
int (*req_unmarshal)(void *, struct evbuffer *),
void (*rpl_marshal)(struct evbuffer *, void *));
/** accessors for obscure and undocumented functionality */
+EVENT2_EXPORT_SYMBOL
struct evrpc_pool* evrpc_request_get_pool(struct evrpc_request_wrapper *ctx);
+EVENT2_EXPORT_SYMBOL
void evrpc_request_set_pool(struct evrpc_request_wrapper *ctx,
struct evrpc_pool *pool);
+EVENT2_EXPORT_SYMBOL
void evrpc_request_set_cb(struct evrpc_request_wrapper *ctx,
void (*cb)(struct evrpc_status*, void *request, void *reply, void *arg),
void *cb_arg);
#include <event2/event-config.h>
-#if defined(event_EXPORTS) || defined(event_extra_EXPORTS) || defined(event_core_EXPORTS)
+#if defined(event_shared_EXPORTS) || \
+ defined(event_extra_shared_EXPORTS) || \
+ defined(event_core_shared_EXPORTS) || \
+ defined(event_pthreads_shared_EXPORTS) || \
+ defined(event_openssl_shared_EXPORTS)
# if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define EVENT2_EXPORT_SYMBOL __global
# elif defined __GNUC__
# define EVENT2_EXPORT_SYMBOL /* unknown compiler */
# endif
#else
-# if defined(EVENT__NEED_DLLIMPORT) && defined(_MSC_VER) && !defined(EVENT_BUILDING_REGRESS_TEST)
+# if defined(_MSC_VER) && !defined(EVENT_BUILDING_REGRESS_TEST)
# define EVENT2_EXPORT_SYMBOL extern __declspec(dllimport)
# else
# define EVENT2_EXPORT_SYMBOL
struct event_iocp_port *event_base_get_iocp_(struct event_base *base);
/* FIXME document. */
+EVENT2_EXPORT_SYMBOL
int event_base_start_iocp_(struct event_base *base, int n_cpus);
void event_base_stop_iocp_(struct event_base *base);
#ifdef EVENT_DEBUG_LOGGING_ENABLED
#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING
+EVENT2_EXPORT_SYMBOL
extern ev_uint32_t event_debug_logging_mask_;
#define event_debug_get_logging_mask_() (event_debug_logging_mask_)
#else
#define event_debug_get_logging_mask_() (0)
#endif
+EVENT2_EXPORT_SYMBOL
void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN;
+EVENT2_EXPORT_SYMBOL
void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2);
+EVENT2_EXPORT_SYMBOL
void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN;
+EVENT2_EXPORT_SYMBOL
void event_sock_warn(evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(2,3);
+EVENT2_EXPORT_SYMBOL
void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN;
+EVENT2_EXPORT_SYMBOL
void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2);
+EVENT2_EXPORT_SYMBOL
void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2);
+EVENT2_EXPORT_SYMBOL
void event_debugx_(const char *fmt, ...) EV_CHECK_FMT(1,2);
+EVENT2_EXPORT_SYMBOL
void event_logv_(int severity, const char *errstr, const char *fmt, va_list ap)
EV_CHECK_FMT(3,0);
* On failure, set errno to ENOMEM and return NULL.
* If the argument sz is 0, simply return NULL.
*/
+EVENT2_EXPORT_SYMBOL
void *event_mm_malloc_(size_t sz);
/** Allocate memory initialized to zero.
* set errno to ENOMEM and return NULL.
* If either arguments are 0, simply return NULL.
*/
+EVENT2_EXPORT_SYMBOL
void *event_mm_calloc_(size_t count, size_t size);
/** Duplicate a string.
* occurs (or would occur) in the process.
* If the argument str is NULL, set errno to EINVAL and return NULL.
*/
+EVENT2_EXPORT_SYMBOL
char *event_mm_strdup_(const char *str);
+EVENT2_EXPORT_SYMBOL
void *event_mm_realloc_(void *p, size_t sz);
+EVENT2_EXPORT_SYMBOL
void event_mm_free_(void *p);
#define mm_malloc(sz) event_mm_malloc_(sz)
#define mm_calloc(count, size) event_mm_calloc_((count), (size))
#endif
#include "event2/event-config.h"
+#include "event2/visibility.h"
#include "evconfig-private.h"
#ifndef EVENT__HAVE_STRLCPY
#include <string.h>
+EVENT2_EXPORT_SYMBOL
size_t event_strlcpy_(char *dst, const char *src, size_t siz);
#define strlcpy event_strlcpy_
#endif
#endif
long evutil_tv_to_msec_(const struct timeval *tv);
+EVENT2_EXPORT_SYMBOL
void evutil_usleep_(const struct timeval *tv);
#ifdef _WIN32
struct timeval last_time;
};
+EVENT2_EXPORT_SYMBOL
int evutil_configure_monotonic_time_(struct evutil_monotonic_timer *mt,
int flags);
+EVENT2_EXPORT_SYMBOL
int evutil_gettime_monotonic_(struct evutil_monotonic_timer *mt, struct timeval *tv);
* when you care about ASCII's notion of character types, because you are about
* to send those types onto the wire.
*/
+EVENT2_EXPORT_SYMBOL
int EVUTIL_ISALPHA_(char c);
+EVENT2_EXPORT_SYMBOL
int EVUTIL_ISALNUM_(char c);
int EVUTIL_ISSPACE_(char c);
+EVENT2_EXPORT_SYMBOL
int EVUTIL_ISDIGIT_(char c);
+EVENT2_EXPORT_SYMBOL
int EVUTIL_ISXDIGIT_(char c);
int EVUTIL_ISPRINT_(char c);
int EVUTIL_ISLOWER_(char c);
int EVUTIL_ISUPPER_(char c);
+EVENT2_EXPORT_SYMBOL
char EVUTIL_TOUPPER_(char c);
+EVENT2_EXPORT_SYMBOL
char EVUTIL_TOLOWER_(char c);
/** Remove all trailing horizontal whitespace (space or tab) from the end of a
* string */
+EVENT2_EXPORT_SYMBOL
void evutil_rtrim_lws_(char *);
*/
int evutil_open_closeonexec_(const char *pathname, int flags, unsigned mode);
+EVENT2_EXPORT_SYMBOL
int evutil_read_file_(const char *filename, char **content_out, size_t *len_out,
int is_binary);
+EVENT2_EXPORT_SYMBOL
int evutil_socket_connect_(evutil_socket_t *fd_ptr, const struct sockaddr *sa, int socklen);
int evutil_socket_finished_connecting_(evutil_socket_t fd);
+EVENT2_EXPORT_SYMBOL
int evutil_ersatz_socketpair_(int, int , int, evutil_socket_t[]);
int evutil_resolve_(int family, const char *hostname, struct sockaddr *sa,
* attacker can't predict, or which passes strong statistical tests, use the
* evutil_secure_rng* functions instead.
*/
+EVENT2_EXPORT_SYMBOL
ev_uint32_t evutil_weakrand_seed_(struct evutil_weakrand_state *state, ev_uint32_t seed);
/* Return a pseudorandom value between 0 and EVUTIL_WEAKRAND_MAX inclusive.
* Updates the state in 'seed' as needed -- this value must be protected by a
* lock.
*/
+EVENT2_EXPORT_SYMBOL
ev_int32_t evutil_weakrand_(struct evutil_weakrand_state *seed);
/* Return a pseudorandom value x such that 0 <= x < top. top must be no more
* than EVUTIL_WEAKRAND_MAX. Updates the state in 'seed' as needed -- this
* value must be proteced by a lock */
+EVENT2_EXPORT_SYMBOL
ev_int32_t evutil_weakrand_range_(struct evutil_weakrand_state *seed, ev_int32_t top);
/* Evaluates to the same boolean value as 'p', and hints to the compiler that
const char *nodename, const char *servname,
const struct evutil_addrinfo *hints_in,
void (*cb)(int, struct evutil_addrinfo *, void *), void *arg);
+EVENT2_EXPORT_SYMBOL
void evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo_fn fn);
typedef void (*evdns_getaddrinfo_cancel_fn)(
struct evdns_getaddrinfo_request *req);
+EVENT2_EXPORT_SYMBOL
void evutil_set_evdns_getaddrinfo_cancel_fn_(evdns_getaddrinfo_cancel_fn fn);
+EVENT2_EXPORT_SYMBOL
struct evutil_addrinfo *evutil_new_addrinfo_(struct sockaddr *sa,
ev_socklen_t socklen, const struct evutil_addrinfo *hints);
+EVENT2_EXPORT_SYMBOL
struct evutil_addrinfo *evutil_addrinfo_append_(struct evutil_addrinfo *first,
struct evutil_addrinfo *append);
+EVENT2_EXPORT_SYMBOL
void evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints);
+EVENT2_EXPORT_SYMBOL
int evutil_getaddrinfo_common_(const char *nodename, const char *servname,
struct evutil_addrinfo *hints, struct evutil_addrinfo **res, int *portnum);
/** Return true iff sa is a looback address. (That is, it is 127.0.0.1/8, or
* ::1). */
+EVENT2_EXPORT_SYMBOL
int evutil_sockaddr_is_loopback_(const struct sockaddr *sa);
Returns a pointer to out. Always writes something into out, so it's safe
to use the output of this function without checking it for NULL.
*/
+EVENT2_EXPORT_SYMBOL
const char *evutil_format_sockaddr_port_(const struct sockaddr *sa, char *out, size_t outlen);
int evutil_hex_char_to_int_(char c);
#endif
#endif
+EVENT2_EXPORT_SYMBOL
evutil_socket_t evutil_socket_(int domain, int type, int protocol);
evutil_socket_t evutil_accept4_(evutil_socket_t sockfd, struct sockaddr *addr,
ev_socklen_t *addrlen, int flags);