diff options
author | Narayan Kamath <narayan@google.com> | 2017-09-13 12:53:52 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2017-09-13 14:18:03 +0100 |
commit | fc74cb45eafe51162b10a850016c6d2e1f8fd23c (patch) | |
tree | 203fb0f2feed47099e5bf999bcaff954f5c0e49d /include | |
parent | 9dfd4017adef7eaf179f743bf746254917a4fb74 (diff) | |
download | libevent-fc74cb45eafe51162b10a850016c6d2e1f8fd23c.tar.gz |
Revert "Revert "Upgrade to 2.1.8-stable (2017-01-22)." and "Probably Mac build fix?""
This reverts commit 83a0c9c65a60a92d3ea5542596b3ba56db492c37.
Bug: 64543673
Test: make checkbuild
Test: Manual tombstoned test
Change-Id: I84bb128d1dec433195f2cbdbf70236ba17fa9955
Diffstat (limited to 'include')
36 files changed, 2851 insertions, 1344 deletions
diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 5153db2..0000000 --- a/include/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -# include/Makefile.am for libevent -# Copyright 2000-2007 Niels Provos -# Copyright 2007-2012 Niels Provos and Nick Mathewson -# -# See LICENSE for copying information. - -AUTOMAKE_OPTIONS = foreign - -EVENT2_EXPORT = \ - event2/buffer.h \ - event2/buffer_compat.h \ - event2/bufferevent.h \ - event2/bufferevent_compat.h \ - event2/bufferevent_ssl.h \ - event2/bufferevent_struct.h \ - event2/dns.h \ - event2/dns_compat.h \ - event2/dns_struct.h \ - event2/event.h \ - event2/event_compat.h \ - event2/event_struct.h \ - event2/http.h \ - event2/http_compat.h \ - event2/http_struct.h \ - event2/keyvalq_struct.h \ - event2/listener.h \ - event2/rpc.h \ - event2/rpc_compat.h \ - event2/rpc_struct.h \ - event2/tag.h \ - event2/tag_compat.h \ - event2/thread.h \ - event2/util.h - -EXTRA_SRC = $(EVENT2_EXPORT) - -## Without the nobase_ prefixing, Automake would strip "event2/" from -## the source header filename to derive the installed header filename. -## With nobase_ the installed path is $(includedir)/event2/ev*.h. - -if INSTALL_LIBEVENT -nobase_include_HEADERS = $(EVENT2_EXPORT) -nobase_nodist_include_HEADERS = ./event2/event-config.h -else -noinst_HEADERS = $(EVENT2_EXPORT) -nodist_noinst_HEADERS = ./event2/event-config.h -endif diff --git a/include/Makefile.in b/include/Makefile.in deleted file mode 100644 index ce0a2b9..0000000 --- a/include/Makefile.in +++ /dev/null @@ -1,598 +0,0 @@ -# Makefile.in generated by automake 1.12.2 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# include/Makefile.am for libevent -# Copyright 2000-2007 Niels Provos -# Copyright 2007-2012 Niels Provos and Nick Mathewson -# -# See LICENSE for copying information. - -VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = include -DIST_COMMON = $(am__nobase_include_HEADERS_DIST) \ - $(am__noinst_HEADERS_DIST) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ac_backport_259_ssizet.m4 \ - $(top_srcdir)/m4/acx_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__nobase_include_HEADERS_DIST = event2/buffer.h \ - event2/buffer_compat.h event2/bufferevent.h \ - event2/bufferevent_compat.h event2/bufferevent_ssl.h \ - event2/bufferevent_struct.h event2/dns.h event2/dns_compat.h \ - event2/dns_struct.h event2/event.h event2/event_compat.h \ - event2/event_struct.h event2/http.h event2/http_compat.h \ - event2/http_struct.h event2/keyvalq_struct.h event2/listener.h \ - event2/rpc.h event2/rpc_compat.h event2/rpc_struct.h \ - event2/tag.h event2/tag_compat.h event2/thread.h event2/util.h -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)" -am__noinst_HEADERS_DIST = event2/buffer.h event2/buffer_compat.h \ - event2/bufferevent.h event2/bufferevent_compat.h \ - event2/bufferevent_ssl.h event2/bufferevent_struct.h \ - event2/dns.h event2/dns_compat.h event2/dns_struct.h \ - event2/event.h event2/event_compat.h event2/event_struct.h \ - event2/http.h event2/http_compat.h event2/http_struct.h \ - event2/keyvalq_struct.h event2/listener.h event2/rpc.h \ - event2/rpc_compat.h event2/rpc_struct.h event2/tag.h \ - event2/tag_compat.h event2/thread.h event2/util.h -HEADERS = $(nobase_include_HEADERS) $(nobase_nodist_include_HEADERS) \ - $(nodist_noinst_HEADERS) $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EV_LIB_GDI = @EV_LIB_GDI@ -EV_LIB_WS32 = @EV_LIB_WS32@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBEVENT_GC_SECTIONS = @LIBEVENT_GC_SECTIONS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIBTOOL_DEPS = @LIBTOOL_DEPS@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OPENSSL_LIBADD = @OPENSSL_LIBADD@ -OPENSSL_LIBS = @OPENSSL_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PTHREAD_CC = @PTHREAD_CC@ -PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ -PTHREAD_LIBS = @PTHREAD_LIBS@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ZLIB_LIBS = @ZLIB_LIBS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -acx_pthread_config = @acx_pthread_config@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = foreign -EVENT2_EXPORT = \ - event2/buffer.h \ - event2/buffer_compat.h \ - event2/bufferevent.h \ - event2/bufferevent_compat.h \ - event2/bufferevent_ssl.h \ - event2/bufferevent_struct.h \ - event2/dns.h \ - event2/dns_compat.h \ - event2/dns_struct.h \ - event2/event.h \ - event2/event_compat.h \ - event2/event_struct.h \ - event2/http.h \ - event2/http_compat.h \ - event2/http_struct.h \ - event2/keyvalq_struct.h \ - event2/listener.h \ - event2/rpc.h \ - event2/rpc_compat.h \ - event2/rpc_struct.h \ - event2/tag.h \ - event2/tag_compat.h \ - event2/thread.h \ - event2/util.h - -EXTRA_SRC = $(EVENT2_EXPORT) -@INSTALL_LIBEVENT_TRUE@nobase_include_HEADERS = $(EVENT2_EXPORT) -@INSTALL_LIBEVENT_TRUE@nobase_nodist_include_HEADERS = ./event2/event-config.h -@INSTALL_LIBEVENT_FALSE@noinst_HEADERS = $(EVENT2_EXPORT) -@INSTALL_LIBEVENT_FALSE@nodist_noinst_HEADERS = ./event2/event-config.h -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-nobase_includeHEADERS: $(nobase_include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - $(am__nobase_list) | while read dir files; do \ - xfiles=; for file in $$files; do \ - if test -f "$$file"; then xfiles="$$xfiles $$file"; \ - else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ - test -z "$$xfiles" || { \ - test "x$$dir" = x. || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \ - echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \ - $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \ - done - -uninstall-nobase_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ - $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) -install-nobase_nodist_includeHEADERS: $(nobase_nodist_include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(nobase_nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - $(am__nobase_list) | while read dir files; do \ - xfiles=; for file in $$files; do \ - if test -f "$$file"; then xfiles="$$xfiles $$file"; \ - else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ - test -z "$$xfiles" || { \ - test "x$$dir" = x. || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \ - echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \ - $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \ - done - -uninstall-nobase_nodist_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(nobase_nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -cscopelist: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-nobase_includeHEADERS \ - install-nobase_nodist_includeHEADERS - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-nobase_includeHEADERS \ - uninstall-nobase_nodist_includeHEADERS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool cscopelist ctags distclean distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-nobase_includeHEADERS \ - install-nobase_nodist_includeHEADERS install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-nobase_includeHEADERS \ - uninstall-nobase_nodist_includeHEADERS - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/include/evdns.h b/include/evdns.h new file mode 100644 index 0000000..8672db0 --- /dev/null +++ b/include/evdns.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 EVENT1_EVDNS_H_INCLUDED_ +#define EVENT1_EVDNS_H_INCLUDED_ + +/** @file evdns.h + + A dns subsystem for Libevent. + + The <evdns.h> header is deprecated in Libevent 2.0 and later; please + use <event2/evdns.h> instead. Depending on what functionality you + need, you may also want to include more of the other <event2/...> + headers. + */ + +#include <event.h> +#include <event2/dns.h> +#include <event2/dns_compat.h> +#include <event2/dns_struct.h> + +#endif /* EVENT1_EVDNS_H_INCLUDED_ */ diff --git a/include/event.h b/include/event.h new file mode 100644 index 0000000..ba51867 --- /dev/null +++ b/include/event.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 EVENT1_EVENT_H_INCLUDED_ +#define EVENT1_EVENT_H_INCLUDED_ + +/** @file event.h + + A library for writing event-driven network servers. + + The <event.h> header is deprecated in Libevent 2.0 and later; please + use <event2/event.h> instead. Depending on what functionality you + need, you may also want to include more of the other event2/ + headers. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <event2/event-config.h> +#ifdef EVENT__HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef EVENT__HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#ifdef EVENT__HAVE_STDINT_H +#include <stdint.h> +#endif +#include <stdarg.h> + +/* For int types. */ +#include <evutil.h> + +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include <winsock2.h> +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN +#endif + +#include <event2/event_struct.h> +#include <event2/event.h> +#include <event2/event_compat.h> +#include <event2/buffer.h> +#include <event2/buffer_compat.h> +#include <event2/bufferevent.h> +#include <event2/bufferevent_struct.h> +#include <event2/bufferevent_compat.h> +#include <event2/tag.h> +#include <event2/tag_compat.h> + +#ifdef __cplusplus +} +#endif + +#endif /* EVENT1_EVENT_H_INCLUDED_ */ diff --git a/include/event2/buffer.h b/include/event2/buffer.h index 5c89655..468588b 100644 --- a/include/event2/buffer.h +++ b/include/event2/buffer.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_BUFFER_H_ -#define _EVENT2_BUFFER_H_ +#ifndef EVENT2_BUFFER_H_INCLUDED_ +#define EVENT2_BUFFER_H_INCLUDED_ /** @file event2/buffer.h @@ -72,16 +72,18 @@ evbuffer_peek() if you don't require that the memory to be contiguous. */ +#include <event2/visibility.h> + #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> #include <stdarg.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_UIO_H +#ifdef EVENT__HAVE_SYS_UIO_H #include <sys/uio.h> #endif #include <event2/util.h> @@ -93,7 +95,7 @@ extern "C" { @see event2/event.h for more information */ struct evbuffer -#ifdef _EVENT_IN_DOXYGEN +#ifdef EVENT_IN_DOXYGEN_ {} #endif ; @@ -103,17 +105,23 @@ struct evbuffer Used when repeatedly searching through a buffer. Calling any function that modifies or re-packs the buffer contents may invalidate all - evbuffer_ptrs for that buffer. Do not modify these values except with - evbuffer_ptr_set. + evbuffer_ptrs for that buffer. Do not modify or contruct these values + except with evbuffer_ptr_set. + + An evbuffer_ptr can represent any position from the start of a buffer up + to a position immediately after the end of a buffer. + + @see evbuffer_ptr_set() */ struct evbuffer_ptr { ev_ssize_t pos; - /* Do not alter the values of fields. */ + /* Do not alter or rely on the values of fields: they are for internal + * use */ struct { void *chain; size_t pos_in_chain; - } _internal; + } internal_; }; /** Describes a single extent of memory inside an evbuffer. Used for @@ -121,10 +129,10 @@ struct evbuffer_ptr { @see evbuffer_reserve_space, evbuffer_commit_space, evbuffer_peek */ -#ifdef _EVENT_HAVE_SYS_UIO_H +#ifdef EVENT__HAVE_SYS_UIO_H #define evbuffer_iovec iovec /* Internal use -- defined only if we are using the native struct iovec */ -#define _EVBUFFER_IOVEC_IS_NATIVE +#define EVBUFFER_IOVEC_IS_NATIVE_ #else struct evbuffer_iovec { /** The start of the extent of memory. */ @@ -140,12 +148,14 @@ struct evbuffer_iovec { @return a pointer to a newly allocated evbuffer struct, or NULL if an error occurred */ +EVENT2_EXPORT_SYMBOL struct evbuffer *evbuffer_new(void); /** Deallocate storage for an evbuffer. @param buf pointer to the evbuffer to be freed */ +EVENT2_EXPORT_SYMBOL void evbuffer_free(struct evbuffer *buf); /** @@ -160,18 +170,21 @@ void evbuffer_free(struct evbuffer *buf); @param lock A lock object, or NULL if we should allocate our own. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_enable_locking(struct evbuffer *buf, void *lock); /** Acquire the lock on an evbuffer. Has no effect if locking was not enabled with evbuffer_enable_locking. */ +EVENT2_EXPORT_SYMBOL void evbuffer_lock(struct evbuffer *buf); /** Release the lock on an evbuffer. Has no effect if locking was not enabled with evbuffer_enable_locking. */ +EVENT2_EXPORT_SYMBOL void evbuffer_unlock(struct evbuffer *buf); @@ -199,6 +212,7 @@ void evbuffer_unlock(struct evbuffer *buf); * @param flags One or more EVBUFFER_FLAG_* options * @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags); /** Change the flags that are set for an evbuffer by removing some. * @@ -207,6 +221,7 @@ int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags); * @param flags One or more EVBUFFER_FLAG_* options * @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags); /** @@ -215,6 +230,7 @@ int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags); @param buf pointer to the evbuffer @return the number of bytes stored in the evbuffer */ +EVENT2_EXPORT_SYMBOL size_t evbuffer_get_length(const struct evbuffer *buf); /** @@ -229,6 +245,7 @@ size_t evbuffer_get_length(const struct evbuffer *buf); @return 0 if no data is available, otherwise the number of available bytes in the first buffer chain. */ +EVENT2_EXPORT_SYMBOL size_t evbuffer_get_contiguous_space(const struct evbuffer *buf); /** @@ -241,6 +258,7 @@ size_t evbuffer_get_contiguous_space(const struct evbuffer *buf); @param datlen the new minimum length requirement @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int evbuffer_expand(struct evbuffer *buf, size_t datlen); /** @@ -276,6 +294,7 @@ int evbuffer_expand(struct evbuffer *buf, size_t datlen); @return the number of provided extents, or -1 on error. @see evbuffer_commit_space() */ +EVENT2_EXPORT_SYMBOL int evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, struct evbuffer_iovec *vec, int n_vec); @@ -301,6 +320,7 @@ evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, @return 0 on success, -1 on error @see evbuffer_reserve_space() */ +EVENT2_EXPORT_SYMBOL int evbuffer_commit_space(struct evbuffer *buf, struct evbuffer_iovec *vec, int n_vecs); @@ -312,6 +332,7 @@ int evbuffer_commit_space(struct evbuffer *buf, @param datlen the number of bytes to be copied from the data buffer @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen); @@ -326,6 +347,7 @@ int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen); @param datlen the maximum size of the destination buffer @return the number of bytes read, or -1 if we can't drain the buffer. */ +EVENT2_EXPORT_SYMBOL int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen); /** @@ -339,9 +361,25 @@ int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen); @param datlen the maximum size of the destination buffer @return the number of bytes read, or -1 if we can't drain the buffer. */ +EVENT2_EXPORT_SYMBOL ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen); /** + Read data from the middle of an evbuffer, and leave the buffer unchanged. + + If more bytes are requested than are available in the evbuffer, we + only extract as many bytes as were available. + + @param buf the evbuffer to be read from + @param pos the position to start reading from + @param data_out the destination buffer to store the result + @param datlen the maximum size of the destination buffer + @return the number of bytes read, or -1 if we can't drain the buffer. + */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen); + +/** Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer. This function avoids copy operations to the extent possible. @@ -354,6 +392,7 @@ ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen) @param datlen the maximum numbers of bytes to transfer @return the number of bytes read */ +EVENT2_EXPORT_SYMBOL int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, size_t datlen); @@ -376,7 +415,9 @@ enum evbuffer_eol_style { /** An EOL is a CR followed by an LF. */ EVBUFFER_EOL_CRLF_STRICT, /** An EOL is a LF. */ - EVBUFFER_EOL_LF + EVBUFFER_EOL_LF, + /** An EOL is a NUL character (that is, a single byte with value 0) */ + EVBUFFER_EOL_NUL }; /** @@ -393,6 +434,7 @@ enum evbuffer_eol_style { * @param eol_style the style of line-ending to use. * @return pointer to a single line, or NULL if an error occurred */ +EVENT2_EXPORT_SYMBOL char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, enum evbuffer_eol_style eol_style); @@ -408,9 +450,27 @@ char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, @see evbuffer_remove_buffer() */ +EVENT2_EXPORT_SYMBOL int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf); /** + Copy data from one evbuffer into another evbuffer. + + This is a non-destructive add. The data from one buffer is copied + into the other buffer. However, no unnecessary memory copies occur. + + Note that buffers already containing buffer references can't be added + to other buffers. + + @param outbuf the output buffer + @param inbuf the input buffer + @return 0 if successful, or -1 if an error occurred + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_buffer_reference(struct evbuffer *outbuf, + struct evbuffer *inbuf); + +/** A cleanup function for a piece of memory added to an evbuffer by reference. @@ -434,6 +494,7 @@ typedef void (*evbuffer_ref_cleanup_cb)(const void *data, @param cleanupfn_arg optional argument to the cleanup callback @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int evbuffer_add_reference(struct evbuffer *outbuf, const void *data, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg); @@ -452,17 +513,140 @@ int evbuffer_add_reference(struct evbuffer *outbuf, The results of using evbuffer_remove() or evbuffer_pullup() on evbuffers whose data was added using this function are undefined. + For more fine-grained control, use evbuffer_add_file_segment. + @param outbuf the output buffer @param fd the file descriptor @param offset the offset from which to read data - @param length how much data to read + @param length how much data to read, or -1 to read as much as possible. + (-1 requires that 'fd' support fstat.) @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset, ev_off_t length); /** + An evbuffer_file_segment holds a reference to a range of a file -- + possibly the whole file! -- for use in writing from an evbuffer to a + socket. It could be implemented with mmap, sendfile, splice, or (if all + else fails) by just pulling all the data into RAM. A single + evbuffer_file_segment can be added more than once, and to more than one + evbuffer. + */ +struct evbuffer_file_segment; + +/** + Flag for creating evbuffer_file_segment: If this flag is set, then when + the evbuffer_file_segment is freed and no longer in use by any + evbuffer, the underlying fd is closed. + */ +#define EVBUF_FS_CLOSE_ON_FREE 0x01 +/** + Flag for creating evbuffer_file_segment: Disable memory-map based + implementations. + */ +#define EVBUF_FS_DISABLE_MMAP 0x02 +/** + Flag for creating evbuffer_file_segment: Disable direct fd-to-fd + implementations (including sendfile and splice). + + You might want to use this option if data needs to be taken from the + evbuffer by any means other than writing it to the network: the sendfile + backend is fast, but it only works for sending files directly to the + network. + */ +#define EVBUF_FS_DISABLE_SENDFILE 0x04 +/** + Flag for creating evbuffer_file_segment: Do not allocate a lock for this + segment. If this option is set, then neither the segment nor any + evbuffer it is added to may ever be accessed from more than one thread + at a time. + */ +#define EVBUF_FS_DISABLE_LOCKING 0x08 + +/** + A cleanup function for a evbuffer_file_segment added to an evbuffer + for reference. + */ +typedef void (*evbuffer_file_segment_cleanup_cb)( + struct evbuffer_file_segment const* seg, int flags, void* arg); + +/** + Create and return a new evbuffer_file_segment for reading data from a + file and sending it out via an evbuffer. + + This function avoids unnecessary data copies between userland and + kernel. Where available, it uses sendfile or splice. + + The file descriptor must not be closed so long as any evbuffer is using + this segment. + + The results of using evbuffer_remove() or evbuffer_pullup() or any other + function that reads bytes from an evbuffer on any evbuffer containing + the newly returned segment are undefined, unless you pass the + EVBUF_FS_DISABLE_SENDFILE flag to this function. + + @param fd an open file to read from. + @param offset an index within the file at which to start reading + @param length how much data to read, or -1 to read as much as possible. + (-1 requires that 'fd' support fstat.) + @param flags any number of the EVBUF_FS_* flags + @return a new evbuffer_file_segment, or NULL on failure. + **/ +EVENT2_EXPORT_SYMBOL +struct evbuffer_file_segment *evbuffer_file_segment_new( + int fd, ev_off_t offset, ev_off_t length, unsigned flags); + +/** + Free an evbuffer_file_segment + + It is safe to call this function even if the segment has been added to + one or more evbuffers. The evbuffer_file_segment will not be freed + until no more references to it exist. + */ +EVENT2_EXPORT_SYMBOL +void evbuffer_file_segment_free(struct evbuffer_file_segment *seg); + +/** + Add cleanup callback and argument for the callback to an + evbuffer_file_segment. + + The cleanup callback will be invoked when no more references to the + evbuffer_file_segment exist. + **/ +EVENT2_EXPORT_SYMBOL +void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg, + evbuffer_file_segment_cleanup_cb cb, void* arg); + +/** + Insert some or all of an evbuffer_file_segment at the end of an evbuffer + + Note that the offset and length parameters of this function have a + different meaning from those provided to evbuffer_file_segment_new: When + you create the segment, the offset is the offset _within the file_, and + the length is the length _of the segment_, whereas when you add a + segment to an evbuffer, the offset is _within the segment_ and the + length is the length of the _part of the segment you want to use. + + In other words, if you have a 10 KiB file, and you create an + evbuffer_file_segment for it with offset 20 and length 1000, it will + refer to bytes 20..1019 inclusive. If you then pass this segment to + evbuffer_add_file_segment and specify an offset of 20 and a length of + 50, you will be adding bytes 40..99 inclusive. + + @param buf the evbuffer to append to + @param seg the segment to add + @param offset the offset within the segment to start from + @param length the amount of data to add, or -1 to add it all. + @return 0 on success, -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_add_file_segment(struct evbuffer *buf, + struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length); + +/** Append a formatted string to the end of an evbuffer. The string is formated as printf. @@ -474,6 +658,7 @@ int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset, @see evutil_printf(), evbuffer_add_vprintf() */ +EVENT2_EXPORT_SYMBOL int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) #ifdef __GNUC__ __attribute__((format(printf, 2, 3))) @@ -488,6 +673,7 @@ int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) @param ap a varargs va_list argument array that will be passed to vprintf(3) @return The number of bytes added if successful, or -1 if an error occurred. */ +EVENT2_EXPORT_SYMBOL int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) #ifdef __GNUC__ __attribute__((format(printf, 2, 0))) @@ -502,6 +688,7 @@ int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) @param len the number of bytes to drain from the beginning of the buffer @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_drain(struct evbuffer *buf, size_t len); @@ -515,6 +702,7 @@ int evbuffer_drain(struct evbuffer *buf, size_t len); @return the number of bytes written, or -1 if an error occurred @see evbuffer_read() */ +EVENT2_EXPORT_SYMBOL int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd); /** @@ -529,6 +717,7 @@ int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd); @return the number of bytes written, or -1 if an error occurred @see evbuffer_read() */ +EVENT2_EXPORT_SYMBOL int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, ev_ssize_t howmuch); @@ -541,6 +730,7 @@ int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, @return the number of bytes read, or -1 if an error occurred @see evbuffer_write() */ +EVENT2_EXPORT_SYMBOL int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch); /** @@ -554,6 +744,7 @@ int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch); first occurrence of the string in the buffer after 'start'. The 'pos' field of the result is -1 if the string was not found. */ +EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start); /** @@ -570,6 +761,7 @@ struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, s first occurrence of the string in the buffer after 'start'. The 'pos' field of the result is -1 if the string was not found. */ +EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end); /** @@ -587,15 +779,25 @@ enum evbuffer_ptr_how { /** Sets the search pointer in the buffer to position. - If evbuffer_ptr is not initialized. This function can only be called + There are two ways to use this function: you can call + evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_SET) + to move 'pos' to a position 'N' bytes after the start of the buffer, or + evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_ADD) + to move 'pos' forward by 'N' bytes. + + If evbuffer_ptr is not initialized, this function can only be called with EVBUFFER_PTR_SET. + An evbuffer_ptr can represent any position from the start of the buffer to + a position immediately after the end of the buffer. + @param buffer the evbuffer to be search @param ptr a pointer to a struct evbuffer_ptr @param position the position at which to start the next search @param how determines how the pointer should be manipulated. @returns 0 on success or -1 otherwise */ +EVENT2_EXPORT_SYMBOL int evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr, size_t position, enum evbuffer_ptr_how how); @@ -614,6 +816,7 @@ evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr, first occurrence EOL in the buffer after 'start'. The 'pos' field of the result is -1 if the string was not found. */ +EVENT2_EXPORT_SYMBOL struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer, struct evbuffer_ptr *start, size_t *eol_len_out, enum evbuffer_eol_style eol_style); @@ -646,6 +849,7 @@ struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer, than n_vec if we would need more to return all the data that was requested. */ +EVENT2_EXPORT_SYMBOL int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len, struct evbuffer_ptr *start_at, struct evbuffer_iovec *vec_out, int n_vec); @@ -698,6 +902,7 @@ struct evbuffer_cb_entry; @param cbarg an argument to be provided to the callback function @return a handle to the callback on success, or NULL on failure. */ +EVENT2_EXPORT_SYMBOL struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg); /** Remove a callback from an evbuffer, given a handle returned from @@ -708,6 +913,7 @@ struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_f @return 0 if a callback was removed, or -1 if no matching callback was found. */ +EVENT2_EXPORT_SYMBOL int evbuffer_remove_cb_entry(struct evbuffer *buffer, struct evbuffer_cb_entry *ent); @@ -717,6 +923,7 @@ int evbuffer_remove_cb_entry(struct evbuffer *buffer, @return 0 if a callback was removed, or -1 if no matching callback was found. */ +EVENT2_EXPORT_SYMBOL int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg); /** If this flag is not set, then a callback is temporarily disabled, and @@ -733,6 +940,7 @@ int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg @param flags EVBUFFER_CB_ENABLED to re-enable the callback. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_cb_set_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags); @@ -743,6 +951,7 @@ int evbuffer_cb_set_flags(struct evbuffer *buffer, @param flags EVBUFFER_CB_ENABLED to disable the callback. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_cb_clear_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags); @@ -756,6 +965,7 @@ int evbuffer_cb_clear_flags(struct evbuffer *buffer, @param the buffer that the callback is watching. @param cb the callback we want to suspend. */ +EVENT2_EXPORT_SYMBOL void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb); /** Stop postponing a callback that we postponed with evbuffer_cb_suspend. @@ -765,6 +975,7 @@ void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb); @param the buffer that the callback is watching. @param cb the callback we want to stop suspending. */ +EVENT2_EXPORT_SYMBOL void evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb); #endif @@ -774,9 +985,11 @@ void evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb @param buf the evbuffer to make contiguous @param size the number of bytes to make contiguous, or -1 to make the entire buffer contiguous. - @return a pointer to the contiguous memory array + @return a pointer to the contiguous memory array, or NULL if param size + requested more data than is present in the buffer. */ +EVENT2_EXPORT_SYMBOL unsigned char *evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size); /** @@ -788,6 +1001,7 @@ unsigned char *evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size); @return 0 if successful, or -1 otherwise */ +EVENT2_EXPORT_SYMBOL int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size); /** @@ -798,6 +1012,7 @@ int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size); @param src the evbuffer to prepend; it will be emptied as a result @return 0 if successful, or -1 otherwise */ +EVENT2_EXPORT_SYMBOL int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src); /** @@ -814,6 +1029,7 @@ int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src); we freeze the back. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_freeze(struct evbuffer *buf, int at_front); /** Re-enable calls that modify an evbuffer. @@ -823,6 +1039,7 @@ int evbuffer_freeze(struct evbuffer *buf, int at_front); we unfreeze the back. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evbuffer_unfreeze(struct evbuffer *buf, int at_front); struct event_base; @@ -833,10 +1050,27 @@ struct event_base; This can be used to serialize all the callbacks to a single thread of execution. */ +EVENT2_EXPORT_SYMBOL int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base); +/** + Append data from 1 or more iovec's to an evbuffer + + Calculates the number of bytes needed for an iovec structure and guarantees + all data will fit into a single chain. Can be used in lieu of functionality + which calls evbuffer_add() constantly before being used to increase + performance. + + @param buffer the destination buffer + @param vec the source iovec + @param n_vec the number of iovec structures. + @return the number of bytes successfully written to the output buffer. +*/ +EVENT2_EXPORT_SYMBOL +size_t evbuffer_add_iovec(struct evbuffer * buffer, struct evbuffer_iovec * vec, int n_vec); + #ifdef __cplusplus } #endif -#endif /* _EVENT2_BUFFER_H_ */ +#endif /* EVENT2_BUFFER_H_INCLUDED_ */ diff --git a/include/event2/buffer_compat.h b/include/event2/buffer_compat.h index a713ee3..24f828c 100644 --- a/include/event2/buffer_compat.h +++ b/include/event2/buffer_compat.h @@ -24,8 +24,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _EVENT2_BUFFER_COMPAT_H_ -#define _EVENT2_BUFFER_COMPAT_H_ +#ifndef EVENT2_BUFFER_COMPAT_H_INCLUDED_ +#define EVENT2_BUFFER_COMPAT_H_INCLUDED_ + +#include <event2/visibility.h> /** @file event2/buffer_compat.h @@ -35,7 +37,7 @@ /** - Obsolete alias for evbuffer_readln(buffer, NULL, EOL_STYLE_ANY). + Obsolete alias for evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY). @deprecated This function is deprecated because its behavior is not correct for almost any protocol, and also because it's wholly subsumed by @@ -45,6 +47,7 @@ @return pointer to a single line, or NULL if an error occurred */ +EVENT2_EXPORT_SYMBOL char *evbuffer_readline(struct evbuffer *buffer); /** Type definition for a callback that is invoked whenever data is added or @@ -88,6 +91,7 @@ typedef void (*evbuffer_cb)(struct evbuffer *buffer, size_t old_len, size_t new_ or NULL to remove all callbacks. @param cbarg an argument to be provided to the callback function */ +EVENT2_EXPORT_SYMBOL void evbuffer_setcb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg); @@ -99,6 +103,7 @@ void evbuffer_setcb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg); @param len the length of the search string @return a pointer to the beginning of the search string, or NULL if the search failed. */ +EVENT2_EXPORT_SYMBOL unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len); /** deprecated in favor of calling the functions directly */ diff --git a/include/event2/bufferevent.h b/include/event2/bufferevent.h index 0cc6cb1..825918e 100644 --- a/include/event2/bufferevent.h +++ b/include/event2/bufferevent.h @@ -24,8 +24,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_BUFFEREVENT_H_ -#define _EVENT2_BUFFEREVENT_H_ +#ifndef EVENT2_BUFFEREVENT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_H_INCLUDED_ /** @file event2/bufferevent.h @@ -74,15 +74,17 @@ </dl> */ +#include <event2/visibility.h> + #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -109,7 +111,7 @@ extern "C" { @see event2/bufferevent.h */ struct bufferevent -#ifdef _EVENT_IN_DOXYGEN +#ifdef EVENT_IN_DOXYGEN_ {} #endif ; @@ -138,6 +140,9 @@ typedef void (*bufferevent_data_cb)(struct bufferevent *bev, void *ctx); The event callback is triggered if either an EOF condition or another unrecoverable error was encountered. + For bufferevents with deferred callbacks, this is a bitwise OR of all errors + that have happened on the bufferevent since the last callback invocation. + @param bev the bufferevent for which the error condition was reached @param what a conjunction of flags: BEV_EVENT_READING or BEV_EVENT_WRITING to indicate if the error was encountered on the read or write path, @@ -181,6 +186,7 @@ enum bufferevent_options { error occurred @see bufferevent_free() */ +EVENT2_EXPORT_SYMBOL struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options); /** @@ -202,7 +208,8 @@ struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socke @param socklen The length of the address @return 0 on success, -1 on failure. */ -int bufferevent_socket_connect(struct bufferevent *, struct sockaddr *, int); +EVENT2_EXPORT_SYMBOL +int bufferevent_socket_connect(struct bufferevent *, const struct sockaddr *, int); struct evdns_base; /** @@ -231,6 +238,7 @@ struct evdns_base; may block while it waits for a DNS response. This is probably not what you want. */ +EVENT2_EXPORT_SYMBOL int bufferevent_socket_connect_hostname(struct bufferevent *, struct evdns_base *, int, const char *, int); @@ -242,6 +250,7 @@ int bufferevent_socket_connect_hostname(struct bufferevent *, @return DNS error code. @see evutil_gai_strerror() */ +EVENT2_EXPORT_SYMBOL int bufferevent_socket_get_dns_error(struct bufferevent *bev); /** @@ -255,11 +264,13 @@ int bufferevent_socket_get_dns_error(struct bufferevent *bev); @return 0 if successful, or -1 if an error occurred @see bufferevent_new() */ +EVENT2_EXPORT_SYMBOL int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); /** Return the event_base used by a bufferevent */ +EVENT2_EXPORT_SYMBOL struct event_base *bufferevent_get_base(struct bufferevent *bev); /** @@ -271,14 +282,26 @@ struct event_base *bufferevent_get_base(struct bufferevent *bev); @param pri the priority to be assigned @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int bufferevent_priority_set(struct bufferevent *bufev, int pri); +/** + Return the priority of a bufferevent. + + Only supported for socket bufferevents + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_get_priority(const struct bufferevent *bufev); /** Deallocate the storage associated with a bufferevent structure. + If there is pending data to write on the bufferevent, it probably won't be + flushed before the bufferevent is freed. + @param bufev the bufferevent structure to be freed. */ +EVENT2_EXPORT_SYMBOL void bufferevent_free(struct bufferevent *bufev); @@ -296,29 +319,54 @@ void bufferevent_free(struct bufferevent *bufev); (readcb, writecb, and errorcb) @see bufferevent_new() */ +EVENT2_EXPORT_SYMBOL void bufferevent_setcb(struct bufferevent *bufev, bufferevent_data_cb readcb, bufferevent_data_cb writecb, bufferevent_event_cb eventcb, void *cbarg); /** + Retrieves the callbacks for a bufferevent. + + @param bufev the bufferevent to examine. + @param readcb_ptr if readcb_ptr is nonnull, *readcb_ptr is set to the current + read callback for the bufferevent. + @param writecb_ptr if writecb_ptr is nonnull, *writecb_ptr is set to the + current write callback for the bufferevent. + @param eventcb_ptr if eventcb_ptr is nonnull, *eventcb_ptr is set to the + current event callback for the bufferevent. + @param cbarg_ptr if cbarg_ptr is nonnull, *cbarg_ptr is set to the current + callback argument for the bufferevent. + @see buffervent_setcb() +*/ +EVENT2_EXPORT_SYMBOL +void bufferevent_getcb(struct bufferevent *bufev, + bufferevent_data_cb *readcb_ptr, + bufferevent_data_cb *writecb_ptr, + bufferevent_event_cb *eventcb_ptr, + void **cbarg_ptr); + +/** Changes the file descriptor on which the bufferevent operates. Not supported for all bufferevent types. @param bufev the bufferevent object for which to change the file descriptor @param fd the file descriptor to operate on */ +EVENT2_EXPORT_SYMBOL int bufferevent_setfd(struct bufferevent *bufev, evutil_socket_t fd); /** Returns the file descriptor associated with a bufferevent, or -1 if no file descriptor is associated with the bufferevent. */ +EVENT2_EXPORT_SYMBOL evutil_socket_t bufferevent_getfd(struct bufferevent *bufev); /** Returns the underlying bufferevent associated with a bufferevent (if the bufferevent is a wrapper), or NULL if there is no underlying bufferevent. */ +EVENT2_EXPORT_SYMBOL struct bufferevent *bufferevent_get_underlying(struct bufferevent *bufev); /** @@ -334,6 +382,7 @@ struct bufferevent *bufferevent_get_underlying(struct bufferevent *bufev); @return 0 if successful, or -1 if an error occurred @see bufferevent_write_buffer() */ +EVENT2_EXPORT_SYMBOL int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size); @@ -347,6 +396,7 @@ int bufferevent_write(struct bufferevent *bufev, @return 0 if successful, or -1 if an error occurred @see bufferevent_write() */ +EVENT2_EXPORT_SYMBOL int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); @@ -360,6 +410,7 @@ int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); @param size the size of the data buffer, in bytes @return the amount of data read, in bytes. */ +EVENT2_EXPORT_SYMBOL size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); /** @@ -370,6 +421,7 @@ size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); @param buf the evbuffer to which to add data @return 0 if successful, or -1 if an error occurred. */ +EVENT2_EXPORT_SYMBOL int bufferevent_read_buffer(struct bufferevent *bufev, struct evbuffer *buf); /** @@ -381,6 +433,7 @@ int bufferevent_read_buffer(struct bufferevent *bufev, struct evbuffer *buf); @return the evbuffer object for the input buffer */ +EVENT2_EXPORT_SYMBOL struct evbuffer *bufferevent_get_input(struct bufferevent *bufev); /** @@ -395,6 +448,7 @@ struct evbuffer *bufferevent_get_input(struct bufferevent *bufev); @return the evbuffer object for the output buffer */ +EVENT2_EXPORT_SYMBOL struct evbuffer *bufferevent_get_output(struct bufferevent *bufev); /** @@ -405,6 +459,7 @@ struct evbuffer *bufferevent_get_output(struct bufferevent *bufev); @return 0 if successful, or -1 if an error occurred @see bufferevent_disable() */ +EVENT2_EXPORT_SYMBOL int bufferevent_enable(struct bufferevent *bufev, short event); /** @@ -415,6 +470,7 @@ int bufferevent_enable(struct bufferevent *bufev, short event); @return 0 if successful, or -1 if an error occurred @see bufferevent_enable() */ +EVENT2_EXPORT_SYMBOL int bufferevent_disable(struct bufferevent *bufev, short event); /** @@ -423,6 +479,7 @@ int bufferevent_disable(struct bufferevent *bufev, short event); @param bufev the bufferevent to inspect @return A combination of EV_READ | EV_WRITE */ +EVENT2_EXPORT_SYMBOL short bufferevent_get_enabled(struct bufferevent *bufev); /** @@ -451,6 +508,7 @@ short bufferevent_get_enabled(struct bufferevent *bufev); @param timeout_read the read timeout, or NULL @param timeout_write the write timeout, or NULL */ +EVENT2_EXPORT_SYMBOL int bufferevent_set_timeouts(struct bufferevent *bufev, const struct timeval *timeout_read, const struct timeval *timeout_write); @@ -472,21 +530,64 @@ int bufferevent_set_timeouts(struct bufferevent *bufev, @param highmark the high watermark to set */ +EVENT2_EXPORT_SYMBOL void bufferevent_setwatermark(struct bufferevent *bufev, short events, size_t lowmark, size_t highmark); /** + Retrieves the watermarks for read or write events. + Returns non-zero if events contains not only EV_READ or EV_WRITE. + Returns zero if events equal EV_READ or EV_WRITE + + @param bufev the bufferevent to be examined + @param events EV_READ or EV_WRITE + @param lowmark receives the lower watermark if not NULL + @param highmark receives the high watermark if not NULL +*/ +EVENT2_EXPORT_SYMBOL +int bufferevent_getwatermark(struct bufferevent *bufev, short events, + size_t *lowmark, size_t *highmark); + +/** Acquire the lock on a bufferevent. Has no effect if locking was not enabled with BEV_OPT_THREADSAFE. */ +EVENT2_EXPORT_SYMBOL void bufferevent_lock(struct bufferevent *bufev); /** Release the lock on a bufferevent. Has no effect if locking was not enabled with BEV_OPT_THREADSAFE. */ +EVENT2_EXPORT_SYMBOL void bufferevent_unlock(struct bufferevent *bufev); + +/** + * Public interface to manually increase the reference count of a bufferevent + * this is useful in situations where a user may reference the bufferevent + * somewhere eles (unknown to libevent) + * + * @param bufev the bufferevent to increase the refcount on + * + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_incref(struct bufferevent *bufev); + +/** + * Public interface to manually decrement the reference count of a bufferevent + * + * Warning: make sure you know what you're doing. This is mainly used in + * conjunction with bufferevent_incref(). This will free up all data associated + * with a bufferevent if the reference count hits 0. + * + * @param bufev the bufferevent to decrement the refcount on + * + * @return 1 if the bufferevent was freed, otherwise 0 (still referenced) + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_decref(struct bufferevent *bufev); + /** Flags that can be passed into filters to let them know how to deal with the incoming data. @@ -510,11 +611,55 @@ enum bufferevent_flush_mode { @param mode either BEV_NORMAL or BEV_FLUSH or BEV_FINISHED @return -1 on failure, 0 if no data was produces, 1 if data was produced */ +EVENT2_EXPORT_SYMBOL int bufferevent_flush(struct bufferevent *bufev, short iotype, enum bufferevent_flush_mode mode); /** + Flags for bufferevent_trigger(_event) that modify when and how to trigger + the callback. +*/ +enum bufferevent_trigger_options { + /** trigger the callback regardless of the watermarks */ + BEV_TRIG_IGNORE_WATERMARKS = (1<<16), + + /** defer even if the callbacks are not */ + BEV_TRIG_DEFER_CALLBACKS = BEV_OPT_DEFER_CALLBACKS + + /* (Note: for internal reasons, these need to be disjoint from + * bufferevent_options, except when they mean the same thing. */ +}; + +/** + Triggers bufferevent data callbacks. + + The function will honor watermarks unless options contain + BEV_TRIG_IGNORE_WATERMARKS. If the options contain BEV_OPT_DEFER_CALLBACKS, + the callbacks are deferred. + + @param bufev the bufferevent object + @param iotype either EV_READ or EV_WRITE or both. + @param options + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_trigger(struct bufferevent *bufev, short iotype, + int options); + +/** + Triggers the bufferevent event callback. + + If the options contain BEV_OPT_DEFER_CALLBACKS, the callbacks are deferred. + + @param bufev the bufferevent object + @param what the flags to pass onto the event callback + @param options + */ +EVENT2_EXPORT_SYMBOL +void bufferevent_trigger_event(struct bufferevent *bufev, short what, + int options); + +/** @name Filtering support @{ @@ -569,6 +714,7 @@ typedef enum bufferevent_filter_result (*bufferevent_filter_cb)( this bufferevent is freed. @param ctx A context pointer to pass to the filter functions. */ +EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_filter_new(struct bufferevent *underlying, bufferevent_filter_cb input_filter, @@ -588,6 +734,7 @@ bufferevent_filter_new(struct bufferevent *underlying, @param pair A pointer to an array to hold the two new bufferevent objects. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int bufferevent_pair_new(struct event_base *base, int options, struct bufferevent *pair[2]); @@ -595,6 +742,7 @@ int bufferevent_pair_new(struct event_base *base, int options, Given one bufferevent returned by bufferevent_pair_new(), returns the other one if it still exists. Otherwise returns NULL. */ +EVENT2_EXPORT_SYMBOL struct bufferevent *bufferevent_pair_get_partner(struct bufferevent *bev); /** @@ -628,6 +776,7 @@ struct bufferevent_rate_limit_group; Note that all rate-limits hare are currently best-effort: future versions of Libevent may implement them more tightly. */ +EVENT2_EXPORT_SYMBOL struct ev_token_bucket_cfg *ev_token_bucket_cfg_new( size_t read_rate, size_t read_burst, size_t write_rate, size_t write_burst, @@ -638,6 +787,7 @@ struct ev_token_bucket_cfg *ev_token_bucket_cfg_new( Note: 'cfg' is not currently reference-counted; it is not safe to free it until no bufferevent is using it. */ +EVENT2_EXPORT_SYMBOL void ev_token_bucket_cfg_free(struct ev_token_bucket_cfg *cfg); /** @@ -651,6 +801,7 @@ void ev_token_bucket_cfg_free(struct ev_token_bucket_cfg *cfg); Return 0 on sucess, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int bufferevent_set_rate_limit(struct bufferevent *bev, struct ev_token_bucket_cfg *cfg); @@ -671,6 +822,7 @@ int bufferevent_set_rate_limit(struct bufferevent *bev, They are: socket-based bufferevents (normal and IOCP-based), and SSL-based bufferevents. */ +EVENT2_EXPORT_SYMBOL struct bufferevent_rate_limit_group *bufferevent_rate_limit_group_new( struct event_base *base, const struct ev_token_bucket_cfg *cfg); @@ -679,6 +831,7 @@ struct bufferevent_rate_limit_group *bufferevent_rate_limit_group_new( Return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int bufferevent_rate_limit_group_set_cfg( struct bufferevent_rate_limit_group *, const struct ev_token_bucket_cfg *); @@ -699,6 +852,7 @@ int bufferevent_rate_limit_group_set_cfg( Returns 0 on success, -1 on faulre. */ +EVENT2_EXPORT_SYMBOL int bufferevent_rate_limit_group_set_min_share( struct bufferevent_rate_limit_group *, size_t); @@ -706,6 +860,7 @@ int bufferevent_rate_limit_group_set_min_share( Free a rate-limiting group. The group must have no members when this function is called. */ +EVENT2_EXPORT_SYMBOL void bufferevent_rate_limit_group_free(struct bufferevent_rate_limit_group *); /** @@ -718,13 +873,43 @@ void bufferevent_rate_limit_group_free(struct bufferevent_rate_limit_group *); Return 0 on success and -1 on failure. */ +EVENT2_EXPORT_SYMBOL int bufferevent_add_to_rate_limit_group(struct bufferevent *bev, struct bufferevent_rate_limit_group *g); /** Remove 'bev' from its current rate-limit group (if any). */ +EVENT2_EXPORT_SYMBOL int bufferevent_remove_from_rate_limit_group(struct bufferevent *bev); /** + Set the size limit for single read operation. + + Set to 0 for a reasonable default. + + Return 0 on success and -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_max_single_read(struct bufferevent *bev, size_t size); + +/** + Set the size limit for single write operation. + + Set to 0 for a reasonable default. + + Return 0 on success and -1 on failure. + */ +EVENT2_EXPORT_SYMBOL +int bufferevent_set_max_single_write(struct bufferevent *bev, size_t size); + +/** Get the current size limit for single read operation. */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_single_read(struct bufferevent *bev); + +/** Get the current size limit for single write operation. */ +EVENT2_EXPORT_SYMBOL +ev_ssize_t bufferevent_get_max_single_write(struct bufferevent *bev); + +/** @name Rate limit inspection Return the current read or write bucket size for a bufferevent. @@ -735,13 +920,20 @@ int bufferevent_remove_from_rate_limit_group(struct bufferevent *bev); @{ */ +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_get_read_limit(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_get_write_limit(struct bufferevent *bev); /*@}*/ +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_get_max_to_read(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_get_max_to_write(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL +const struct ev_token_bucket_cfg *bufferevent_get_token_bucket_cfg(const struct bufferevent * bev); + /** @name Group Rate limit inspection @@ -751,8 +943,10 @@ ev_ssize_t bufferevent_get_max_to_write(struct bufferevent *bev); @{ */ +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_rate_limit_group_get_read_limit( struct bufferevent_rate_limit_group *); +EVENT2_EXPORT_SYMBOL ev_ssize_t bufferevent_rate_limit_group_get_write_limit( struct bufferevent_rate_limit_group *); /*@}*/ @@ -771,7 +965,9 @@ ev_ssize_t bufferevent_rate_limit_group_get_write_limit( @{ */ +EVENT2_EXPORT_SYMBOL int bufferevent_decrement_read_limit(struct bufferevent *bev, ev_ssize_t decr); +EVENT2_EXPORT_SYMBOL int bufferevent_decrement_write_limit(struct bufferevent *bev, ev_ssize_t decr); /*@}*/ @@ -788,8 +984,10 @@ int bufferevent_decrement_write_limit(struct bufferevent *bev, ev_ssize_t decr); @{ */ +EVENT2_EXPORT_SYMBOL int bufferevent_rate_limit_group_decrement_read( struct bufferevent_rate_limit_group *, ev_ssize_t); +EVENT2_EXPORT_SYMBOL int bufferevent_rate_limit_group_decrement_write( struct bufferevent_rate_limit_group *, ev_ssize_t); /*@}*/ @@ -801,6 +999,7 @@ int bufferevent_rate_limit_group_decrement_write( * Set the variable pointed to by total_read_out to the total number of bytes * ever read on grp, and the variable pointed to by total_written_out to the * total number of bytes ever written on grp. */ +EVENT2_EXPORT_SYMBOL void bufferevent_rate_limit_group_get_totals( struct bufferevent_rate_limit_group *grp, ev_uint64_t *total_read_out, ev_uint64_t *total_written_out); @@ -810,6 +1009,7 @@ void bufferevent_rate_limit_group_get_totals( * * Reset the number of bytes read or written on grp as given by * bufferevent_rate_limit_group_reset_totals(). */ +EVENT2_EXPORT_SYMBOL void bufferevent_rate_limit_group_reset_totals( struct bufferevent_rate_limit_group *grp); @@ -818,4 +1018,4 @@ bufferevent_rate_limit_group_reset_totals( } #endif -#endif /* _EVENT2_BUFFEREVENT_H_ */ +#endif /* EVENT2_BUFFEREVENT_H_INCLUDED_ */ diff --git a/include/event2/bufferevent_compat.h b/include/event2/bufferevent_compat.h index 3256fd1..6548204 100644 --- a/include/event2/bufferevent_compat.h +++ b/include/event2/bufferevent_compat.h @@ -25,8 +25,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_BUFFEREVENT_COMPAT_H_ -#define _EVENT2_BUFFEREVENT_COMPAT_H_ +#ifndef EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_COMPAT_H_INCLUDED_ #define evbuffercb bufferevent_data_cb #define everrorcb bufferevent_event_cb diff --git a/include/event2/bufferevent_ssl.h b/include/event2/bufferevent_ssl.h index c612e99..bf39b84 100644 --- a/include/event2/bufferevent_ssl.h +++ b/include/event2/bufferevent_ssl.h @@ -23,14 +23,14 @@ * (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_BUFFEREVENT_SSL_H_ -#define _EVENT2_BUFFEREVENT_SSL_H_ +#ifndef EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ /** @file event2/bufferevent_ssl.h OpenSSL support for bufferevents. */ - +#include <event2/visibility.h> #include <event2/event-config.h> #include <event2/bufferevent.h> #include <event2/util.h> @@ -52,7 +52,7 @@ enum bufferevent_ssl_state { BUFFEREVENT_SSL_ACCEPTING = 2 }; -#if defined(_EVENT_HAVE_OPENSSL) || defined(_EVENT_IN_DOXYGEN) +#if defined(EVENT__HAVE_OPENSSL) || defined(EVENT_IN_DOXYGEN_) /** Create a new SSL bufferevent to send its data over another bufferevent. @@ -64,6 +64,7 @@ enum bufferevent_ssl_state { @param options One or more bufferevent_options @return A new bufferevent on success, or NULL on failure */ +EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_openssl_filter_new(struct event_base *base, struct bufferevent *underlying, @@ -81,6 +82,7 @@ bufferevent_openssl_filter_new(struct event_base *base, @param options One or more bufferevent_options @return A new bufferevent on success, or NULL on failure. */ +EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_openssl_socket_new(struct event_base *base, evutil_socket_t fd, @@ -88,14 +90,39 @@ bufferevent_openssl_socket_new(struct event_base *base, enum bufferevent_ssl_state state, int options); +/** Control how to report dirty SSL shutdowns. + + If the peer (or the network, or an attacker) closes the TCP + connection before closing the SSL channel, and the protocol is SSL >= v3, + this is a "dirty" shutdown. If allow_dirty_shutdown is 0 (default), + this is reported as BEV_EVENT_ERROR. + + If instead allow_dirty_shutdown=1, a dirty shutdown is reported as + BEV_EVENT_EOF. + + (Note that if the protocol is < SSLv3, you will always receive + BEV_EVENT_EOF, since SSL 2 and earlier cannot distinguish a secure + connection close from a dirty one. This is one reason (among many) + not to use SSL 2.) +*/ + +EVENT2_EXPORT_SYMBOL +int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev); +EVENT2_EXPORT_SYMBOL +void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev, + int allow_dirty_shutdown); + /** Return the underlying openssl SSL * object for an SSL bufferevent. */ +EVENT2_EXPORT_SYMBOL struct ssl_st * bufferevent_openssl_get_ssl(struct bufferevent *bufev); /** Tells a bufferevent to begin SSL renegotiation. */ +EVENT2_EXPORT_SYMBOL int bufferevent_ssl_renegotiate(struct bufferevent *bev); /** Return the most recent OpenSSL error reported on an SSL bufferevent. */ +EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_openssl_error(struct bufferevent *bev); #endif @@ -104,4 +131,4 @@ unsigned long bufferevent_get_openssl_error(struct bufferevent *bev); } #endif -#endif /* _EVENT2_BUFFEREVENT_SSL_H_ */ +#endif /* EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ */ diff --git a/include/event2/bufferevent_struct.h b/include/event2/bufferevent_struct.h index 02835c1..e84c082 100644 --- a/include/event2/bufferevent_struct.h +++ b/include/event2/bufferevent_struct.h @@ -24,8 +24,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_BUFFEREVENT_STRUCT_H_ -#define _EVENT2_BUFFEREVENT_STRUCT_H_ +#ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ +#define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ /** @file event2/bufferevent_struct.h @@ -42,10 +42,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -113,4 +113,4 @@ struct bufferevent { } #endif -#endif /* _EVENT2_BUFFEREVENT_STRUCT_H_ */ +#endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */ diff --git a/include/event2/dns.h b/include/event2/dns.h index 6677d4e..17cd86a 100644 --- a/include/event2/dns.h +++ b/include/event2/dns.h @@ -132,8 +132,10 @@ * with the next probe. */ -#ifndef _EVENT2_DNS_H_ -#define _EVENT2_DNS_H_ +#ifndef EVENT2_DNS_H_INCLUDED_ +#define EVENT2_DNS_H_INCLUDED_ + +#include <event2/visibility.h> #ifdef __cplusplus extern "C" { @@ -201,6 +203,12 @@ typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, struct evdns_base; struct event_base; +/** Flag for evdns_base_new: process resolv.conf. */ +#define EVDNS_BASE_INITIALIZE_NAMESERVERS 1 +/** Flag for evdns_base_new: Do not prevent the libevent event loop from + * exiting when we have no active dns requests. */ +#define EVDNS_BASE_DISABLE_WHEN_INACTIVE 0x8000 + /** Initialize the asynchronous DNS library. @@ -209,10 +217,12 @@ struct event_base; evdns_config_windows_nameservers() on Windows. @param event_base the event base to associate the dns client with - @param initialize_nameservers 1 if resolve.conf processing should occur + @param flags any of EVDNS_BASE_INITIALIZE_NAMESERVERS| + EVDNS_BASE_DISABLE_WHEN_INACTIVE @return evdns_base object if successful, or NULL if an error occurred. @see evdns_base_free() */ +EVENT2_EXPORT_SYMBOL struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize_nameservers); @@ -228,14 +238,25 @@ struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize active requests will return DNS_ERR_SHUTDOWN. @see evdns_base_new() */ +EVENT2_EXPORT_SYMBOL void evdns_base_free(struct evdns_base *base, int fail_requests); /** + Remove all hosts entries that have been loaded into the event_base via + evdns_base_load_hosts or via event_base_resolv_conf_parse. + + @param evdns_base the evdns base to remove outdated host addresses from + */ +EVENT2_EXPORT_SYMBOL +void evdns_base_clear_host_addresses(struct evdns_base *base); + +/** Convert a DNS error code to a string. @param err the DNS error code @return a string containing an explanation of the error code */ +EVENT2_EXPORT_SYMBOL const char *evdns_err_to_string(int err); @@ -250,6 +271,7 @@ const char *evdns_err_to_string(int err); @return 0 if successful, or -1 if an error occurred @see evdns_base_nameserver_ip_add() */ +EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address); @@ -265,6 +287,7 @@ int evdns_base_nameserver_add(struct evdns_base *base, @return the number of configured nameservers @see evdns_base_nameserver_add() */ +EVENT2_EXPORT_SYMBOL int evdns_base_count_nameservers(struct evdns_base *base); /** @@ -276,6 +299,7 @@ int evdns_base_count_nameservers(struct evdns_base *base); @return 0 if successful, or -1 if an error occurred @see evdns_base_resume() */ +EVENT2_EXPORT_SYMBOL int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base); @@ -289,6 +313,7 @@ int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base); @return 0 if successful, or -1 if an error occurred @see evdns_base_clear_nameservers_and_suspend() */ +EVENT2_EXPORT_SYMBOL int evdns_base_resume(struct evdns_base *base); /** @@ -308,12 +333,14 @@ int evdns_base_resume(struct evdns_base *base); @return 0 if successful, or -1 if an error occurred @see evdns_base_nameserver_add() */ +EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_ip_add(struct evdns_base *base, const char *ip_as_string); /** Add a nameserver by sockaddr. **/ +EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_sockaddr_add(struct evdns_base *base, const struct sockaddr *sa, ev_socklen_t len, unsigned flags); @@ -331,6 +358,7 @@ struct evdns_request; @return an evdns_request object if successful, or NULL if an error occurred. @see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6(), evdns_cancel_request() */ +EVENT2_EXPORT_SYMBOL struct evdns_request *evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr); /** @@ -344,6 +372,7 @@ struct evdns_request *evdns_base_resolve_ipv4(struct evdns_base *base, const cha @return an evdns_request object if successful, or NULL if an error occurred. @see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6(), evdns_cancel_request() */ +EVENT2_EXPORT_SYMBOL struct evdns_request *evdns_base_resolve_ipv6(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr); struct in_addr; @@ -360,6 +389,7 @@ struct in6_addr; @return an evdns_request object if successful, or NULL if an error occurred. @see evdns_resolve_reverse_ipv6(), evdns_cancel_request() */ +EVENT2_EXPORT_SYMBOL struct evdns_request *evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr); @@ -374,6 +404,7 @@ struct evdns_request *evdns_base_resolve_reverse(struct evdns_base *base, const @return an evdns_request object if successful, or NULL if an error occurred. @see evdns_resolve_reverse_ipv6(), evdns_cancel_request() */ +EVENT2_EXPORT_SYMBOL struct evdns_request *evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr); /** @@ -383,6 +414,7 @@ struct evdns_request *evdns_base_resolve_reverse_ipv6(struct evdns_base *base, c @param req the evdns_request that was returned by calling a resolve function @see evdns_base_resolve_ipv4(), evdns_base_resolve_ipv6, evdns_base_resolve_reverse */ +EVENT2_EXPORT_SYMBOL void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req); /** @@ -401,6 +433,7 @@ void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req); @param val the value to be set @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val); @@ -426,6 +459,7 @@ int evdns_base_set_option(struct evdns_base *base, const char *option, const cha occurred (see above) @see resolv.conf(3), evdns_config_windows_nameservers() */ +EVENT2_EXPORT_SYMBOL int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename); /** @@ -436,8 +470,12 @@ int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char Note that only evdns_getaddrinfo uses the /etc/hosts entries. + This function does not replace previously loaded hosts entries; to do that, + call evdns_base_clear_host_addresses first. + Return 0 on success, negative on failure. */ +EVENT2_EXPORT_SYMBOL int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); /** @@ -450,7 +488,8 @@ int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); @return 0 if successful, or -1 if an error occurred @see evdns_resolv_conf_parse() */ -#ifdef WIN32 +#ifdef _WIN32 +EVENT2_EXPORT_SYMBOL int evdns_base_config_windows_nameservers(struct evdns_base *); #define EVDNS_BASE_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED #endif @@ -459,6 +498,7 @@ int evdns_base_config_windows_nameservers(struct evdns_base *); /** Clear the list of search domains. */ +EVENT2_EXPORT_SYMBOL void evdns_base_search_clear(struct evdns_base *base); @@ -467,6 +507,7 @@ void evdns_base_search_clear(struct evdns_base *base); @param domain the domain to be added to the search list */ +EVENT2_EXPORT_SYMBOL void evdns_base_search_add(struct evdns_base *base, const char *domain); @@ -478,6 +519,7 @@ void evdns_base_search_add(struct evdns_base *base, const char *domain); @param ndots the new ndots parameter */ +EVENT2_EXPORT_SYMBOL void evdns_base_search_ndots_set(struct evdns_base *base, const int ndots); /** @@ -496,6 +538,7 @@ typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg); @param fn the callback to be invoked when a log message is generated */ +EVENT2_EXPORT_SYMBOL void evdns_set_log_fn(evdns_debug_log_fn_type fn); /** @@ -508,6 +551,7 @@ void evdns_set_log_fn(evdns_debug_log_fn_type fn); NOTE: This function has no effect in Libevent 2.0.4-alpha and later, since Libevent now provides its own secure RNG. */ +EVENT2_EXPORT_SYMBOL void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)); /** @@ -519,6 +563,7 @@ void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)); NOTE: This function has no effect in Libevent 2.0.4-alpha and later, since Libevent now provides its own secure RNG. */ +EVENT2_EXPORT_SYMBOL void evdns_set_random_bytes_fn(void (*fn)(char *, size_t)); /* @@ -572,36 +617,47 @@ typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, vo @param user_data Data to pass to the callback. @return an evdns_server_port structure for this server port. */ +EVENT2_EXPORT_SYMBOL struct evdns_server_port *evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data); /** Close down a DNS server port, and free associated structures. */ +EVENT2_EXPORT_SYMBOL void evdns_close_server_port(struct evdns_server_port *port); /** Sets some flags in a reply we're building. Allows setting of the AA or RD flags */ +EVENT2_EXPORT_SYMBOL void evdns_server_request_set_flags(struct evdns_server_request *req, int flags); /* Functions to add an answer to an in-progress DNS reply. */ +EVENT2_EXPORT_SYMBOL int evdns_server_request_add_reply(struct evdns_server_request *req, int section, const char *name, int type, int dns_class, int ttl, int datalen, int is_name, const char *data); +EVENT2_EXPORT_SYMBOL int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl); +EVENT2_EXPORT_SYMBOL int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl); +EVENT2_EXPORT_SYMBOL int evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl); +EVENT2_EXPORT_SYMBOL int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl); /** Send back a response to a DNS request, and free the request structure. */ +EVENT2_EXPORT_SYMBOL int evdns_server_request_respond(struct evdns_server_request *req, int err); /** Free a DNS request without sending back a reply. */ +EVENT2_EXPORT_SYMBOL int evdns_server_request_drop(struct evdns_server_request *req); struct sockaddr; /** Get the address that made a DNS request. */ -int evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, int addr_len); +EVENT2_EXPORT_SYMBOL +int evdns_server_request_get_requesting_addr(struct evdns_server_request *req, struct sockaddr *sa, int addr_len); /** Callback for evdns_getaddrinfo. */ typedef void (*evdns_getaddrinfo_cb)(int result, struct evutil_addrinfo *res, void *arg); @@ -625,6 +681,7 @@ struct evdns_getaddrinfo_request; * - For ai_socktype, we only handle SOCKTYPE_STREAM, SOCKTYPE_UDP, and 0. * - For ai_protocol, we only handle IPPROTO_TCP, IPPROTO_UDP, and 0. */ +EVENT2_EXPORT_SYMBOL struct evdns_getaddrinfo_request *evdns_getaddrinfo( struct evdns_base *dns_base, const char *nodename, const char *servname, @@ -634,10 +691,27 @@ struct evdns_getaddrinfo_request *evdns_getaddrinfo( /* Cancel an in-progress evdns_getaddrinfo. This MUST NOT be called after the * getaddrinfo's callback has been invoked. The resolves will be canceled, * and the callback will be invoked with the error EVUTIL_EAI_CANCEL. */ +EVENT2_EXPORT_SYMBOL void evdns_getaddrinfo_cancel(struct evdns_getaddrinfo_request *req); +/** + Retrieve the address of the 'idx'th configured nameserver. + + @param base The evdns_base to examine. + @param idx The index of the nameserver to get the address of. + @param sa A location to receive the server's address. + @param len The number of bytes available at sa. + + @return the number of bytes written into sa on success. On failure, returns + -1 if idx is greater than the number of configured nameservers, or a + value greater than 'len' if len was not high enough. + */ +EVENT2_EXPORT_SYMBOL +int evdns_base_get_nameserver_addr(struct evdns_base *base, int idx, + struct sockaddr *sa, ev_socklen_t len); + #ifdef __cplusplus } #endif -#endif /* !_EVENT2_DNS_H_ */ +#endif /* !EVENT2_DNS_H_INCLUDED_ */ diff --git a/include/event2/dns_compat.h b/include/event2/dns_compat.h index 7c1c776..965fd65 100644 --- a/include/event2/dns_compat.h +++ b/include/event2/dns_compat.h @@ -24,8 +24,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_DNS_COMPAT_H_ -#define _EVENT2_DNS_COMPAT_H_ +#ifndef EVENT2_DNS_COMPAT_H_INCLUDED_ +#define EVENT2_DNS_COMPAT_H_INCLUDED_ /** @file event2/dns_compat.h @@ -40,10 +40,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -324,7 +324,7 @@ void evdns_search_ndots_set(const int ndots); */ 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 +#ifdef _WIN32 int evdns_config_windows_nameservers(void); #define EVDNS_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED #endif @@ -333,4 +333,4 @@ int evdns_config_windows_nameservers(void); } #endif -#endif /* _EVENT2_EVENT_COMPAT_H_ */ +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/include/event2/dns_struct.h b/include/event2/dns_struct.h index 5a02a0b..593a8a7 100644 --- a/include/event2/dns_struct.h +++ b/include/event2/dns_struct.h @@ -24,8 +24,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_DNS_STRUCT_H_ -#define _EVENT2_DNS_STRUCT_H_ +#ifndef EVENT2_DNS_STRUCT_H_INCLUDED_ +#define EVENT2_DNS_STRUCT_H_INCLUDED_ /** @file event2/dns_struct.h @@ -39,10 +39,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -76,5 +76,5 @@ struct evdns_server_question { } #endif -#endif /* _EVENT2_DNS_STRUCT_H_ */ +#endif /* EVENT2_DNS_STRUCT_H_INCLUDED_ */ diff --git a/include/event2/event-config-bionic.h b/include/event2/event-config-bionic.h index 06fdebe..4287cac 100644 --- a/include/event2/event-config-bionic.h +++ b/include/event2/event-config-bionic.h @@ -12,434 +12,489 @@ #ifndef _EVENT2_EVENT_CONFIG_H_ #define _EVENT2_EVENT_CONFIG_H_ +#include <stddef.h> #include <stdint.h> /* The size of `size_t', as computed by sizeof. */ #if SIZE_MAX == UINT64_MAX -# define _EVENT_SIZEOF_SIZE_T 8 +# define EVENT__SIZEOF_SIZE_T 8 #elif SIZE_MAX == UINT32_MAX -# define _EVENT_SIZEOF_SIZE_T 4 +# define EVENT__SIZEOF_SIZE_T 4 #else # error "No way to infer sizeof size_t" #endif +#define EVENT__HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT8_T 1 +#define EVENT__HAVE_UINTPTR_T 1 + /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if libevent should build without support for a debug mode */ -/* #undef _EVENT_DISABLE_DEBUG_MODE */ +/* #undef EVENT__DISABLE_DEBUG_MODE */ /* Define if libevent should not allow replacing the mm functions */ -/* #undef _EVENT_DISABLE_MM_REPLACEMENT */ +/* #undef EVENT__DISABLE_MM_REPLACEMENT */ /* Define if libevent should not be compiled with thread support */ -/* #undef _EVENT_DISABLE_THREAD_SUPPORT */ +/* #undef EVENT__DISABLE_THREAD_SUPPORT */ + +/* Define to 1 if you have the `accept4' function. */ +#define EVENT__HAVE_ACCEPT4 1 /* Define to 1 if you have the `arc4random' function. */ -#define _EVENT_HAVE_ARC4RANDOM 1 +#define EVENT__HAVE_ARC4RANDOM 1 /* Define to 1 if you have the `arc4random_buf' function. */ -#define _EVENT_HAVE_ARC4RANDOM_BUF 1 +#define EVENT__HAVE_ARC4RANDOM_BUF 1 /* Define to 1 if you have the <arpa/inet.h> header file. */ -#define _EVENT_HAVE_ARPA_INET_H 1 +#define EVENT__HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `clock_gettime' function. */ -#define _EVENT_HAVE_CLOCK_GETTIME 1 +#define EVENT__HAVE_CLOCK_GETTIME 1 /* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you don't. */ -/* #undef _EVENT_HAVE_DECL_CTL_KERN */ +/* #undef EVENT__HAVE_DECL_CTL_KERN */ /* Define to 1 if you have the declaration of `KERN_ARND', and to 0 if you don't. */ -/* #undef _EVENT_HAVE_DECL_KERN_ARND */ +/* #undef EVENT__HAVE_DECL_KERN_ARND */ /* Define to 1 if you have the declaration of `KERN_RANDOM', and to 0 if you don't. */ -/* #undef _EVENT_HAVE_DECL_KERN_RANDOM */ +/* #undef EVENT__HAVE_DECL_KERN_RANDOM */ /* Define to 1 if you have the declaration of `RANDOM_UUID', and to 0 if you don't. */ -/* #undef _EVENT_HAVE_DECL_RANDOM_UUID */ +/* #undef EVENT__HAVE_DECL_RANDOM_UUID */ /* Define if /dev/poll is available */ -/* #undef _EVENT_HAVE_DEVPOLL */ +/* #undef EVENT__HAVE_DEVPOLL */ /* Define to 1 if you have the <dlfcn.h> header file. */ -#define _EVENT_HAVE_DLFCN_H 1 +#define EVENT__HAVE_DLFCN_H 1 /* Define if your system supports the epoll system calls */ -#define _EVENT_HAVE_EPOLL 1 +#define EVENT__HAVE_EPOLL 1 + +/* Define to 1 if you have the `epoll_create1' function. */ +#define EVENT__HAVE_EPOLL_CREATE1 1 /* Define to 1 if you have the `epoll_ctl' function. */ -#define _EVENT_HAVE_EPOLL_CTL 1 +#define EVENT__HAVE_EPOLL_CTL 1 + +/* Define to 1 if you have the <errno.h> header file. */ +#define EVENT__HAVE_ERRNO_H 1 + +/* Define to 1 if you have ERR_remove_thread_stat(). */ +#undef EVENT__HAVE_ERR_REMOVE_THREAD_STATE /* Define to 1 if you have the `eventfd' function. */ -#define _EVENT_HAVE_EVENTFD 1 +#define EVENT__HAVE_EVENTFD 1 /* Define if your system supports event ports */ -/* #undef _EVENT_HAVE_EVENT_PORTS */ +/* #undef EVENT__HAVE_EVENT_PORTS */ /* Define to 1 if you have the `fcntl' function. */ -#define _EVENT_HAVE_FCNTL 1 +#define EVENT__HAVE_FCNTL 1 /* Define to 1 if you have the <fcntl.h> header file. */ -#define _EVENT_HAVE_FCNTL_H 1 +#define EVENT__HAVE_FCNTL_H 1 /* Define to 1 if the system has the type `fd_mask'. */ -/* #undef _EVENT_HAVE_FD_MASK */ +/* #undef EVENT__HAVE_FD_MASK */ /* Do we have getaddrinfo()? */ -#define _EVENT_HAVE_GETADDRINFO 1 +#define EVENT__HAVE_GETADDRINFO 1 /* Define to 1 if you have the `getegid' function. */ -#define _EVENT_HAVE_GETEGID 1 +#define EVENT__HAVE_GETEGID 1 /* Define to 1 if you have the `geteuid' function. */ -#define _EVENT_HAVE_GETEUID 1 +#define EVENT__HAVE_GETEUID 1 /* Define this if you have any gethostbyname_r() */ -#define _EVENT_HAVE_GETHOSTBYNAME_R 1 +#define EVENT__HAVE_GETHOSTBYNAME_R 1 /* Define this if gethostbyname_r takes 3 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_3_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_3_ARG */ /* Define this if gethostbyname_r takes 5 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_5_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_5_ARG */ /* Define this if gethostbyname_r takes 6 arguments */ -#define _EVENT_HAVE_GETHOSTBYNAME_R_6_ARG 1 +#define EVENT__HAVE_GETHOSTBYNAME_R_6_ARG 1 + +/* Define to 1 if you have the `getifaddrs' function. */ +#define EVENT__HAVE_GETIFADDRS 1 /* Define to 1 if you have the `getnameinfo' function. */ -#define _EVENT_HAVE_GETNAMEINFO 1 +#define EVENT__HAVE_GETNAMEINFO 1 /* Define to 1 if you have the `getprotobynumber' function. */ -#define _EVENT_HAVE_GETPROTOBYNUMBER 1 +#define EVENT__HAVE_GETPROTOBYNUMBER 1 /* Define to 1 if you have the `getservbyname' function. */ -/* #undef _EVENT_HAVE_GETSERVBYNAME */ +/* #undef EVENT__HAVE_GETSERVBYNAME */ /* Define to 1 if you have the `gettimeofday' function. */ -#define _EVENT_HAVE_GETTIMEOFDAY 1 +#define EVENT__HAVE_GETTIMEOFDAY 1 -/* Define to 1 if you have the `inet_aton' function. */ -#define _EVENT_HAVE_INET_ATON 1 +/* Define to 1 if you have the <ifaddrs.h> header file. */ +#define EVENT__HAVE_IFADDRS_H 1 /* Define to 1 if you have the `inet_ntop' function. */ -#define _EVENT_HAVE_INET_NTOP 1 +#define EVENT__HAVE_INET_NTOP 1 /* Define to 1 if you have the `inet_pton' function. */ -#define _EVENT_HAVE_INET_PTON 1 +#define EVENT__HAVE_INET_PTON 1 /* Define to 1 if you have the <inttypes.h> header file. */ -#define _EVENT_HAVE_INTTYPES_H 1 +#define EVENT__HAVE_INTTYPES_H 1 /* Define to 1 if you have the `issetugid' function. */ -/* #undef _EVENT_HAVE_ISSETUGID */ +/* #undef EVENT__HAVE_ISSETUGID */ /* Define to 1 if you have the `kqueue' function. */ -/* #undef _EVENT_HAVE_KQUEUE */ +/* #undef EVENT__HAVE_KQUEUE */ /* Define if the system has zlib */ -#define _EVENT_HAVE_LIBZ 1 +#define EVENT__HAVE_LIBZ 1 + +/* Define to 1 if you have the `mach_absolute_time' function. */ +#undef HAVE_MACH_ABSOLUTE_TIME + +/* Define to 1 if you have the <mach/mach_time.h> header file. */ +#undef HAVE_MACH_MACH_TIME_H /* Define to 1 if you have the <memory.h> header file. */ -#define _EVENT_HAVE_MEMORY_H 1 +#define EVENT__HAVE_MEMORY_H 1 /* Define to 1 if you have the `mmap' function. */ -#define _EVENT_HAVE_MMAP 1 +#define EVENT__HAVE_MMAP 1 + +/* Define to 1 if you have the `nanosleep' function. */ +#define EVENT__HAVE_NANOSLEEP 1 /* Define to 1 if you have the <netdb.h> header file. */ -#define _EVENT_HAVE_NETDB_H 1 +#define EVENT__HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in6.h> header file. */ -#define _EVENT_HAVE_NETINET_IN6_H 1 +#define EVENT__HAVE_NETINET_IN6_H 1 /* Define to 1 if you have the <netinet/in.h> header file. */ -#define _EVENT_HAVE_NETINET_IN_H 1 +#define EVENT__HAVE_NETINET_IN_H 1 -/* Define if the system has openssl */ -#define _EVENT_HAVE_OPENSSL 1 +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +#define EVENT__HAVE_NETINET_TCP_H 1 -/* Define to 1 if you have the <openssl/bio.h> header file. */ -/* #undef _EVENT_HAVE_OPENSSL_BIO_H */ +/* Define if the system has openssl */ +#define EVENT__HAVE_OPENSSL 1 /* Define to 1 if you have the `pipe' function. */ -#define _EVENT_HAVE_PIPE 1 +#define EVENT__HAVE_PIPE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define EVENT__HAVE_PIPE2 1 /* Define to 1 if you have the `poll' function. */ -#define _EVENT_HAVE_POLL 1 +#define EVENT__HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ -#define _EVENT_HAVE_POLL_H 1 +#define EVENT__HAVE_POLL_H 1 /* Define to 1 if you have the `port_create' function. */ -/* #undef _EVENT_HAVE_PORT_CREATE */ +/* #undef EVENT__HAVE_PORT_CREATE */ /* Define to 1 if you have the <port.h> header file. */ -/* #undef _EVENT_HAVE_PORT_H */ +/* #undef EVENT__HAVE_PORT_H */ /* Define if you have POSIX threads libraries and header files. */ -/* #undef _EVENT_HAVE_PTHREAD */ +/* #undef EVENT__HAVE_PTHREAD */ /* Define if we have pthreads on this system */ -#define _EVENT_HAVE_PTHREADS 1 +#define EVENT__HAVE_PTHREADS 1 /* Define to 1 if you have the `putenv' function. */ -#define _EVENT_HAVE_PUTENV 1 +#define EVENT__HAVE_PUTENV 1 /* Define to 1 if the system has the type `sa_family_t'. */ -#define _EVENT_HAVE_SA_FAMILY_T 1 +#define EVENT__HAVE_SA_FAMILY_T 1 /* Define to 1 if you have the `select' function. */ -#define _EVENT_HAVE_SELECT 1 +#define EVENT__HAVE_SELECT 1 /* Define to 1 if you have the `sendfile' function. */ -#define _EVENT_HAVE_SENDFILE 1 +#define EVENT__HAVE_SENDFILE 1 /* Define to 1 if you have the `setenv' function. */ -#define _EVENT_HAVE_SETENV 1 +#define EVENT__HAVE_SETENV 1 /* Define if F_SETFD is defined in <fcntl.h> */ -#define _EVENT_HAVE_SETFD 1 +#define EVENT__HAVE_SETFD 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#define HAVE_SETRLIMIT 1 /* Define to 1 if you have the `sigaction' function. */ -#define _EVENT_HAVE_SIGACTION 1 +#define EVENT__HAVE_SIGACTION 1 /* Define to 1 if you have the `signal' function. */ -#define _EVENT_HAVE_SIGNAL 1 +#define EVENT__HAVE_SIGNAL 1 /* Define to 1 if you have the `splice' function. */ -#define _EVENT_HAVE_SPLICE 1 +#define EVENT__HAVE_SPLICE 1 /* Define to 1 if you have the <stdarg.h> header file. */ -#define _EVENT_HAVE_STDARG_H 1 +#define EVENT__HAVE_STDARG_H 1 /* Define to 1 if you have the <stddef.h> header file. */ -#define _EVENT_HAVE_STDDEF_H 1 +#define EVENT__HAVE_STDDEF_H 1 /* Define to 1 if you have the <stdint.h> header file. */ -#define _EVENT_HAVE_STDINT_H 1 +#define EVENT__HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ -#define _EVENT_HAVE_STDLIB_H 1 +#define EVENT__HAVE_STDLIB_H 1 /* Define to 1 if you have the <strings.h> header file. */ -#define _EVENT_HAVE_STRINGS_H 1 +#define EVENT__HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ -#define _EVENT_HAVE_STRING_H 1 +#define EVENT__HAVE_STRING_H 1 /* Define to 1 if you have the `strlcpy' function. */ -#define _EVENT_HAVE_STRLCPY 1 +#define EVENT__HAVE_STRLCPY 1 /* Define to 1 if you have the `strsep' function. */ -#define _EVENT_HAVE_STRSEP 1 +#define EVENT__HAVE_STRSEP 1 /* Define to 1 if you have the `strtok_r' function. */ -#define _EVENT_HAVE_STRTOK_R 1 +#define EVENT__HAVE_STRTOK_R 1 /* Define to 1 if you have the `strtoll' function. */ -#define _EVENT_HAVE_STRTOLL 1 +#define EVENT__HAVE_STRTOLL 1 /* Define to 1 if the system has the type `struct addrinfo'. */ -#define _EVENT_HAVE_STRUCT_ADDRINFO 1 +#define EVENT__HAVE_STRUCT_ADDRINFO 1 /* Define to 1 if the system has the type `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR 1 /* Define to 1 if `s6_addr16' is a member of `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 /* Define to 1 if `s6_addr32' is a member of `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 /* Define to 1 if the system has the type `struct sockaddr_in6'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_IN6 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Define to 1 if the system has the type `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if the system has the type `struct so_linger'. */ +#define HAVE_STRUCT_SO_LINGER 1 /* Define to 1 if you have the `sysctl' function. */ -/* #undef _EVENT_HAVE_SYSCTL */ +/* #undef EVENT__HAVE_SYSCTL */ /* Define to 1 if you have the <sys/devpoll.h> header file. */ -/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ +/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ /* Define to 1 if you have the <sys/epoll.h> header file. */ -#define _EVENT_HAVE_SYS_EPOLL_H 1 +#define EVENT__HAVE_SYS_EPOLL_H 1 /* Define to 1 if you have the <sys/eventfd.h> header file. */ -#define _EVENT_HAVE_SYS_EVENTFD_H 1 +#define EVENT__HAVE_SYS_EVENTFD_H 1 /* Define to 1 if you have the <sys/event.h> header file. */ -/* #undef _EVENT_HAVE_SYS_EVENT_H */ +/* #undef EVENT__HAVE_SYS_EVENT_H */ /* Define to 1 if you have the <sys/ioctl.h> header file. */ -#define _EVENT_HAVE_SYS_IOCTL_H 1 +#define EVENT__HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/mman.h> header file. */ -#define _EVENT_HAVE_SYS_MMAN_H 1 +#define EVENT__HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the <sys/param.h> header file. */ -#define _EVENT_HAVE_SYS_PARAM_H 1 +#define EVENT__HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/queue.h> header file. */ -#define _EVENT_HAVE_SYS_QUEUE_H 1 +#define EVENT__HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have the <sys/select.h> header file. */ -#define _EVENT_HAVE_SYS_SELECT_H 1 +#define EVENT__HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the <sys/sendfile.h> header file. */ -#define _EVENT_HAVE_SYS_SENDFILE_H 1 +#define EVENT__HAVE_SYS_SENDFILE_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ -#define _EVENT_HAVE_SYS_SOCKET_H 1 +#define EVENT__HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ -#define _EVENT_HAVE_SYS_STAT_H 1 +#define EVENT__HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysctl.h> header file. */ -/* #undef _EVENT_HAVE_SYS_SYSCTL_H */ +/* #undef EVENT__HAVE_SYS_SYSCTL_H */ + +/* Define to 1 if you have the <sys/timerfd.h> header file. */ +#define HAVE_SYS_TIMERFD_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ -#define _EVENT_HAVE_SYS_TIME_H 1 +#define EVENT__HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ -#define _EVENT_HAVE_SYS_TYPES_H 1 +#define EVENT__HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ -#define _EVENT_HAVE_SYS_UIO_H 1 +#define EVENT__HAVE_SYS_UIO_H 1 /* Define to 1 if you have the <sys/wait.h> header file. */ -#define _EVENT_HAVE_SYS_WAIT_H 1 +#define EVENT__HAVE_SYS_WAIT_H 1 /* Define if TAILQ_FOREACH is defined in <sys/queue.h> */ -/*#define _EVENT_HAVE_TAILQFOREACH 1 */ +/*#define EVENT__HAVE_TAILQFOREACH 1 */ /* Define if timeradd is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERADD 1 +#define EVENT__HAVE_TIMERADD 1 /* Define if timerclear is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCLEAR 1 +#define EVENT__HAVE_TIMERCLEAR 1 /* Define if timercmp is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCMP 1 +#define EVENT__HAVE_TIMERCMP 1 + +/* Define to 1 if you have the `timerfd_create' function. */ +#define HAVE_TIMERFD_CREATE 1 /* Define if timerisset is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERISSET 1 +#define EVENT__HAVE_TIMERISSET 1 /* Define to 1 if the system has the type `uint16_t'. */ -#define _EVENT_HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT16_T 1 /* Define to 1 if the system has the type `uint32_t'. */ -#define _EVENT_HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT32_T 1 /* Define to 1 if the system has the type `uint64_t'. */ -#define _EVENT_HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT64_T 1 /* Define to 1 if the system has the type `uint8_t'. */ -#define _EVENT_HAVE_UINT8_T 1 +#define EVENT__HAVE_UINT8_T 1 /* Define to 1 if the system has the type `uintptr_t'. */ -#define _EVENT_HAVE_UINTPTR_T 1 +#define EVENT__HAVE_UINTPTR_T 1 /* Define to 1 if you have the `umask' function. */ -#define _EVENT_HAVE_UMASK 1 +#define EVENT__HAVE_UMASK 1 /* Define to 1 if you have the <unistd.h> header file. */ -#define _EVENT_HAVE_UNISTD_H 1 +#define EVENT__HAVE_UNISTD_H 1 /* Define to 1 if you have the `unsetenv' function. */ -#define _EVENT_HAVE_UNSETENV 1 +#define EVENT__HAVE_UNSETENV 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 /* Define to 1 if you have the `vasprintf' function. */ -#define _EVENT_HAVE_VASPRINTF 1 +#define EVENT__HAVE_VASPRINTF 1 + +/* Define if waitpid() supports WNOWAIT */ +#define HAVE_WAITPID_WITH_WNOWAIT 1 /* Define if kqueue works correctly with pipes */ -/* #undef _EVENT_HAVE_WORKING_KQUEUE */ +/* #undef EVENT__HAVE_WORKING_KQUEUE */ /* Define to 1 if you have the <zlib.h> header file. */ -#define _EVENT_HAVE_ZLIB_H 1 +#define EVENT__HAVE_ZLIB_H 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ -#define _EVENT_LT_OBJDIR ".libs/" +#define EVENT__LT_OBJDIR ".libs/" /* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef _EVENT_NO_MINUS_C_MINUS_O */ +/* #undef EVENT__NO_MINUS_C_MINUS_O */ /* Numeric representation of the version */ -#define _EVENT_NUMERIC_VERSION 0x02001600 +#define EVENT__NUMERIC_VERSION 0x02001600 /* Name of package */ -#define _EVENT_PACKAGE "libevent" +#define EVENT__PACKAGE "libevent" /* Define to the address where bug reports for this package should be sent. */ -#define _EVENT_PACKAGE_BUGREPORT "" +#define EVENT__PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ -#define _EVENT_PACKAGE_NAME "" +#define EVENT__PACKAGE_NAME "" /* Define to the full name and version of this package. */ -#define _EVENT_PACKAGE_STRING "" +#define EVENT__PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ -#define _EVENT_PACKAGE_TARNAME "" +#define EVENT__PACKAGE_TARNAME "" /* Define to the home page for this package. */ -#define _EVENT_PACKAGE_URL "" +#define EVENT__PACKAGE_URL "" /* Define to the version of this package. */ -#define _EVENT_PACKAGE_VERSION "" +#define EVENT__PACKAGE_VERSION "" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ -/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */ +/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ /* Define to 1 if you have the ANSI C header files. */ -#define _EVENT_STDC_HEADERS 1 +#define EVENT__STDC_HEADERS 1 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#define _EVENT_TIME_WITH_SYS_TIME 1 +#define EVENT__TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define _EVENT_VERSION "2.0.22-stable" +#define EVENT__VERSION "2.1.8-stable" /* Define to appropriate substitue if compiler doesnt have __func__ */ -/* #undef _EVENT___func__ */ +/* #undef EVENT____func__ */ /* Define to empty if `const' does not conform to ANSI C. */ -/* #undef _EVENT_const */ +/* #undef EVENT__const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef _EVENT___cplusplus -/* #undef _EVENT_inline */ +#ifndef EVENT____cplusplus +/* #undef EVENT__inline */ #endif /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_pid_t */ +/* #undef EVENT__pid_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ -/* #undef _EVENT_size_t */ +/* #undef EVENT__size_t */ /* Define to unsigned int if you dont have it */ -/* #undef _EVENT_socklen_t */ +/* #undef EVENT__socklen_t */ /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_ssize_t */ +/* #undef EVENT__ssize_t */ #endif /* event2/event-config.h */ diff --git a/include/event2/event-config-darwin.h b/include/event2/event-config-darwin.h index 4d4e239..961257f 100644 --- a/include/event2/event-config-darwin.h +++ b/include/event2/event-config-darwin.h @@ -11,456 +11,511 @@ #ifndef _EVENT2_EVENT_CONFIG_H_ #define _EVENT2_EVENT_CONFIG_H_ +#include <stddef.h> #include <stdint.h> /* The size of `size_t', as computed by sizeof. */ #if SIZE_MAX == UINT64_MAX -# define _EVENT_SIZEOF_SIZE_T 8 +# define EVENT__SIZEOF_SIZE_T 8 #elif SIZE_MAX == UINT32_MAX -# define _EVENT_SIZEOF_SIZE_T 4 +# define EVENT__SIZEOF_SIZE_T 4 #else # error "No way to infer sizeof size_t" #endif +#define EVENT__HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT8_T 1 +#define EVENT__HAVE_UINTPTR_T 1 + /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if libevent should build without support for a debug mode */ -/* #undef _EVENT_DISABLE_DEBUG_MODE */ +/* #undef EVENT__DISABLE_DEBUG_MODE */ /* Define if libevent should not allow replacing the mm functions */ -/* #undef _EVENT_DISABLE_MM_REPLACEMENT */ +/* #undef EVENT__DISABLE_MM_REPLACEMENT */ /* Define if libevent should not be compiled with thread support */ -/* #undef _EVENT_DISABLE_THREAD_SUPPORT */ +/* #undef EVENT__DISABLE_THREAD_SUPPORT */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef EVENT__HAVE_ACCEPT4 */ /* Define to 1 if you have the `arc4random' function. */ -#define _EVENT_HAVE_ARC4RANDOM 1 +#define EVENT__HAVE_ARC4RANDOM 1 /* Define to 1 if you have the `arc4random_buf' function. */ -#define _EVENT_HAVE_ARC4RANDOM_BUF 1 +#define EVENT__HAVE_ARC4RANDOM_BUF 1 /* Define to 1 if you have the <arpa/inet.h> header file. */ -#define _EVENT_HAVE_ARPA_INET_H 1 +#define EVENT__HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `clock_gettime' function. */ -/* #undef _EVENT_HAVE_CLOCK_GETTIME */ +/* #undef EVENT__HAVE_CLOCK_GETTIME */ /* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_CTL_KERN 1 +#define EVENT__HAVE_DECL_CTL_KERN 1 /* Define to 1 if you have the declaration of `KERN_ARND', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_KERN_ARND 0 +#define EVENT__HAVE_DECL_KERN_ARND 0 /* Define to 1 if you have the declaration of `KERN_RANDOM', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_KERN_RANDOM 0 +#define EVENT__HAVE_DECL_KERN_RANDOM 0 /* Define to 1 if you have the declaration of `RANDOM_UUID', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_RANDOM_UUID 0 +#define EVENT__HAVE_DECL_RANDOM_UUID 0 /* Define if /dev/poll is available */ -/* #undef _EVENT_HAVE_DEVPOLL */ +/* #undef EVENT__HAVE_DEVPOLL */ /* Define to 1 if you have the <dlfcn.h> header file. */ -#define _EVENT_HAVE_DLFCN_H 1 +#define EVENT__HAVE_DLFCN_H 1 /* Define if your system supports the epoll system calls */ -/* #undef _EVENT_HAVE_EPOLL */ +/* #undef EVENT__HAVE_EPOLL */ + +/* Define to 1 if you have the `epoll_create1' function. */ +/* #undef EVENT__HAVE_EPOLL_CREATE1 */ /* Define to 1 if you have the `epoll_ctl' function. */ -/* #undef _EVENT_HAVE_EPOLL_CTL */ +/* #undef EVENT__HAVE_EPOLL_CTL */ + +/* Define to 1 if you have the <errno.h> header file. */ +#define EVENT__HAVE_ERRNO_H 1 + +/* Define to 1 if you have ERR_remove_thread_stat(). */ +/* #undef EVENT__HAVE_ERR_REMOVE_THREAD_STATE */ /* Define to 1 if you have the `eventfd' function. */ -/* #undef _EVENT_HAVE_EVENTFD */ +/* #undef EVENT__HAVE_EVENTFD */ /* Define if your system supports event ports */ -/* #undef _EVENT_HAVE_EVENT_PORTS */ +/* #undef EVENT__HAVE_EVENT_PORTS */ /* Define to 1 if you have the `fcntl' function. */ -#define _EVENT_HAVE_FCNTL 1 +#define EVENT__HAVE_FCNTL 1 /* Define to 1 if you have the <fcntl.h> header file. */ -#define _EVENT_HAVE_FCNTL_H 1 +#define EVENT__HAVE_FCNTL_H 1 /* Define to 1 if the system has the type `fd_mask'. */ -#define _EVENT_HAVE_FD_MASK 1 +#define EVENT__HAVE_FD_MASK 1 /* Do we have getaddrinfo()? */ -#define _EVENT_HAVE_GETADDRINFO 1 +#define EVENT__HAVE_GETADDRINFO 1 /* Define to 1 if you have the `getegid' function. */ -#define _EVENT_HAVE_GETEGID 1 +#define EVENT__HAVE_GETEGID 1 /* Define to 1 if you have the `geteuid' function. */ -#define _EVENT_HAVE_GETEUID 1 +#define EVENT__HAVE_GETEUID 1 /* Define this if you have any gethostbyname_r() */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R */ /* Define this if gethostbyname_r takes 3 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_3_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_3_ARG */ /* Define this if gethostbyname_r takes 5 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_5_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_5_ARG */ /* Define this if gethostbyname_r takes 6 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_6_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getifaddrs' function. */ +#define EVENT__HAVE_GETIFADDRS 1 /* Define to 1 if you have the `getnameinfo' function. */ -#define _EVENT_HAVE_GETNAMEINFO 1 +#define EVENT__HAVE_GETNAMEINFO 1 /* Define to 1 if you have the `getprotobynumber' function. */ -#define _EVENT_HAVE_GETPROTOBYNUMBER 1 +#define EVENT__HAVE_GETPROTOBYNUMBER 1 /* Define to 1 if you have the `getservbyname' function. */ -/* #undef _EVENT_HAVE_GETSERVBYNAME */ +/* #undef EVENT__HAVE_GETSERVBYNAME */ /* Define to 1 if you have the `gettimeofday' function. */ -#define _EVENT_HAVE_GETTIMEOFDAY 1 +#define EVENT__HAVE_GETTIMEOFDAY 1 -/* Define to 1 if you have the `inet_aton' function. */ -#define _EVENT_HAVE_INET_ATON 1 +/* Define to 1 if you have the <ifaddrs.h> header file. */ +#define EVENT__HAVE_IFADDRS_H 1 /* Define to 1 if you have the `inet_ntop' function. */ -#define _EVENT_HAVE_INET_NTOP 1 +#define EVENT__HAVE_INET_NTOP 1 /* Define to 1 if you have the `inet_pton' function. */ -#define _EVENT_HAVE_INET_PTON 1 +#define EVENT__HAVE_INET_PTON 1 /* Define to 1 if you have the <inttypes.h> header file. */ -#define _EVENT_HAVE_INTTYPES_H 1 +#define EVENT__HAVE_INTTYPES_H 1 /* Define to 1 if you have the `issetugid' function. */ -#define _EVENT_HAVE_ISSETUGID 1 +#define EVENT__HAVE_ISSETUGID 1 /* Define to 1 if you have the `kqueue' function. */ -#define _EVENT_HAVE_KQUEUE 1 +#define EVENT__HAVE_KQUEUE 1 /* Define if the system has zlib */ -#define _EVENT_HAVE_LIBZ 1 +#define EVENT__HAVE_LIBZ 1 + +/* Define to 1 if you have the `mach_absolute_time' function. */ +#define HAVE_MACH_ABSOLUTE_TIME 1 + +/* Define to 1 if you have the <mach/mach_time.h> header file. */ +#define HAVE_MACH_MACH_TIME_H 1 /* Define to 1 if you have the <memory.h> header file. */ -#define _EVENT_HAVE_MEMORY_H 1 +#define EVENT__HAVE_MEMORY_H 1 /* Define to 1 if you have the `mmap' function. */ -#define _EVENT_HAVE_MMAP 1 +#define EVENT__HAVE_MMAP 1 + +/* Define to 1 if you have the `nanosleep' function. */ +#define HAVE_NANOSLEEP 1 /* Define to 1 if you have the <netdb.h> header file. */ -#define _EVENT_HAVE_NETDB_H 1 +#define EVENT__HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in6.h> header file. */ -/* #undef _EVENT_HAVE_NETINET_IN6_H */ +/* #undef EVENT__HAVE_NETINET_IN6_H */ /* Define to 1 if you have the <netinet/in.h> header file. */ -#define _EVENT_HAVE_NETINET_IN_H 1 +#define EVENT__HAVE_NETINET_IN_H 1 -/* Define if the system has openssl */ -#define _EVENT_HAVE_OPENSSL 1 +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +#define HAVE_NETINET_TCP_H 1 -/* Define to 1 if you have the <openssl/bio.h> header file. */ -#define _EVENT_HAVE_OPENSSL_BIO_H 1 +/* Define if the system has openssl */ +#define EVENT__HAVE_OPENSSL 1 /* Define to 1 if you have the `pipe' function. */ -#define _EVENT_HAVE_PIPE 1 +#define EVENT__HAVE_PIPE 1 + +/* Define to 1 if you have the `pipe2' function. */ +/* #undef EVENT__HAVE_PIPE2 */ /* Define to 1 if you have the `poll' function. */ -#define _EVENT_HAVE_POLL 1 +#define EVENT__HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ -#define _EVENT_HAVE_POLL_H 1 +#define EVENT__HAVE_POLL_H 1 /* Define to 1 if you have the `port_create' function. */ -/* #undef _EVENT_HAVE_PORT_CREATE */ +/* #undef EVENT__HAVE_PORT_CREATE */ /* Define to 1 if you have the <port.h> header file. */ -/* #undef _EVENT_HAVE_PORT_H */ +/* #undef EVENT__HAVE_PORT_H */ /* Define if you have POSIX threads libraries and header files. */ -/* #undef _EVENT_HAVE_PTHREAD */ +/* #undef EVENT__HAVE_PTHREAD */ /* Define if we have pthreads on this system */ -#define _EVENT_HAVE_PTHREADS 1 +#define EVENT__HAVE_PTHREADS 1 /* Define to 1 if you have the `putenv' function. */ -#define _EVENT_HAVE_PUTENV 1 +#define EVENT__HAVE_PUTENV 1 /* Define to 1 if the system has the type `sa_family_t'. */ -#define _EVENT_HAVE_SA_FAMILY_T 1 +#define EVENT__HAVE_SA_FAMILY_T 1 /* Define to 1 if you have the `select' function. */ -#define _EVENT_HAVE_SELECT 1 +#define EVENT__HAVE_SELECT 1 /* Define to 1 if you have the `sendfile' function. */ -#define _EVENT_HAVE_SENDFILE 1 +#define EVENT__HAVE_SENDFILE 1 /* Define to 1 if you have the `setenv' function. */ -#define _EVENT_HAVE_SETENV 1 +#define EVENT__HAVE_SETENV 1 /* Define if F_SETFD is defined in <fcntl.h> */ -#define _EVENT_HAVE_SETFD 1 +#define EVENT__HAVE_SETFD 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#define EVENT__HAVE_SETRLIMIT 1 /* Define to 1 if you have the `sigaction' function. */ -#define _EVENT_HAVE_SIGACTION 1 +#define EVENT__HAVE_SIGACTION 1 /* Define to 1 if you have the `signal' function. */ -#define _EVENT_HAVE_SIGNAL 1 +#define EVENT__HAVE_SIGNAL 1 /* Define to 1 if you have the `splice' function. */ -/* #undef _EVENT_HAVE_SPLICE */ +/* #undef EVENT__HAVE_SPLICE */ /* Define to 1 if you have the <stdarg.h> header file. */ -#define _EVENT_HAVE_STDARG_H 1 +#define EVENT__HAVE_STDARG_H 1 /* Define to 1 if you have the <stddef.h> header file. */ -#define _EVENT_HAVE_STDDEF_H 1 +#define EVENT__HAVE_STDDEF_H 1 /* Define to 1 if you have the <stdint.h> header file. */ -#define _EVENT_HAVE_STDINT_H 1 +#define EVENT__HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ -#define _EVENT_HAVE_STDLIB_H 1 +#define EVENT__HAVE_STDLIB_H 1 /* Define to 1 if you have the <strings.h> header file. */ -#define _EVENT_HAVE_STRINGS_H 1 +#define EVENT__HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ -#define _EVENT_HAVE_STRING_H 1 +#define EVENT__HAVE_STRING_H 1 /* Define to 1 if you have the `strlcpy' function. */ -#define _EVENT_HAVE_STRLCPY 1 +#define EVENT__HAVE_STRLCPY 1 /* Define to 1 if you have the `strsep' function. */ -#define _EVENT_HAVE_STRSEP 1 +#define EVENT__HAVE_STRSEP 1 /* Define to 1 if you have the `strtok_r' function. */ -#define _EVENT_HAVE_STRTOK_R 1 +#define EVENT__HAVE_STRTOK_R 1 /* Define to 1 if you have the `strtoll' function. */ -#define _EVENT_HAVE_STRTOLL 1 +#define EVENT__HAVE_STRTOLL 1 /* Define to 1 if the system has the type `struct addrinfo'. */ -#define _EVENT_HAVE_STRUCT_ADDRINFO 1 +#define EVENT__HAVE_STRUCT_ADDRINFO 1 /* Define to 1 if the system has the type `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR 1 /* Define to 1 if `s6_addr16' is a member of `struct in6_addr'. */ -/* #undef _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR16 */ +/* #undef EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 */ /* Define to 1 if `s6_addr32' is a member of `struct in6_addr'. */ -/* #undef _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR32 */ +/* #undef EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 */ /* Define to 1 if the system has the type `struct sockaddr_in6'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_IN6 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1 /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 /* Define to 1 if the system has the type `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if the system has the type `struct so_linger'. */ +#define HAVE_STRUCT_SO_LINGER 1 /* Define to 1 if you have the `sysctl' function. */ -#define _EVENT_HAVE_SYSCTL 1 +#define EVENT__HAVE_SYSCTL 1 /* Define to 1 if you have the <sys/devpoll.h> header file. */ -/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ +/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ /* Define to 1 if you have the <sys/epoll.h> header file. */ -/* #undef _EVENT_HAVE_SYS_EPOLL_H */ +/* #undef EVENT__HAVE_SYS_EPOLL_H */ /* Define to 1 if you have the <sys/eventfd.h> header file. */ -/* #undef _EVENT_HAVE_SYS_EVENTFD_H */ +/* #undef EVENT__HAVE_SYS_EVENTFD_H */ /* Define to 1 if you have the <sys/event.h> header file. */ -#define _EVENT_HAVE_SYS_EVENT_H 1 +#define EVENT__HAVE_SYS_EVENT_H 1 /* Define to 1 if you have the <sys/ioctl.h> header file. */ -#define _EVENT_HAVE_SYS_IOCTL_H 1 +#define EVENT__HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/mman.h> header file. */ -#define _EVENT_HAVE_SYS_MMAN_H 1 +#define EVENT__HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the <sys/param.h> header file. */ -#define _EVENT_HAVE_SYS_PARAM_H 1 +#define EVENT__HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/queue.h> header file. */ -#define _EVENT_HAVE_SYS_QUEUE_H 1 +#define EVENT__HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define EVENT__HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have the <sys/select.h> header file. */ -#define _EVENT_HAVE_SYS_SELECT_H 1 +#define EVENT__HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the <sys/sendfile.h> header file. */ -/* #undef _EVENT_HAVE_SYS_SENDFILE_H */ +/* #undef EVENT__HAVE_SYS_SENDFILE_H */ /* Define to 1 if you have the <sys/socket.h> header file. */ -#define _EVENT_HAVE_SYS_SOCKET_H 1 +#define EVENT__HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ -#define _EVENT_HAVE_SYS_STAT_H 1 +#define EVENT__HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysctl.h> header file. */ -#define _EVENT_HAVE_SYS_SYSCTL_H 1 +#define EVENT__HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/timerfd.h> header file. */ +#define EVENT__HAVE_SYS_TIMERFD_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ -#define _EVENT_HAVE_SYS_TIME_H 1 +#define EVENT__HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ -#define _EVENT_HAVE_SYS_TYPES_H 1 +#define EVENT__HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ -#define _EVENT_HAVE_SYS_UIO_H 1 +#define EVENT__HAVE_SYS_UIO_H 1 /* Define to 1 if you have the <sys/wait.h> header file. */ -#define _EVENT_HAVE_SYS_WAIT_H 1 +#define EVENT__HAVE_SYS_WAIT_H 1 /* Define if TAILQ_FOREACH is defined in <sys/queue.h> */ -#define _EVENT_HAVE_TAILQFOREACH 1 +#define EVENT__HAVE_TAILQFOREACH 1 /* Define if timeradd is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERADD 1 +#define EVENT__HAVE_TIMERADD 1 /* Define if timerclear is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCLEAR 1 +#define EVENT__HAVE_TIMERCLEAR 1 /* Define if timercmp is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCMP 1 +#define EVENT__HAVE_TIMERCMP 1 + +/* Define to 1 if you have the `timerfd_create' function. */ +#define EVENT__HAVE_TIMERFD_CREATE 1 /* Define if timerisset is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERISSET 1 +#define EVENT__HAVE_TIMERISSET 1 /* Define to 1 if the system has the type `uint16_t'. */ -#define _EVENT_HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT16_T 1 /* Define to 1 if the system has the type `uint32_t'. */ -#define _EVENT_HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT32_T 1 /* Define to 1 if the system has the type `uint64_t'. */ -#define _EVENT_HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT64_T 1 /* Define to 1 if the system has the type `uint8_t'. */ -#define _EVENT_HAVE_UINT8_T 1 +#define EVENT__HAVE_UINT8_T 1 /* Define to 1 if the system has the type `uintptr_t'. */ -#define _EVENT_HAVE_UINTPTR_T 1 +#define EVENT__HAVE_UINTPTR_T 1 /* Define to 1 if you have the `umask' function. */ -#define _EVENT_HAVE_UMASK 1 +#define EVENT__HAVE_UMASK 1 /* Define to 1 if you have the <unistd.h> header file. */ -#define _EVENT_HAVE_UNISTD_H 1 +#define EVENT__HAVE_UNISTD_H 1 /* Define to 1 if you have the `unsetenv' function. */ -#define _EVENT_HAVE_UNSETENV 1 +#define EVENT__HAVE_UNSETENV 1 + +/* Define to 1 if you have the `usleep' function. */ +#define EVENT__HAVE_USLEEP 1 /* Define to 1 if you have the `vasprintf' function. */ -#define _EVENT_HAVE_VASPRINTF 1 +#define EVENT__HAVE_VASPRINTF 1 + +/* Define if waitpid() supports WNOWAIT */ +/* #undef EVENT__HAVE_WAITPID_WITH_WNOWAIT */ /* Define if kqueue works correctly with pipes */ -#define _EVENT_HAVE_WORKING_KQUEUE 1 +#define EVENT__HAVE_WORKING_KQUEUE 1 /* Define to 1 if you have the <zlib.h> header file. */ -#define _EVENT_HAVE_ZLIB_H 1 +#define EVENT__HAVE_ZLIB_H 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ -#define _EVENT_LT_OBJDIR ".libs/" +#define EVENT__LT_OBJDIR ".libs/" /* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef _EVENT_NO_MINUS_C_MINUS_O */ +/* #undef EVENT__NO_MINUS_C_MINUS_O */ /* Numeric representation of the version */ -#define _EVENT_NUMERIC_VERSION 0x02001600 +#define EVENT__NUMERIC_VERSION 0x02001600 /* Name of package */ -#define _EVENT_PACKAGE "libevent" +#define EVENT__PACKAGE "libevent" /* Define to the address where bug reports for this package should be sent. */ -#define _EVENT_PACKAGE_BUGREPORT "" +#define EVENT__PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ -#define _EVENT_PACKAGE_NAME "" +#define EVENT__PACKAGE_NAME "" /* Define to the full name and version of this package. */ -#define _EVENT_PACKAGE_STRING "" +#define EVENT__PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ -#define _EVENT_PACKAGE_TARNAME "" +#define EVENT__PACKAGE_TARNAME "" /* Define to the home page for this package. */ -#define _EVENT_PACKAGE_URL "" +#define EVENT__PACKAGE_URL "" /* Define to the version of this package. */ -#define _EVENT_PACKAGE_VERSION "" +#define EVENT__PACKAGE_VERSION "" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ -/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */ +/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ /* The size of `int', as computed by sizeof. */ -#define _EVENT_SIZEOF_INT 4 +#define EVENT__SIZEOF_INT 4 /* The size of `long', as computed by sizeof. */ -#define _EVENT_SIZEOF_LONG 8 +#define EVENT__SIZEOF_LONG 8 /* The size of `long long', as computed by sizeof. */ -#define _EVENT_SIZEOF_LONG_LONG 8 +#define EVENT__SIZEOF_LONG_LONG 8 /* The size of `off_t', as computed by sizeof. */ -#define _EVENT_SIZEOF_OFF_T 8 +#define EVENT__SIZEOF_OFF_T 8 /* The size of `pthread_t', as computed by sizeof. */ -#define _EVENT_SIZEOF_PTHREAD_T 8 +#define EVENT__SIZEOF_PTHREAD_T 8 /* The size of `short', as computed by sizeof. */ -#define _EVENT_SIZEOF_SHORT 2 +#define EVENT__SIZEOF_SHORT 2 /* The size of `void *', as computed by sizeof. */ -#define _EVENT_SIZEOF_VOID_P 8 +#define EVENT__SIZEOF_VOID_P 8 /* Define to 1 if you have the ANSI C header files. */ -#define _EVENT_STDC_HEADERS 1 +#define EVENT__STDC_HEADERS 1 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#define _EVENT_TIME_WITH_SYS_TIME 1 +#define EVENT__TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define _EVENT_VERSION "2.0.22-stable" +#define EVENT__VERSION "2.1.8-stable" /* Define to appropriate substitue if compiler doesnt have __func__ */ -/* #undef _EVENT___func__ */ +/* #undef EVENT____func__ */ /* Define to empty if `const' does not conform to ANSI C. */ -/* #undef _EVENT_const */ +/* #undef EVENT__const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef _EVENT___cplusplus -/* #undef _EVENT_inline */ +#ifndef EVENT____cplusplus +/* #undef EVENT__inline */ #endif /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_pid_t */ +/* #undef EVENT__pid_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ -/* #undef _EVENT_size_t */ +/* #undef EVENT__size_t */ /* Define to unsigned int if you dont have it */ -/* #undef _EVENT_socklen_t */ +/* #undef EVENT__socklen_t */ /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_ssize_t */ +/* #undef EVENT__ssize_t */ #endif /* event2/event-config.h */ diff --git a/include/event2/event-config-linux.h b/include/event2/event-config-linux.h index 5a906df..7c43c78 100644 --- a/include/event2/event-config-linux.h +++ b/include/event2/event-config-linux.h @@ -11,456 +11,508 @@ #ifndef _EVENT2_EVENT_CONFIG_H_ #define _EVENT2_EVENT_CONFIG_H_ +#include <stddef.h> #include <stdint.h> /* The size of `size_t', as computed by sizeof. */ #if SIZE_MAX == UINT64_MAX -# define _EVENT_SIZEOF_SIZE_T 8 +# define EVENT__SIZEOF_SIZE_T 8 #elif SIZE_MAX == UINT32_MAX -# define _EVENT_SIZEOF_SIZE_T 4 +# define EVENT__SIZEOF_SIZE_T 4 #else # error "No way to infer sizeof size_t" #endif +#define EVENT__HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT8_T 1 +#define EVENT__HAVE_UINTPTR_T 1 + /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if libevent should build without support for a debug mode */ -/* #undef _EVENT_DISABLE_DEBUG_MODE */ +/* #undef EVENT__DISABLE_DEBUG_MODE */ /* Define if libevent should not allow replacing the mm functions */ -/* #undef _EVENT_DISABLE_MM_REPLACEMENT */ +/* #undef EVENT__DISABLE_MM_REPLACEMENT */ /* Define if libevent should not be compiled with thread support */ -/* #undef _EVENT_DISABLE_THREAD_SUPPORT */ +/* #undef EVENT__DISABLE_THREAD_SUPPORT */ + +/* Define to 1 if you have the `accept4' function. */ +#define EVENT__HAVE_ACCEPT4 1 /* Define to 1 if you have the `arc4random' function. */ -/* #undef _EVENT_HAVE_ARC4RANDOM */ +/* #undef EVENT__HAVE_ARC4RANDOM */ /* Define to 1 if you have the `arc4random_buf' function. */ -/* #undef _EVENT_HAVE_ARC4RANDOM_BUF */ +/* #undef EVENT__HAVE_ARC4RANDOM_BUF */ /* Define to 1 if you have the <arpa/inet.h> header file. */ -#define _EVENT_HAVE_ARPA_INET_H 1 +#define EVENT__HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `clock_gettime' function. */ -#define _EVENT_HAVE_CLOCK_GETTIME 1 +#define EVENT__HAVE_CLOCK_GETTIME 1 /* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_CTL_KERN 1 +#define EVENT__HAVE_DECL_CTL_KERN 1 /* Define to 1 if you have the declaration of `KERN_ARND', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_KERN_ARND 0 +#define EVENT__HAVE_DECL_KERN_ARND 0 /* Define to 1 if you have the declaration of `KERN_RANDOM', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_KERN_RANDOM 1 +#define EVENT__HAVE_DECL_KERN_RANDOM 1 /* Define to 1 if you have the declaration of `RANDOM_UUID', and to 0 if you don't. */ -#define _EVENT_HAVE_DECL_RANDOM_UUID 1 +#define EVENT__HAVE_DECL_RANDOM_UUID 1 /* Define if /dev/poll is available */ -/* #undef _EVENT_HAVE_DEVPOLL */ +/* #undef EVENT__HAVE_DEVPOLL */ /* Define to 1 if you have the <dlfcn.h> header file. */ -#define _EVENT_HAVE_DLFCN_H 1 +#define EVENT__HAVE_DLFCN_H 1 /* Define if your system supports the epoll system calls */ -#define _EVENT_HAVE_EPOLL 1 +#define EVENT__HAVE_EPOLL 1 + +/* Define to 1 if you have the `epoll_create1' function. */ +#define HAVE_EPOLL_CREATE1 1 /* Define to 1 if you have the `epoll_ctl' function. */ -#define _EVENT_HAVE_EPOLL_CTL 1 +#define EVENT__HAVE_EPOLL_CTL 1 + +/* Define to 1 if you have the <errno.h> header file. */ +#define EVENT__HAVE_ERRNO_H 1 + +/* Define to 1 if you have ERR_remove_thread_stat(). */ +#undef HAVE_ERR_REMOVE_THREAD_STATE /* Define to 1 if you have the `eventfd' function. */ -#define _EVENT_HAVE_EVENTFD 1 +#define EVENT__HAVE_EVENTFD 1 /* Define if your system supports event ports */ -/* #undef _EVENT_HAVE_EVENT_PORTS */ +/* #undef EVENT__HAVE_EVENT_PORTS */ /* Define to 1 if you have the `fcntl' function. */ -#define _EVENT_HAVE_FCNTL 1 +#define EVENT__HAVE_FCNTL 1 /* Define to 1 if you have the <fcntl.h> header file. */ -#define _EVENT_HAVE_FCNTL_H 1 +#define EVENT__HAVE_FCNTL_H 1 /* Define to 1 if the system has the type `fd_mask'. */ -#define _EVENT_HAVE_FD_MASK 1 +#define EVENT__HAVE_FD_MASK 1 /* Do we have getaddrinfo()? */ -#define _EVENT_HAVE_GETADDRINFO 1 +#define EVENT__HAVE_GETADDRINFO 1 /* Define to 1 if you have the `getegid' function. */ -#define _EVENT_HAVE_GETEGID 1 +#define EVENT__HAVE_GETEGID 1 /* Define to 1 if you have the `geteuid' function. */ -#define _EVENT_HAVE_GETEUID 1 +#define EVENT__HAVE_GETEUID 1 /* Define this if you have any gethostbyname_r() */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R */ /* Define this if gethostbyname_r takes 3 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_3_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_3_ARG */ /* Define this if gethostbyname_r takes 5 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_5_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_5_ARG */ /* Define this if gethostbyname_r takes 6 arguments */ -/* #undef _EVENT_HAVE_GETHOSTBYNAME_R_6_ARG */ +/* #undef EVENT__HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getifaddrs' function. */ +#define EVENT__HAVE_GETIFADDRS 1 /* Define to 1 if you have the `getnameinfo' function. */ -#define _EVENT_HAVE_GETNAMEINFO 1 +#define EVENT__HAVE_GETNAMEINFO 1 /* Define to 1 if you have the `getprotobynumber' function. */ -#define _EVENT_HAVE_GETPROTOBYNUMBER 1 +#define EVENT__HAVE_GETPROTOBYNUMBER 1 /* Define to 1 if you have the `getservbyname' function. */ -/* #undef _EVENT_HAVE_GETSERVBYNAME */ +/* #undef EVENT__HAVE_GETSERVBYNAME */ /* Define to 1 if you have the `gettimeofday' function. */ -#define _EVENT_HAVE_GETTIMEOFDAY 1 +#define EVENT__HAVE_GETTIMEOFDAY 1 -/* Define to 1 if you have the `inet_aton' function. */ -#define _EVENT_HAVE_INET_ATON 1 +/* Define to 1 if you have the <ifaddrs.h> header file. */ +#define EVENT__HAVE_IFADDRS_H 1 /* Define to 1 if you have the `inet_ntop' function. */ -#define _EVENT_HAVE_INET_NTOP 1 +#define EVENT__HAVE_INET_NTOP 1 /* Define to 1 if you have the `inet_pton' function. */ -#define _EVENT_HAVE_INET_PTON 1 +#define EVENT__HAVE_INET_PTON 1 /* Define to 1 if you have the <inttypes.h> header file. */ -#define _EVENT_HAVE_INTTYPES_H 1 +#define EVENT__HAVE_INTTYPES_H 1 /* Define to 1 if you have the `issetugid' function. */ -/* #undef _EVENT_HAVE_ISSETUGID */ +/* #undef EVENT__HAVE_ISSETUGID */ /* Define to 1 if you have the `kqueue' function. */ -/* #undef _EVENT_HAVE_KQUEUE */ +/* #undef EVENT__HAVE_KQUEUE */ /* Define if the system has zlib */ -#define _EVENT_HAVE_LIBZ 1 +#define EVENT__HAVE_LIBZ 1 /* Define to 1 if you have the <memory.h> header file. */ -#define _EVENT_HAVE_MEMORY_H 1 +#define EVENT__HAVE_MEMORY_H 1 /* Define to 1 if you have the `mmap' function. */ -#define _EVENT_HAVE_MMAP 1 +#define EVENT__HAVE_MMAP 1 + +/* Define to 1 if you have the `nanosleep' function. */ +#define EVENT__HAVE_NANOSLEEP 1 /* Define to 1 if you have the <netdb.h> header file. */ -#define _EVENT_HAVE_NETDB_H 1 +#define EVENT__HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in6.h> header file. */ -/* #undef _EVENT_HAVE_NETINET_IN6_H */ +/* #undef EVENT__HAVE_NETINET_IN6_H */ /* Define to 1 if you have the <netinet/in.h> header file. */ -#define _EVENT_HAVE_NETINET_IN_H 1 +#define EVENT__HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +#define EVENT__HAVE_NETINET_TCP_H 1 /* Define if the system has openssl */ -#define _EVENT_HAVE_OPENSSL 1 +#define EVENT__HAVE_OPENSSL 1 /* Define to 1 if you have the <openssl/bio.h> header file. */ -#define _EVENT_HAVE_OPENSSL_BIO_H 1 +#define EVENT__HAVE_OPENSSL_BIO_H 1 /* Define to 1 if you have the `pipe' function. */ -#define _EVENT_HAVE_PIPE 1 +#define EVENT__HAVE_PIPE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define EVENT__HAVE_PIPE2 1 /* Define to 1 if you have the `poll' function. */ -#define _EVENT_HAVE_POLL 1 +#define EVENT__HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ -#define _EVENT_HAVE_POLL_H 1 +#define EVENT__HAVE_POLL_H 1 /* Define to 1 if you have the `port_create' function. */ -/* #undef _EVENT_HAVE_PORT_CREATE */ +/* #undef EVENT__HAVE_PORT_CREATE */ /* Define to 1 if you have the <port.h> header file. */ -/* #undef _EVENT_HAVE_PORT_H */ +/* #undef EVENT__HAVE_PORT_H */ /* Define if you have POSIX threads libraries and header files. */ -/* #undef _EVENT_HAVE_PTHREAD */ +/* #undef EVENT__HAVE_PTHREAD */ /* Define if we have pthreads on this system */ -#define _EVENT_HAVE_PTHREADS 1 +#define EVENT__HAVE_PTHREADS 1 /* Define to 1 if you have the `putenv' function. */ -#define _EVENT_HAVE_PUTENV 1 +#define EVENT__HAVE_PUTENV 1 /* Define to 1 if the system has the type `sa_family_t'. */ -#define _EVENT_HAVE_SA_FAMILY_T 1 +#define EVENT__HAVE_SA_FAMILY_T 1 /* Define to 1 if you have the `select' function. */ -#define _EVENT_HAVE_SELECT 1 +#define EVENT__HAVE_SELECT 1 /* Define to 1 if you have the `sendfile' function. */ -#define _EVENT_HAVE_SENDFILE 1 +#define EVENT__HAVE_SENDFILE 1 /* Define to 1 if you have the `setenv' function. */ -#define _EVENT_HAVE_SETENV 1 +#define EVENT__HAVE_SETENV 1 /* Define if F_SETFD is defined in <fcntl.h> */ -#define _EVENT_HAVE_SETFD 1 +#define EVENT__HAVE_SETFD 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#define EVENT__HAVE_SETRLIMIT 1 /* Define to 1 if you have the `sigaction' function. */ -#define _EVENT_HAVE_SIGACTION 1 +#define EVENT__HAVE_SIGACTION 1 /* Define to 1 if you have the `signal' function. */ -#define _EVENT_HAVE_SIGNAL 1 +#define EVENT__HAVE_SIGNAL 1 /* Define to 1 if you have the `splice' function. */ -#define _EVENT_HAVE_SPLICE 1 +#define EVENT__HAVE_SPLICE 1 /* Define to 1 if you have the <stdarg.h> header file. */ -#define _EVENT_HAVE_STDARG_H 1 +#define EVENT__HAVE_STDARG_H 1 /* Define to 1 if you have the <stddef.h> header file. */ -#define _EVENT_HAVE_STDDEF_H 1 +#define EVENT__HAVE_STDDEF_H 1 /* Define to 1 if you have the <stdint.h> header file. */ -#define _EVENT_HAVE_STDINT_H 1 +#define EVENT__HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ -#define _EVENT_HAVE_STDLIB_H 1 +#define EVENT__HAVE_STDLIB_H 1 /* Define to 1 if you have the <strings.h> header file. */ -#define _EVENT_HAVE_STRINGS_H 1 +#define EVENT__HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ -#define _EVENT_HAVE_STRING_H 1 +#define EVENT__HAVE_STRING_H 1 /* Define to 1 if you have the `strlcpy' function. */ -/* #undef _EVENT_HAVE_STRLCPY */ +/* #undef EVENT__HAVE_STRLCPY */ /* Define to 1 if you have the `strsep' function. */ -#define _EVENT_HAVE_STRSEP 1 +#define EVENT__HAVE_STRSEP 1 /* Define to 1 if you have the `strtok_r' function. */ -#define _EVENT_HAVE_STRTOK_R 1 +#define EVENT__HAVE_STRTOK_R 1 /* Define to 1 if you have the `strtoll' function. */ -#define _EVENT_HAVE_STRTOLL 1 +#define EVENT__HAVE_STRTOLL 1 /* Define to 1 if the system has the type `struct addrinfo'. */ -#define _EVENT_HAVE_STRUCT_ADDRINFO 1 +#define EVENT__HAVE_STRUCT_ADDRINFO 1 /* Define to 1 if the system has the type `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR 1 /* Define to 1 if `s6_addr16' is a member of `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 /* Define to 1 if `s6_addr32' is a member of `struct in6_addr'. */ -#define _EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 /* Define to 1 if the system has the type `struct sockaddr_in6'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_IN6 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Define to 1 if the system has the type `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ -#define _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ -/* #undef _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ + +/* Define to 1 if the system has the type `struct so_linger'. */ +#define EVENT__HAVE_STRUCT_SO_LINGER 1 /* Define to 1 if you have the `sysctl' function. */ -#define _EVENT_HAVE_SYSCTL 1 +#define EVENT__HAVE_SYSCTL 1 /* Define to 1 if you have the <sys/devpoll.h> header file. */ -/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ +/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ /* Define to 1 if you have the <sys/epoll.h> header file. */ -#define _EVENT_HAVE_SYS_EPOLL_H 1 +#define EVENT__HAVE_SYS_EPOLL_H 1 /* Define to 1 if you have the <sys/eventfd.h> header file. */ -#define _EVENT_HAVE_SYS_EVENTFD_H 1 +#define EVENT__HAVE_SYS_EVENTFD_H 1 /* Define to 1 if you have the <sys/event.h> header file. */ -/* #undef _EVENT_HAVE_SYS_EVENT_H */ +/* #undef EVENT__HAVE_SYS_EVENT_H */ /* Define to 1 if you have the <sys/ioctl.h> header file. */ -#define _EVENT_HAVE_SYS_IOCTL_H 1 +#define EVENT__HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/mman.h> header file. */ -#define _EVENT_HAVE_SYS_MMAN_H 1 +#define EVENT__HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the <sys/param.h> header file. */ -#define _EVENT_HAVE_SYS_PARAM_H 1 +#define EVENT__HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/queue.h> header file. */ -#define _EVENT_HAVE_SYS_QUEUE_H 1 +#define EVENT__HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define EVENT__HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have the <sys/select.h> header file. */ -#define _EVENT_HAVE_SYS_SELECT_H 1 +#define EVENT__HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the <sys/sendfile.h> header file. */ -#define _EVENT_HAVE_SYS_SENDFILE_H 1 +#define EVENT__HAVE_SYS_SENDFILE_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ -#define _EVENT_HAVE_SYS_SOCKET_H 1 +#define EVENT__HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ -#define _EVENT_HAVE_SYS_STAT_H 1 +#define EVENT__HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysctl.h> header file. */ -#define _EVENT_HAVE_SYS_SYSCTL_H 1 +#define EVENT__HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/timerfd.h> header file. */ +#define HAVE_SYS_TIMERFD_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ -#define _EVENT_HAVE_SYS_TIME_H 1 +#define EVENT__HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ -#define _EVENT_HAVE_SYS_TYPES_H 1 +#define EVENT__HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ -#define _EVENT_HAVE_SYS_UIO_H 1 +#define EVENT__HAVE_SYS_UIO_H 1 /* Define to 1 if you have the <sys/wait.h> header file. */ -#define _EVENT_HAVE_SYS_WAIT_H 1 +#define EVENT__HAVE_SYS_WAIT_H 1 /* Define if TAILQ_FOREACH is defined in <sys/queue.h> */ -#define _EVENT_HAVE_TAILQFOREACH 1 +#define EVENT__HAVE_TAILQFOREACH 1 /* Define if timeradd is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERADD 1 +#define EVENT__HAVE_TIMERADD 1 /* Define if timerclear is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCLEAR 1 +#define EVENT__HAVE_TIMERCLEAR 1 /* Define if timercmp is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERCMP 1 +#define EVENT__HAVE_TIMERCMP 1 + +/* Define to 1 if you have the `timerfd_create' function. */ +#define EVENT__HAVE_TIMERFD_CREATE 1 /* Define if timerisset is defined in <sys/time.h> */ -#define _EVENT_HAVE_TIMERISSET 1 +#define EVENT__HAVE_TIMERISSET 1 /* Define to 1 if the system has the type `uint16_t'. */ -#define _EVENT_HAVE_UINT16_T 1 +#define EVENT__HAVE_UINT16_T 1 /* Define to 1 if the system has the type `uint32_t'. */ -#define _EVENT_HAVE_UINT32_T 1 +#define EVENT__HAVE_UINT32_T 1 /* Define to 1 if the system has the type `uint64_t'. */ -#define _EVENT_HAVE_UINT64_T 1 +#define EVENT__HAVE_UINT64_T 1 /* Define to 1 if the system has the type `uint8_t'. */ -#define _EVENT_HAVE_UINT8_T 1 +#define EVENT__HAVE_UINT8_T 1 /* Define to 1 if the system has the type `uintptr_t'. */ -#define _EVENT_HAVE_UINTPTR_T 1 +#define EVENT__HAVE_UINTPTR_T 1 /* Define to 1 if you have the `umask' function. */ -#define _EVENT_HAVE_UMASK 1 +#define EVENT__HAVE_UMASK 1 /* Define to 1 if you have the <unistd.h> header file. */ -#define _EVENT_HAVE_UNISTD_H 1 +#define EVENT__HAVE_UNISTD_H 1 /* Define to 1 if you have the `unsetenv' function. */ -#define _EVENT_HAVE_UNSETENV 1 +#define EVENT__HAVE_UNSETENV 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 /* Define to 1 if you have the `vasprintf' function. */ -#define _EVENT_HAVE_VASPRINTF 1 +#define EVENT__HAVE_VASPRINTF 1 + +/* Define if waitpid() supports WNOWAIT */ +#define HAVE_WAITPID_WITH_WNOWAIT 1 /* Define if kqueue works correctly with pipes */ -/* #undef _EVENT_HAVE_WORKING_KQUEUE */ +/* #undef EVENT__HAVE_WORKING_KQUEUE */ /* Define to 1 if you have the <zlib.h> header file. */ -#define _EVENT_HAVE_ZLIB_H 1 +#define EVENT__HAVE_ZLIB_H 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ -#define _EVENT_LT_OBJDIR ".libs/" +#define EVENT__LT_OBJDIR ".libs/" /* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef _EVENT_NO_MINUS_C_MINUS_O */ +/* #undef EVENT__NO_MINUS_C_MINUS_O */ /* Numeric representation of the version */ -#define _EVENT_NUMERIC_VERSION 0x02001600 +#define EVENT__NUMERIC_VERSION 0x02001600 /* Name of package */ -#define _EVENT_PACKAGE "libevent" +#define EVENT__PACKAGE "libevent" /* Define to the address where bug reports for this package should be sent. */ -#define _EVENT_PACKAGE_BUGREPORT "" +#define EVENT__PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ -#define _EVENT_PACKAGE_NAME "" +#define EVENT__PACKAGE_NAME "" /* Define to the full name and version of this package. */ -#define _EVENT_PACKAGE_STRING "" +#define EVENT__PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ -#define _EVENT_PACKAGE_TARNAME "" +#define EVENT__PACKAGE_TARNAME "" /* Define to the home page for this package. */ -#define _EVENT_PACKAGE_URL "" +#define EVENT__PACKAGE_URL "" /* Define to the version of this package. */ -#define _EVENT_PACKAGE_VERSION "" +#define EVENT__PACKAGE_VERSION "" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ -/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */ +/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ /* The size of `int', as computed by sizeof. */ -#define _EVENT_SIZEOF_INT 4 +#define EVENT__SIZEOF_INT 4 /* The size of `long', as computed by sizeof. */ -#define _EVENT_SIZEOF_LONG 8 +#define EVENT__SIZEOF_LONG 8 /* The size of `long long', as computed by sizeof. */ -#define _EVENT_SIZEOF_LONG_LONG 8 +#define EVENT__SIZEOF_LONG_LONG 8 /* The size of `off_t', as computed by sizeof. */ -#define _EVENT_SIZEOF_OFF_T 8 +#define EVENT__SIZEOF_OFF_T 8 /* The size of `pthread_t', as computed by sizeof. */ -#define _EVENT_SIZEOF_PTHREAD_T 8 +#define EVENT__SIZEOF_PTHREAD_T 8 /* The size of `short', as computed by sizeof. */ -#define _EVENT_SIZEOF_SHORT 2 +#define EVENT__SIZEOF_SHORT 2 /* The size of `void *', as computed by sizeof. */ -#define _EVENT_SIZEOF_VOID_P 8 +#define EVENT__SIZEOF_VOID_P 8 /* Define to 1 if you have the ANSI C header files. */ -#define _EVENT_STDC_HEADERS 1 +#define EVENT__STDC_HEADERS 1 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#define _EVENT_TIME_WITH_SYS_TIME 1 +#define EVENT__TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define _EVENT_VERSION "2.0.22-stable" +#define EVENT__VERSION "2.1.8-stable" /* Define to appropriate substitue if compiler doesnt have __func__ */ -/* #undef _EVENT___func__ */ +/* #undef EVENT____func__ */ /* Define to empty if `const' does not conform to ANSI C. */ -/* #undef _EVENT_const */ +/* #undef EVENT__const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef _EVENT___cplusplus -/* #undef _EVENT_inline */ +#ifndef EVENT____cplusplus +/* #undef EVENT__inline */ #endif /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_pid_t */ +/* #undef EVENT__pid_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ -/* #undef _EVENT_size_t */ +/* #undef EVENT__size_t */ /* Define to unsigned int if you dont have it */ -/* #undef _EVENT_socklen_t */ +/* #undef EVENT__socklen_t */ /* Define to `int' if <sys/types.h> does not define. */ -/* #undef _EVENT_ssize_t */ +/* #undef EVENT__ssize_t */ #endif /* event2/event-config.h */ diff --git a/include/event2/event.h b/include/event2/event.h index 10bcd97..6e0a4f0 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -24,8 +24,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_EVENT_H_ -#define _EVENT2_EVENT_H_ +#ifndef EVENT2_EVENT_H_INCLUDED_ +#define EVENT2_EVENT_H_INCLUDED_ /** @mainpage @@ -39,7 +39,7 @@ to signals or regular timeouts. Libevent is meant to replace the event loop found in event driven network - servers. An application just needs to call event_dispatch() and then add or + servers. An application just needs to call event_base_dispatch() and then add or remove events dynamically without having to change the event loop. @@ -54,7 +54,7 @@ @section usage Standard usage - Every program that uses Libevent must inclurde the <event2/event.h> + Every program that uses Libevent must include the <event2/event.h> header, and pass the -levent flag to the linker. (You can instead link -levent_core if you only want the main event and buffered IO-based code, and don't want to link any protocol code.) @@ -90,7 +90,7 @@ remain allocated as long as it is active, so it should generally be allocated on the heap. - @section loop Dispaching evets. + @section loop Dispatching events. Finally, you call event_base_dispatch() to loop and dispatch events. You can also use event_base_loop() for more fine-grained control. @@ -124,9 +124,11 @@ @section timers Timers Libevent can also be used to create timers that invoke a callback after a - certain amount of time has expired. The evtimer_new() function returns + certain amount of time has expired. The evtimer_new() macro returns an event struct to use as a timer. To activate the timer, call evtimer_add(). Timers can be deactivated by calling evtimer_del(). + (These macros are thin wrappers around event_new(), event_add(), + and event_del(); you can also use those instead.) @section evdns Asynchronous DNS resolution @@ -180,15 +182,17 @@ Core functions for waiting for and receiving events, and using event bases. */ +#include <event2/visibility.h> + #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -211,7 +215,7 @@ extern "C" { * event_base_new_with_config() */ struct event_base -#ifdef _EVENT_IN_DOXYGEN +#ifdef EVENT_IN_DOXYGEN_ {/*Empty body so that doxygen will generate documentation here.*/} #endif ; @@ -270,7 +274,7 @@ struct event_base * event_priority_set() */ struct event -#ifdef _EVENT_IN_DOXYGEN +#ifdef EVENT_IN_DOXYGEN_ {/*Empty body so that doxygen will generate documentation here.*/} #endif ; @@ -289,7 +293,7 @@ struct event * event_config_set_flag(), event_config_set_num_cpus_hint() */ struct event_config -#ifdef _EVENT_IN_DOXYGEN +#ifdef EVENT_IN_DOXYGEN_ {/*Empty body so that doxygen will generate documentation here.*/} #endif ; @@ -314,6 +318,7 @@ struct event_config * * @see event_debug_unassign() */ +EVENT2_EXPORT_SYMBOL void event_enable_debug_mode(void); /** @@ -325,6 +330,7 @@ void event_enable_debug_mode(void); * * @see event_enable_debug_mode() */ +EVENT2_EXPORT_SYMBOL void event_debug_unassign(struct event *); /** @@ -334,6 +340,7 @@ void event_debug_unassign(struct event *); * * @see event_base_free(), event_base_new_with_config() */ +EVENT2_EXPORT_SYMBOL struct event_base *event_base_new(void); /** @@ -346,6 +353,7 @@ struct event_base *event_base_new(void); @return 0 if successful, or -1 if some events could not be re-added. @see event_base_new() */ +EVENT2_EXPORT_SYMBOL int event_reinit(struct event_base *base); /** @@ -361,6 +369,7 @@ int event_reinit(struct event_base *base); no events were pending or active. @see event_base_loop() */ +EVENT2_EXPORT_SYMBOL int event_base_dispatch(struct event_base *); /** @@ -369,6 +378,7 @@ int event_base_dispatch(struct event_base *); @param eb the event_base structure returned by event_base_new() @return a string identifying the kernel event mechanism (kqueue, epoll, etc.) */ +EVENT2_EXPORT_SYMBOL const char *event_base_get_method(const struct event_base *); /** @@ -383,8 +393,66 @@ const char *event_base_get_method(const struct event_base *); The end of the array is indicated by a NULL pointer. If an error is encountered NULL is returned. */ +EVENT2_EXPORT_SYMBOL const char **event_get_supported_methods(void); +/** Query the current monotonic time from a the timer for a struct + * event_base. + */ +EVENT2_EXPORT_SYMBOL +int event_gettime_monotonic(struct event_base *base, struct timeval *tp); + +/** + @name event type flag + + Flags to pass to event_base_get_num_events() to specify the kinds of events + we want to aggregate counts for +*/ +/**@{*/ +/** count the number of active events, which have been triggered.*/ +#define EVENT_BASE_COUNT_ACTIVE 1U +/** count the number of virtual events, which is used to represent an internal + * condition, other than a pending event, that keeps the loop from exiting. */ +#define EVENT_BASE_COUNT_VIRTUAL 2U +/** count the number of events which have been added to event base, including + * internal events. */ +#define EVENT_BASE_COUNT_ADDED 4U +/**@}*/ + +/** + Gets the number of events in event_base, as specified in the flags. + + Since event base has some internal events added to make some of its + functionalities work, EVENT_BASE_COUNT_ADDED may return more than the + number of events you added using event_add(). + + If you pass EVENT_BASE_COUNT_ACTIVE and EVENT_BASE_COUNT_ADDED together, an + active event will be counted twice. However, this might not be the case in + future libevent versions. The return value is an indication of the work + load, but the user shouldn't rely on the exact value as this may change in + the future. + + @param eb the event_base structure returned by event_base_new() + @param flags a bitwise combination of the kinds of events to aggregate + counts for + @return the number of events specified in the flags +*/ +EVENT2_EXPORT_SYMBOL +int event_base_get_num_events(struct event_base *, unsigned int); + +/** + Get the maximum number of events in a given event_base as specified in the + flags. + + @param eb the event_base structure returned by event_base_new() + @param flags a bitwise combination of the kinds of events to aggregate + counts for + @param clear option used to reset the maximum count. + @return the number of events specified in the flags + */ +EVENT2_EXPORT_SYMBOL +int event_base_get_max_events(struct event_base *, unsigned int, int); + /** Allocates a new event configuration object. @@ -395,6 +463,7 @@ const char **event_get_supported_methods(void); NULL if an error is encountered. @see event_base_new_with_config(), event_config_free(), event_config */ +EVENT2_EXPORT_SYMBOL struct event_config *event_config_new(void); /** @@ -402,6 +471,7 @@ struct event_config *event_config_new(void); @param cfg the event configuration object to be freed. */ +EVENT2_EXPORT_SYMBOL void event_config_free(struct event_config *cfg); /** @@ -416,6 +486,7 @@ void event_config_free(struct event_config *cfg); @param method the name of the event method to avoid @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int event_config_avoid_method(struct event_config *cfg, const char *method); /** @@ -437,7 +508,14 @@ enum event_method_feature { EV_FEATURE_O1 = 0x02, /** Require an event method that allows file descriptors as well as * sockets. */ - EV_FEATURE_FDS = 0x04 + EV_FEATURE_FDS = 0x04, + /** Require an event method that allows you to use EV_CLOSED to detect + * connection close without the necessity of reading all the pending data. + * + * Methods that do support EV_CLOSED may not be able to provide support on + * all kernel versions. + **/ + EV_FEATURE_EARLY_CLOSE = 0x08 }; /** @@ -450,7 +528,11 @@ enum event_method_feature { */ enum event_base_config_flag { /** Do not allocate a lock for the event base, even if we have - locking set up. */ + locking set up. + + Setting this option will make it unsafe and nonfunctional to call + functions on the base concurrently from multiple threads. + */ EVENT_BASE_FLAG_NOLOCK = 0x01, /** Do not check the EVENT_* environment variables when configuring an event_base */ @@ -475,13 +557,20 @@ enum event_base_config_flag { if you have any fds cloned by dup() or its variants. Doing so will produce strange and hard-to-diagnose bugs. - This flag can also be activated by settnig the + This flag can also be activated by setting the EVENT_EPOLL_USE_CHANGELIST environment variable. This flag has no effect if you wind up using a backend other than epoll. */ - EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10 + EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10, + + /** Ordinarily, Libevent implements its time and timeout code using + the fastest monotonic timer that we have. If this flag is set, + however, we use less efficient more precise timer, assuming one is + present. + */ + EVENT_BASE_FLAG_PRECISE_TIMER = 0x20 }; /** @@ -491,6 +580,7 @@ enum event_base_config_flag { @see event_method_feature */ +EVENT2_EXPORT_SYMBOL int event_base_get_features(const struct event_base *base); /** @@ -515,6 +605,7 @@ int event_base_get_features(const struct event_base *base); @return 0 on success, -1 on failure. @see event_method_feature, event_base_new_with_config() */ +EVENT2_EXPORT_SYMBOL int event_config_require_features(struct event_config *cfg, int feature); /** @@ -523,6 +614,7 @@ int event_config_require_features(struct event_config *cfg, int feature); * * @see event_base_config_flags, event_base_new_with_config() **/ +EVENT2_EXPORT_SYMBOL int event_config_set_flag(struct event_config *cfg, int flag); /** @@ -534,9 +626,43 @@ int event_config_set_flag(struct event_config *cfg, int flag); * @param cpus the number of cpus * @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus); /** + * Record an interval and/or a number of callbacks after which the event base + * should check for new events. By default, the event base will run as many + * events are as activated at the higest activated priority before checking + * for new events. If you configure it by setting max_interval, it will check + * the time after each callback, and not allow more than max_interval to + * elapse before checking for new events. If you configure it by setting + * max_callbacks to a value >= 0, it will run no more than max_callbacks + * callbacks before checking for new events. + * + * This option can decrease the latency of high-priority events, and + * avoid priority inversions where multiple low-priority events keep us from + * polling for high-priority events, but at the expense of slightly decreasing + * the throughput. Use it with caution! + * + * @param cfg The event_base configuration object. + * @param max_interval An interval after which Libevent should stop running + * callbacks and check for more events, or NULL if there should be + * no such interval. + * @param max_callbacks A number of callbacks after which Libevent should + * stop running callbacks and check for more events, or -1 if there + * should be no such limit. + * @param min_priority A priority below which max_interval and max_callbacks + * should not be enforced. If this is set to 0, they are enforced + * for events of every priority; if it's set to 1, they're enforced + * for events of priority 1 and above, and so on. + * @return 0 on success, -1 on failure. + **/ +EVENT2_EXPORT_SYMBOL +int event_config_set_max_dispatch_interval(struct event_config *cfg, + const struct timeval *max_interval, int max_callbacks, + int min_priority); + +/** Initialize the event API. Use event_base_new_with_config() to initialize a new event base, taking @@ -548,6 +674,7 @@ int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus); or NULL if no event base can be created with the requested event_config. @see event_base_new(), event_base_free(), event_init(), event_assign() */ +EVENT2_EXPORT_SYMBOL struct event_base *event_base_new_with_config(const struct event_config *); /** @@ -556,10 +683,23 @@ struct event_base *event_base_new_with_config(const struct event_config *); Note that this function will not close any fds or free any memory passed to event_new as the argument to callback. + If there are any pending finalizer callbacks, this function will invoke + them. + @param eb an event_base to be freed */ +EVENT2_EXPORT_SYMBOL void event_base_free(struct event_base *); +/** + As event_free, but do not run finalizers. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +void event_base_free_nofinalize(struct event_base *); + /** @name Log severities */ /**@{*/ @@ -586,12 +726,13 @@ typedef void (*event_log_cb)(int severity, const char *msg); Redirect Libevent's log messages. @param cb a function taking two arguments: an integer severity between - _EVENT_LOG_DEBUG and _EVENT_LOG_ERR, and a string. If cb is NULL, + EVENT_LOG_DEBUG and EVENT_LOG_ERR, and a string. If cb is NULL, then the default log is used. NOTE: The function you provide *must not* call any other libevent functionality. Doing so can produce undefined behavior. */ +EVENT2_EXPORT_SYMBOL void event_set_log_callback(event_log_cb cb); /** @@ -610,11 +751,32 @@ typedef void (*event_fatal_cb)(int err); something is wrong with your program, or with Libevent: any subsequent calls to Libevent may result in undefined behavior. - Libevent will (almost) always log an _EVENT_LOG_ERR message before calling + Libevent will (almost) always log an EVENT_LOG_ERR message before calling this function; look at the last log message to see why Libevent has died. */ +EVENT2_EXPORT_SYMBOL void event_set_fatal_callback(event_fatal_cb cb); +#define EVENT_DBG_ALL 0xffffffffu +#define EVENT_DBG_NONE 0 + +/** + Turn on debugging logs and have them sent to the default log handler. + + This is a global setting; if you are going to call it, you must call this + before any calls that create an event-base. You must call it before any + multithreaded use of Libevent. + + Debug logs are verbose. + + @param which Controls which debug messages are turned on. This option is + unused for now; for forward compatibility, you must pass in the constant + "EVENT_DBG_ALL" to turn debugging logs on, or "EVENT_DBG_NONE" to turn + debugging logs off. + */ +EVENT2_EXPORT_SYMBOL +void event_enable_debug_logging(ev_uint32_t which); + /** Associate a different event base with an event. @@ -624,6 +786,7 @@ void event_set_fatal_callback(event_fatal_cb cb); @param ev the event @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int event_base_set(struct event_base *, struct event *); /** @name Loop flags @@ -637,6 +800,11 @@ int event_base_set(struct event_base *, struct event *); /** Do not block: see which events are ready now, run the callbacks * of the highest-priority ones, then exit. */ #define EVLOOP_NONBLOCK 0x02 +/** Do not exit the loop because we have no pending events. Instead, keep + * running until event_base_loopexit() or event_base_loopbreak() makes us + * stop. + */ +#define EVLOOP_NO_EXIT_ON_EMPTY 0x04 /**@}*/ /** @@ -657,6 +825,7 @@ int event_base_set(struct event_base *, struct event *); @see event_base_loopexit(), event_base_dispatch(), EVLOOP_ONCE, EVLOOP_NONBLOCK */ +EVENT2_EXPORT_SYMBOL int event_base_loop(struct event_base *, int); /** @@ -674,6 +843,7 @@ int event_base_loop(struct event_base *, int); @return 0 if successful, or -1 if an error occurred @see event_base_loopbreak() */ +EVENT2_EXPORT_SYMBOL int event_base_loopexit(struct event_base *, const struct timeval *); /** @@ -683,16 +853,37 @@ int event_base_loopexit(struct event_base *, const struct timeval *); event_base_loopbreak() is typically invoked from this event's callback. This behavior is analogous to the "break;" statement. - Subsequent invocations of event_loop() will proceed normally. + Subsequent invocations of event_base_loop() will proceed normally. @param eb the event_base structure returned by event_init() @return 0 if successful, or -1 if an error occurred @see event_base_loopexit() */ +EVENT2_EXPORT_SYMBOL int event_base_loopbreak(struct event_base *); /** - Checks if the event loop was told to exit by event_loopexit(). + Tell the active event_base_loop() to scan for new events immediately. + + Calling this function makes the currently active event_base_loop() + start the loop over again (scanning for new events) after the current + event callback finishes. If the event loop is not running, this + function has no effect. + + event_base_loopbreak() is typically invoked from this event's callback. + This behavior is analogous to the "continue;" statement. + + Subsequent invocations of event loop will proceed normally. + + @param eb the event_base structure returned by event_init() + @return 0 if successful, or -1 if an error occurred + @see event_base_loopbreak() + */ +EVENT2_EXPORT_SYMBOL +int event_base_loopcontinue(struct event_base *); + +/** + Checks if the event loop was told to exit by event_base_loopexit(). This function will return true for an event_base at every point after event_loopexit() is called, until the event loop is next entered. @@ -703,13 +894,14 @@ int event_base_loopbreak(struct event_base *); @see event_base_loopexit() @see event_base_got_break() */ +EVENT2_EXPORT_SYMBOL int event_base_got_exit(struct event_base *); /** - Checks if the event loop was told to abort immediately by event_loopbreak(). + Checks if the event loop was told to abort immediately by event_base_loopbreak(). This function will return true for an event_base at every point after - event_loopbreak() is called, until the event loop is next entered. + event_base_loopbreak() is called, until the event loop is next entered. @param eb the event_base structure returned by event_init() @return true if event_base_loopbreak() was called on this event base, @@ -717,6 +909,7 @@ int event_base_got_exit(struct event_base *); @see event_base_loopbreak() @see event_base_got_exit() */ +EVENT2_EXPORT_SYMBOL int event_base_got_break(struct event_base *); /** @@ -743,7 +936,28 @@ int event_base_got_break(struct event_base *); */ #define EV_PERSIST 0x10 /** Select edge-triggered behavior, if supported by the backend. */ -#define EV_ET 0x20 +#define EV_ET 0x20 +/** + * If this option is provided, then event_del() will not block in one thread + * while waiting for the event callback to complete in another thread. + * + * To use this option safely, you may need to use event_finalize() or + * event_free_finalize() in order to safely tear down an event in a + * multithreaded application. See those functions for more information. + * + * THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + * BECOMES STABLE. + **/ +#define EV_FINALIZE 0x40 +/** + * Detects connection close events. You can use this to detect when a + * connection has been closed, without having to read all the pending data + * from a connection. + * + * Not all backends support EV_CLOSED. To detect or require it, use the + * feature flag EV_FEATURE_EARLY_CLOSE. + **/ +#define EV_CLOSED 0x80 /**@}*/ /** @@ -790,6 +1004,31 @@ int event_base_got_break(struct event_base *); typedef void (*event_callback_fn)(evutil_socket_t, short, void *); /** + Return a value used to specify that the event itself must be used as the callback argument. + + The function event_new() takes a callback argument which is passed + to the event's callback function. To specify that the argument to be + passed to the callback function is the event that event_new() returns, + pass in the return value of event_self_cbarg() as the callback argument + for event_new(). + + For example: + <pre> + struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg()); + </pre> + + For consistency with event_new(), it is possible to pass the return value + of this function as the callback argument for event_assign() – this + achieves the same result as passing the event in directly. + + @return a value to be passed as the callback argument to event_new() or + event_assign(). + @see event_new(), event_assign() + */ +EVENT2_EXPORT_SYMBOL +void *event_self_cbarg(void); + +/** Allocate and asssign a new event structure, ready to be added. The function event_new() returns a new event that can be used in @@ -837,6 +1076,7 @@ typedef void (*event_callback_fn)(evutil_socket_t, short, void *); event_free(). @see event_free(), event_add(), event_del(), event_assign() */ +EVENT2_EXPORT_SYMBOL struct event *event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *); @@ -878,6 +1118,7 @@ struct event *event_new(struct event_base *, evutil_socket_t, short, event_callb @see event_new(), event_add(), event_del(), event_base_once(), event_get_struct_event_size() */ +EVENT2_EXPORT_SYMBOL int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *); /** @@ -886,18 +1127,69 @@ int event_assign(struct event *, struct event_base *, evutil_socket_t, short, ev If the event is pending or active, first make it non-pending and non-active. */ +EVENT2_EXPORT_SYMBOL void event_free(struct event *); /** + * Callback type for event_finalize and event_free_finalize(). + * + * THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + * BECOMES STABLE. + * + **/ +typedef void (*event_finalize_callback_fn)(struct event *, void *); +/** + @name Finalization functions + + These functions are used to safely tear down an event in a multithreaded + application. If you construct your events with EV_FINALIZE to avoid + deadlocks, you will need a way to remove an event in the certainty that + it will definitely not be running its callback when you deallocate it + and its callback argument. + + To do this, call one of event_finalize() or event_free_finalize with + 0 for its first argument, the event to tear down as its second argument, + and a callback function as its third argument. The callback will be + invoked as part of the event loop, with the event's priority. + + After you call a finalizer function, event_add() and event_active() will + no longer work on the event, and event_del() will produce a no-op. You + must not try to change the event's fields with event_assign() or + event_set() while the finalize callback is in progress. Once the + callback has been invoked, you should treat the event structure as + containing uninitialized memory. + + The event_free_finalize() function frees the event after it's finalized; + event_finalize() does not. + + A finalizer callback must not make events pending or active. It must not + add events, activate events, or attempt to "resucitate" the event being + finalized in any way. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + + @return 0 on succes, -1 on failure. + */ +/**@{*/ +EVENT2_EXPORT_SYMBOL +int event_finalize(unsigned, struct event *, event_finalize_callback_fn); +EVENT2_EXPORT_SYMBOL +int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn); +/**@}*/ + +/** Schedule a one-time event - The function event_base_once() is similar to event_set(). However, it + The function event_base_once() is similar to event_new(). However, it schedules a callback to be called exactly once, and does not require the caller to prepare an event structure. - Note that in Libevent 2.0 and earlier, if the event is never triggered, - the internal memory used to hold it will never be freed. This may be - fixed in a later version of Libevent. + Note that in Libevent 2.0 and earlier, if the event is never triggered, the + internal memory used to hold it will never be freed. In Libevent 2.1, + the internal memory will get freed by event_base_free() if the event + is never triggered. The 'arg' value, however, will not get freed in either + case--you'll need to free that on your own if you want it to go away. @param base an event_base @param fd a file descriptor to monitor, or -1 for no fd. @@ -910,13 +1202,14 @@ void event_free(struct event *); EV_TIMEOUT event succees immediately. @return 0 if successful, or -1 if an error occurred */ +EVENT2_EXPORT_SYMBOL int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_fn, void *, const struct timeval *); /** Add an event to the set of pending events. - The function event_add() schedules the execution of the ev event when the - event specified in event_assign()/event_new() occurs, or when the time + The function event_add() schedules the execution of the event 'ev' when the + condition specified by event_assign() or event_new() occurs, or when the time specified in timeout has elapesed. If atimeout is NULL, no timeout occurs and the function will only be called if a matching event occurs. The event in the @@ -925,18 +1218,30 @@ int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_ in calls to event_assign() until it is no longer pending. If the event in the ev argument already has a scheduled timeout, calling - event_add() replaces the old timeout with the new one, or clears the old - timeout if the timeout argument is NULL. + event_add() replaces the old timeout with the new one if tv is non-NULL. - @param ev an event struct initialized via event_set() + @param ev an event struct initialized via event_assign() or event_new() @param timeout the maximum amount of time to wait for the event, or NULL to wait forever @return 0 if successful, or -1 if an error occurred @see event_del(), event_assign(), event_new() */ +EVENT2_EXPORT_SYMBOL int event_add(struct event *ev, const struct timeval *timeout); /** + Remove a timer from a pending event without removing the event itself. + + If the event has a scheduled timeout, this function unschedules it but + leaves the event otherwise pending. + + @param ev an event struct initialized via event_assign() or event_new() + @return 0 on success, or -1 if an error occurrect. +*/ +EVENT2_EXPORT_SYMBOL +int event_remove_timer(struct event *ev); + +/** Remove an event from the set of monitored events. The function event_del() will cancel the event in the argument ev. If the @@ -947,8 +1252,29 @@ int event_add(struct event *ev, const struct timeval *timeout); @return 0 if successful, or -1 if an error occurred @see event_add() */ +EVENT2_EXPORT_SYMBOL int event_del(struct event *); +/** + As event_del(), but never blocks while the event's callback is running + in another thread, even if the event was constructed without the + EV_FINALIZE flag. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +int event_del_noblock(struct event *ev); +/** + As event_del(), but always blocks while the event's callback is running + in another thread, even if the event was constructed with the + EV_FINALIZE flag. + + THIS IS AN EXPERIMENTAL API. IT MIGHT CHANGE BEFORE THE LIBEVENT 2.1 SERIES + BECOMES STABLE. + */ +EVENT2_EXPORT_SYMBOL +int event_del_block(struct event *ev); /** Make an event active. @@ -964,6 +1290,7 @@ int event_del(struct event *); @param res a set of flags to pass to the event's callback. @param ncalls an obsolete argument: this is ignored. **/ +EVENT2_EXPORT_SYMBOL void event_active(struct event *ev, int res, short ncalls); /** @@ -979,8 +1306,17 @@ void event_active(struct event *ev, int res, short ncalls); @return true if the event is pending on any of the events in 'what', (that is to say, it has been added), or 0 if the event is not added. */ +EVENT2_EXPORT_SYMBOL int event_pending(const struct event *ev, short events, struct timeval *tv); +/** + If called from within the callback for an event, returns that event. + + The behavior of this function is not defined when called from outside the + callback function for an event. + */ +EVENT2_EXPORT_SYMBOL +struct event *event_base_get_running_event(struct event_base *base); /** Test if an event structure might be initialized. @@ -997,6 +1333,7 @@ int event_pending(const struct event *ev, short events, struct timeval *tv); @return 1 if the structure might be initialized, or 0 if it has not been initialized */ +EVENT2_EXPORT_SYMBOL int event_initialized(const struct event *ev); /** @@ -1008,35 +1345,48 @@ int event_initialized(const struct event *ev); Get the socket or signal assigned to an event, or -1 if the event has no socket. */ +EVENT2_EXPORT_SYMBOL evutil_socket_t event_get_fd(const struct event *ev); /** Get the event_base associated with an event. */ +EVENT2_EXPORT_SYMBOL struct event_base *event_get_base(const struct event *ev); /** Return the events (EV_READ, EV_WRITE, etc) assigned to an event. */ +EVENT2_EXPORT_SYMBOL short event_get_events(const struct event *ev); /** Return the callback assigned to an event. */ +EVENT2_EXPORT_SYMBOL event_callback_fn event_get_callback(const struct event *ev); /** Return the callback argument assigned to an event. */ +EVENT2_EXPORT_SYMBOL void *event_get_callback_arg(const struct event *ev); /** + Return the priority of an event. + @see event_priority_init(), event_get_priority() +*/ +EVENT2_EXPORT_SYMBOL +int event_get_priority(const struct event *ev); + +/** Extract _all_ of arguments given to construct a given event. The event_base is copied into *base_out, the fd is copied into *fd_out, and so on. If any of the "_out" arguments is NULL, it will be ignored. */ +EVENT2_EXPORT_SYMBOL void event_get_assignment(const struct event *event, struct event_base **base_out, evutil_socket_t *fd_out, short *events_out, event_callback_fn *callback_out, void **arg_out); @@ -1054,6 +1404,7 @@ void event_get_assignment(const struct event *event, We might do this to help ensure ABI-compatibility between different versions of Libevent. */ +EVENT2_EXPORT_SYMBOL size_t event_get_struct_event_size(void); /** @@ -1065,6 +1416,7 @@ size_t event_get_struct_event_size(void); @return a string containing the version number of Libevent */ +EVENT2_EXPORT_SYMBOL const char *event_get_version(void); /** @@ -1078,13 +1430,14 @@ const char *event_get_version(void); the version number. The low-order byte is unused. For example, version 2.0.1-alpha has a numeric representation of 0x02000100 */ +EVENT2_EXPORT_SYMBOL ev_uint32_t event_get_version_number(void); /** As event_get_version, but gives the version of Libevent's headers. */ -#define LIBEVENT_VERSION _EVENT_VERSION +#define LIBEVENT_VERSION EVENT__VERSION /** As event_get_version_number, but gives the version number of Libevent's * headers. */ -#define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION +#define LIBEVENT_VERSION_NUMBER EVENT__NUMERIC_VERSION /** Largest number of priorities that Libevent can support. */ #define EVENT_MAX_PRIORITIES 256 @@ -1115,16 +1468,28 @@ ev_uint32_t event_get_version_number(void); @return 0 if successful, or -1 if an error occurred @see event_priority_set() */ +EVENT2_EXPORT_SYMBOL int event_base_priority_init(struct event_base *, int); /** + Get the number of different event priorities. + + @param eb the event_base structure returned by event_base_new() + @return Number of different event priorities + @see event_base_priority_init() +*/ +EVENT2_EXPORT_SYMBOL +int event_base_get_npriorities(struct event_base *eb); + +/** Assign a priority to an event. @param ev an event struct @param priority the new priority to be assigned @return 0 if successful, or -1 if an error occurred - @see event_priority_init() + @see event_priority_init(), event_get_priority() */ +EVENT2_EXPORT_SYMBOL int event_priority_set(struct event *, int); /** @@ -1146,10 +1511,11 @@ int event_priority_set(struct event *, int); (This optimization probably will not be worthwhile until you have thousands or tens of thousands of events with the same timeout.) */ +EVENT2_EXPORT_SYMBOL const struct timeval *event_base_init_common_timeout(struct event_base *base, const struct timeval *duration); -#if !defined(_EVENT_DISABLE_MM_REPLACEMENT) || defined(_EVENT_IN_DOXYGEN) +#if !defined(EVENT__DISABLE_MM_REPLACEMENT) || defined(EVENT_IN_DOXYGEN_) /** Override the functions that Libevent uses for memory management. @@ -1172,6 +1538,7 @@ const struct timeval *event_base_init_common_timeout(struct event_base *base, @param realloc_fn A replacement for realloc @param free_fn A replacement for free. **/ +EVENT2_EXPORT_SYMBOL void event_set_mem_functions( void *(*malloc_fn)(size_t sz), void *(*realloc_fn)(void *ptr, size_t sz), @@ -1181,8 +1548,79 @@ void event_set_mem_functions( #define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED #endif +/** + Writes a human-readable description of all inserted and/or active + events to a provided stdio stream. + + This is intended for debugging; its format is not guaranteed to be the same + between libevent versions. + + @param base An event_base on which to scan the events. + @param output A stdio file to write on. + */ +EVENT2_EXPORT_SYMBOL void event_base_dump_events(struct event_base *, FILE *); + +/** + Activates all pending events for the given fd and event mask. + + This function activates pending events only. Events which have not been + added will not become active. + + @param base the event_base on which to activate the events. + @param fd An fd to active events on. + @param events One or more of EV_{READ,WRITE}. + */ +EVENT2_EXPORT_SYMBOL +void event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events); + +/** + Activates all pending signals with a given signal number + + This function activates pending events only. Events which have not been + added will not become active. + + @param base the event_base on which to activate the events. + @param fd The signal to active events on. + */ +EVENT2_EXPORT_SYMBOL +void event_base_active_by_signal(struct event_base *base, int sig); + +/** + * Callback for iterating events in an event base via event_base_foreach_event + */ +typedef int (*event_base_foreach_event_cb)(const struct event_base *, const struct event *, void *); + +/** + Iterate over all added or active events events in an event loop, and invoke + a given callback on each one. + + The callback must not call any function that modifies the event base, that + modifies any event in the event base, or that adds or removes any event to + the event base. Doing so is unsupported and will lead to undefined + behavior -- likely, to crashes. + + event_base_foreach_event() holds a lock on the event_base() for the whole + time it's running: slow callbacks are not advisable. + + Note that Libevent adds some events of its own to make pieces of its + functionality work. You must not assume that the only events you'll + encounter will be the ones you added yourself. + + The callback function must return 0 to continue iteration, or some other + integer to stop iterating. + + @param base An event_base on which to scan the events. + @param fn A callback function to receive the events. + @param arg An argument passed to the callback function. + @return 0 if we iterated over every event, or the value returned by the + callback function if the loop exited early. +*/ +EVENT2_EXPORT_SYMBOL +int event_base_foreach_event(struct event_base *base, event_base_foreach_event_cb fn, void *arg); + + /** Sets 'tv' to the current time (as returned by gettimeofday()), looking at the cached value in 'base' if possible, and calling gettimeofday() or clock_gettime() as appropriate if there is no @@ -1194,11 +1632,44 @@ void event_base_dump_events(struct event_base *, FILE *); Returns 0 on success, negative on failure. */ +EVENT2_EXPORT_SYMBOL int event_base_gettimeofday_cached(struct event_base *base, struct timeval *tv); +/** Update cached_tv in the 'base' to the current time + * + * You can use this function is useful for selectively increasing + * the accuracy of the cached time value in 'base' during callbacks + * that take a long time to execute. + * + * This function has no effect if the base is currently not in its + * event loop, or if timeval caching is disabled via + * EVENT_BASE_FLAG_NO_CACHE_TIME. + * + * @return 0 on success, -1 on failure + */ +EVENT2_EXPORT_SYMBOL +int event_base_update_cache_time(struct event_base *base); + +/** Release up all globally-allocated resources allocated by Libevent. + + This function does not free developer-controlled resources like + event_bases, events, bufferevents, listeners, and so on. It only releases + resources like global locks that there is no other way to free. + + It is not actually necessary to call this function before exit: every + resource that it frees would be released anyway on exit. It mainly exists + so that resource-leak debugging tools don't see Libevent as holding + resources at exit. + + You should only call this function when no other Libevent functions will + be invoked -- e.g., when cleanly exiting a program. + */ +EVENT2_EXPORT_SYMBOL +void libevent_global_shutdown(void); + #ifdef __cplusplus } #endif -#endif /* _EVENT2_EVENT_H_ */ +#endif /* EVENT2_EVENT_H_INCLUDED_ */ diff --git a/include/event2/event_compat.h b/include/event2/event_compat.h index 14a10e9..5110175 100644 --- a/include/event2/event_compat.h +++ b/include/event2/event_compat.h @@ -24,8 +24,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_EVENT_COMPAT_H_ -#define _EVENT2_EVENT_COMPAT_H_ +#ifndef EVENT2_EVENT_COMPAT_H_INCLUDED_ +#define EVENT2_EVENT_COMPAT_H_INCLUDED_ /** @file event2/event_compat.h @@ -41,16 +41,17 @@ @deprecated All functions in this file are by definition deprecated. */ +#include <event2/visibility.h> #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -70,6 +71,7 @@ extern "C" { @see event_base_set(), event_base_new() */ +EVENT2_EXPORT_SYMBOL struct event_base *event_init(void); /** @@ -83,6 +85,7 @@ struct event_base *event_init(void); @see event_base_dispatch(), event_init() */ +EVENT2_EXPORT_SYMBOL int event_dispatch(void); /** @@ -96,6 +99,7 @@ int event_dispatch(void); @see event_base_loop(), event_init() */ +EVENT2_EXPORT_SYMBOL int event_loop(int); @@ -111,6 +115,7 @@ int event_loop(int); @see event_init, event_base_loopexit() */ +EVENT2_EXPORT_SYMBOL int event_loopexit(const struct timeval *); @@ -126,6 +131,7 @@ int event_loopexit(const struct timeval *); @see event_base_loopbreak(), event_init() */ +EVENT2_EXPORT_SYMBOL int event_loopbreak(void); /** @@ -137,6 +143,7 @@ int event_loopbreak(void); @see event_base_once() */ +EVENT2_EXPORT_SYMBOL int event_once(evutil_socket_t , short, void (*)(evutil_socket_t, short, void *), void *, const struct timeval *); @@ -150,6 +157,7 @@ int event_once(evutil_socket_t , short, @see event_base_get_method() */ +EVENT2_EXPORT_SYMBOL const char *event_get_method(void); @@ -162,6 +170,7 @@ const char *event_get_method(void); @see event_base_priority_init() */ +EVENT2_EXPORT_SYMBOL int event_priority_init(int); /** @@ -171,6 +180,7 @@ int event_priority_init(int); a subsequent call to event_base_set() to be safe under most circumstances. Use event_assign() or event_new() instead. */ +EVENT2_EXPORT_SYMBOL void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); #define evtimer_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg)) @@ -217,4 +227,4 @@ void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, } #endif -#endif /* _EVENT2_EVENT_COMPAT_H_ */ +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/include/event2/event_struct.h b/include/event2/event_struct.h index 2ed4272..1c8b71b 100644 --- a/include/event2/event_struct.h +++ b/include/event2/event_struct.h @@ -24,8 +24,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_EVENT_STRUCT_H_ -#define _EVENT2_EVENT_STRUCT_H_ +#ifndef EVENT2_EVENT_STRUCT_H_INCLUDED_ +#define EVENT2_EVENT_STRUCT_H_INCLUDED_ /** @file event2/event_struct.h @@ -41,10 +41,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -54,19 +54,20 @@ extern "C" { /* For evkeyvalq */ #include <event2/keyvalq_struct.h> -#define EVLIST_TIMEOUT 0x01 -#define EVLIST_INSERTED 0x02 -#define EVLIST_SIGNAL 0x04 -#define EVLIST_ACTIVE 0x08 -#define EVLIST_INTERNAL 0x10 -#define EVLIST_INIT 0x80 +#define EVLIST_TIMEOUT 0x01 +#define EVLIST_INSERTED 0x02 +#define EVLIST_SIGNAL 0x04 +#define EVLIST_ACTIVE 0x08 +#define EVLIST_INTERNAL 0x10 +#define EVLIST_ACTIVE_LATER 0x20 +#define EVLIST_FINALIZING 0x40 +#define EVLIST_INIT 0x80 -/* EVLIST_X_ Private space: 0x1000-0xf000 */ -#define EVLIST_ALL (0xf000 | 0x9f) +#define EVLIST_ALL 0xff /* Fix so that people don't have to run with <sys/queue.h> */ #ifndef TAILQ_ENTRY -#define _EVENT_DEFINED_TQENTRY +#define EVENT_DEFINED_TQENTRY_ #define TAILQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ @@ -75,7 +76,7 @@ struct { \ #endif /* !TAILQ_ENTRY */ #ifndef TAILQ_HEAD -#define _EVENT_DEFINED_TQHEAD +#define EVENT_DEFINED_TQHEAD_ #define TAILQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; \ @@ -83,10 +84,45 @@ struct name { \ } #endif +/* Fix so that people don't have to run with <sys/queue.h> */ +#ifndef LIST_ENTRY +#define EVENT_DEFINED_LISTENTRY_ +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} +#endif /* !LIST_ENTRY */ + +#ifndef LIST_HEAD +#define EVENT_DEFINED_LISTHEAD_ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ + } +#endif /* !LIST_HEAD */ + +struct event; + +struct event_callback { + TAILQ_ENTRY(event_callback) evcb_active_next; + short evcb_flags; + ev_uint8_t evcb_pri; /* smaller numbers are higher priority */ + ev_uint8_t evcb_closure; + /* allows us to adopt for different types of events */ + union { + void (*evcb_callback)(evutil_socket_t, short, void *); + void (*evcb_selfcb)(struct event_callback *, void *); + void (*evcb_evfinalize)(struct event *, void *); + void (*evcb_cbfinalize)(struct event_callback *, void *); + } evcb_cb_union; + void *evcb_arg; +}; + struct event_base; struct event { - TAILQ_ENTRY(event) ev_active_next; - TAILQ_ENTRY(event) ev_next; + struct event_callback ev_evcallback; + /* for managing timeouts */ union { TAILQ_ENTRY(event) ev_next_with_common_timeout; @@ -99,43 +135,46 @@ struct event { union { /* used for io events */ struct { - TAILQ_ENTRY(event) ev_io_next; + LIST_ENTRY (event) ev_io_next; struct timeval ev_timeout; } ev_io; /* used by signal events */ struct { - TAILQ_ENTRY(event) ev_signal_next; + LIST_ENTRY (event) ev_signal_next; short ev_ncalls; /* Allows deletes in callback */ short *ev_pncalls; } ev_signal; - } _ev; + } ev_; short ev_events; short ev_res; /* result passed to event callback */ - short ev_flags; - ev_uint8_t ev_pri; /* smaller numbers are higher priority */ - ev_uint8_t ev_closure; struct timeval ev_timeout; - - /* allows us to adopt for different types of events */ - void (*ev_callback)(evutil_socket_t, short, void *arg); - void *ev_arg; }; TAILQ_HEAD (event_list, event); -#ifdef _EVENT_DEFINED_TQENTRY +#ifdef EVENT_DEFINED_TQENTRY_ #undef TAILQ_ENTRY #endif -#ifdef _EVENT_DEFINED_TQHEAD +#ifdef EVENT_DEFINED_TQHEAD_ #undef TAILQ_HEAD #endif +LIST_HEAD (event_dlist, event); + +#ifdef EVENT_DEFINED_LISTENTRY_ +#undef LIST_ENTRY +#endif + +#ifdef EVENT_DEFINED_LISTHEAD_ +#undef LIST_HEAD +#endif + #ifdef __cplusplus } #endif -#endif /* _EVENT2_EVENT_STRUCT_H_ */ +#endif /* EVENT2_EVENT_STRUCT_H_INCLUDED_ */ diff --git a/include/event2/http.h b/include/event2/http.h index c6ee1db..8fb5642 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -24,11 +24,12 @@ * (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_HTTP_H_ -#define _EVENT2_HTTP_H_ +#ifndef EVENT2_HTTP_H_INCLUDED_ +#define EVENT2_HTTP_H_INCLUDED_ /* For int types. */ #include <event2/util.h> +#include <event2/visibility.h> #ifdef __cplusplus extern "C" { @@ -37,6 +38,8 @@ extern "C" { /* In case we haven't included the right headers yet. */ struct evbuffer; struct event_base; +struct bufferevent; +struct evhttp_connection; /** @file event2/http.h * @@ -69,6 +72,7 @@ struct evhttp_request; struct evkeyvalq; struct evhttp_bound_socket; struct evconnlistener; +struct evdns_base; /** * Create a new HTTP server. @@ -77,6 +81,7 @@ struct evconnlistener; * @return a pointer to a newly initialized evhttp server structure * @see evhttp_free() */ +EVENT2_EXPORT_SYMBOL struct evhttp *evhttp_new(struct event_base *base); /** @@ -91,6 +96,7 @@ struct evhttp *evhttp_new(struct event_base *base); * @return 0 on success, -1 on failure. * @see evhttp_accept_socket() */ +EVENT2_EXPORT_SYMBOL int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port); /** @@ -104,6 +110,7 @@ int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t por * @return Handle for the socket on success, NULL on failure. * @see evhttp_bind_socket(), evhttp_del_accept_socket() */ +EVENT2_EXPORT_SYMBOL struct evhttp_bound_socket *evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port); /** @@ -122,6 +129,7 @@ struct evhttp_bound_socket *evhttp_bind_socket_with_handle(struct evhttp *http, * @return 0 on success, -1 on failure. * @see evhttp_bind_socket() */ +EVENT2_EXPORT_SYMBOL int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd); /** @@ -134,6 +142,7 @@ int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd); * @return Handle for the socket on success, NULL on failure. * @see evhttp_accept_socket(), evhttp_del_accept_socket() */ +EVENT2_EXPORT_SYMBOL struct evhttp_bound_socket *evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd); /** @@ -141,13 +150,29 @@ struct evhttp_bound_socket *evhttp_accept_socket_with_handle(struct evhttp *http * returns an evhttp_bound_socket. The listener will be freed when the bound * socket is freed. */ +EVENT2_EXPORT_SYMBOL struct evhttp_bound_socket *evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener); /** * Return the listener used to implement a bound socket. */ +EVENT2_EXPORT_SYMBOL struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound); +typedef void evhttp_bound_socket_foreach_fn(struct evhttp_bound_socket *, void *); +/** + * Applies the function specified in the first argument to all + * evhttp_bound_sockets associated with "http". The user must not + * attempt to free or remove any connections, sockets or listeners + * in the callback "function". + * + * @param http pointer to an evhttp object + * @param function function to apply to every bound socket + * @param argument pointer value passed to function for every socket iterated + */ +EVENT2_EXPORT_SYMBOL +void evhttp_foreach_bound_socket(struct evhttp *http, evhttp_bound_socket_foreach_fn *function, void *argument); + /** * Makes an HTTP server stop accepting connections on the specified socket * @@ -165,6 +190,7 @@ struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_sock * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle() */ +EVENT2_EXPORT_SYMBOL void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound_socket); /** @@ -174,6 +200,7 @@ void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *b * @return the file descriptor used by the bound socket * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle() */ +EVENT2_EXPORT_SYMBOL evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket); /** @@ -184,14 +211,29 @@ evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_soc * @param http the evhttp server object to be freed * @see evhttp_start() */ +EVENT2_EXPORT_SYMBOL void evhttp_free(struct evhttp* http); /** XXX Document. */ +EVENT2_EXPORT_SYMBOL void evhttp_set_max_headers_size(struct evhttp* http, ev_ssize_t max_headers_size); /** XXX Document. */ +EVENT2_EXPORT_SYMBOL void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size); /** + Set the value to use for the Content-Type header when none was provided. If + the content type string is NULL, the Content-Type header will not be + automatically added. + + @param http the http server on which to set the default content type + @param content_type the value for the Content-Type header +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_set_default_content_type(struct evhttp *http, + const char *content_type); + +/** Sets the what HTTP methods are supported in requests accepted by this server, and passed to user callbacks. @@ -202,6 +244,7 @@ void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size); @param http the http server on which to set the methods @param methods bit mask constructed from evhttp_cmd_type values */ +EVENT2_EXPORT_SYMBOL void evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods); /** @@ -213,10 +256,12 @@ void evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods); @param cb_arg an additional context argument for the callback @return 0 on success, -1 if the callback existed already, -2 on failure */ +EVENT2_EXPORT_SYMBOL int evhttp_set_cb(struct evhttp *http, const char *path, void (*cb)(struct evhttp_request *, void *), void *cb_arg); /** Removes the callback for a specified URI */ +EVENT2_EXPORT_SYMBOL int evhttp_del_cb(struct evhttp *, const char *); /** @@ -230,10 +275,29 @@ int evhttp_del_cb(struct evhttp *, const char *); @param cb the callback to invoke for any unmatched requests @param arg an context argument for the callback */ +EVENT2_EXPORT_SYMBOL void evhttp_set_gencb(struct evhttp *http, void (*cb)(struct evhttp_request *, void *), void *arg); /** + Set a callback used to create new bufferevents for connections + to a given evhttp object. + + You can use this to override the default bufferevent type -- for example, + to make this evhttp object use SSL bufferevents rather than unencrypted + ones. + + New bufferevents must be allocated with no fd set on them. + + @param http the evhttp server object for which to set the callback + @param cb the callback to invoke for incoming connections + @param arg an context argument for the callback + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_bevcb(struct evhttp *http, + struct bufferevent *(*cb)(struct event_base *, void *), void *arg); + +/** Adds a virtual host to the http server. A virtual host is a newly initialized evhttp object that has request @@ -255,6 +319,7 @@ void evhttp_set_gencb(struct evhttp *http, @return 0 on success, -1 on failure @see evhttp_remove_virtual_host() */ +EVENT2_EXPORT_SYMBOL int evhttp_add_virtual_host(struct evhttp* http, const char *pattern, struct evhttp* vhost); @@ -266,6 +331,7 @@ int evhttp_add_virtual_host(struct evhttp* http, const char *pattern, @return 0 on success, -1 on failure @see evhttp_add_virtual_host() */ +EVENT2_EXPORT_SYMBOL int evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost); /** @@ -276,6 +342,7 @@ int evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost); @param alias the alias to add @see evhttp_add_remove_alias() */ +EVENT2_EXPORT_SYMBOL int evhttp_add_server_alias(struct evhttp *http, const char *alias); /** @@ -285,6 +352,7 @@ int evhttp_add_server_alias(struct evhttp *http, const char *alias); @param alias the alias to remove @see evhttp_add_server_alias() */ +EVENT2_EXPORT_SYMBOL int evhttp_remove_server_alias(struct evhttp *http, const char *alias); /** @@ -293,8 +361,31 @@ int evhttp_remove_server_alias(struct evhttp *http, const char *alias); * @param http an evhttp object * @param timeout_in_secs the timeout, in seconds */ +EVENT2_EXPORT_SYMBOL void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs); +/** + * Set the timeout for an HTTP request. + * + * @param http an evhttp object + * @param tv the timeout, or NULL + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_timeout_tv(struct evhttp *http, const struct timeval* tv); + +/* Read all the clients body, and only after this respond with an error if the + * clients body exceed max_body_size */ +#define EVHTTP_SERVER_LINGERING_CLOSE 0x0001 +/** + * Set connection flags for HTTP server. + * + * @see EVHTTP_SERVER_* + * @return 0 on success, otherwise non zero (for example if flag doesn't + * supported). + */ +EVENT2_EXPORT_SYMBOL +int evhttp_set_flags(struct evhttp *http, int flags); + /* Request/Response functionality */ /** @@ -305,6 +396,7 @@ void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs); * @param reason a brief explanation of the error. If this is NULL, we'll * just use the standard meaning of the error code. */ +EVENT2_EXPORT_SYMBOL void evhttp_send_error(struct evhttp_request *req, int error, const char *reason); @@ -321,6 +413,7 @@ void evhttp_send_error(struct evhttp_request *req, int error, * @param reason a brief message to send with the response code * @param databuf the body of the response */ +EVENT2_EXPORT_SYMBOL void evhttp_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf); @@ -340,6 +433,7 @@ void evhttp_send_reply(struct evhttp_request *req, int code, @param code the HTTP response code to send @param reason a brief message to send with the response code */ +EVENT2_EXPORT_SYMBOL void evhttp_send_reply_start(struct evhttp_request *req, int code, const char *reason); @@ -354,13 +448,33 @@ void evhttp_send_reply_start(struct evhttp_request *req, int code, @param req a request object @param databuf the data chunk to send as part of the reply. */ +EVENT2_EXPORT_SYMBOL void evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf); + +/** + Send another data chunk as part of an ongoing chunked reply. + + The reply chunk consists of the data in databuf. After calling + evhttp_send_reply_chunk() databuf will be empty, but the buffer is + still owned by the caller and needs to be deallocated by the caller + if necessary. + + @param req a request object + @param databuf the data chunk to send as part of the reply. + @param cb callback funcion + @param call back's argument. +*/ +EVENT2_EXPORT_SYMBOL +void evhttp_send_reply_chunk_with_cb(struct evhttp_request *, struct evbuffer *, + void (*cb)(struct evhttp_connection *, void *), void *arg); + /** Complete a chunked reply, freeing the request as appropriate. @param req a request object */ +EVENT2_EXPORT_SYMBOL void evhttp_send_reply_end(struct evhttp_request *req); /* @@ -390,10 +504,42 @@ enum evhttp_cmd_type { enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE }; /** + * Create and return a connection object that can be used to for making HTTP + * requests. The connection object tries to resolve address and establish the + * connection when it is given an http request object. + * + * @param base the event_base to use for handling the connection + * @param dnsbase the dns_base to use for resolving host names; if not + * specified host name resolution will block. + * @param bev a bufferevent to use for connecting to the server; if NULL, a + * socket-based bufferevent will be created. This buffrevent will be freed + * when the connection closes. It must have no fd set on it. + * @param address the address to which to connect + * @param port the port to connect to + * @return an evhttp_connection object that can be used for making requests + */ +EVENT2_EXPORT_SYMBOL +struct evhttp_connection *evhttp_connection_base_bufferevent_new( + struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port); + +/** + * Return the bufferevent that an evhttp_connection is using. + */ +EVENT2_EXPORT_SYMBOL +struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon); + +/** + * Return the HTTP server associated with this connection, or NULL. + */ +EVENT2_EXPORT_SYMBOL +struct evhttp *evhttp_connection_get_server(struct evhttp_connection *evcon); + +/** * Creates a new request object that needs to be filled in with the request * parameters. The callback is executed when the request completed or an * error occurred. */ +EVENT2_EXPORT_SYMBOL struct evhttp_request *evhttp_request_new( void (*cb)(struct evhttp_request *, void *), void *arg); @@ -404,18 +550,86 @@ struct evhttp_request *evhttp_request_new( * response. May drain the input buffer; it will be drained * automatically on return. */ +EVENT2_EXPORT_SYMBOL void evhttp_request_set_chunked_cb(struct evhttp_request *, void (*cb)(struct evhttp_request *, void *)); +/** + * Register callback for additional parsing of request headers. + * @param cb will be called after receiving and parsing the full header. + * It allows analyzing the header and possibly closing the connection + * by returning a value < 0. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_header_cb(struct evhttp_request *, + int (*cb)(struct evhttp_request *, void *)); + +/** + * The different error types supported by evhttp + * + * @see evhttp_request_set_error_cb() + */ +enum evhttp_request_error { + /** + * Timeout reached, also @see evhttp_connection_set_timeout() + */ + EVREQ_HTTP_TIMEOUT, + /** + * EOF reached + */ + EVREQ_HTTP_EOF, + /** + * Error while reading header, or invalid header + */ + EVREQ_HTTP_INVALID_HEADER, + /** + * Error encountered while reading or writing + */ + EVREQ_HTTP_BUFFER_ERROR, + /** + * The evhttp_cancel_request() called on this request. + */ + EVREQ_HTTP_REQUEST_CANCEL, + /** + * Body is greater then evhttp_connection_set_max_body_size() + */ + EVREQ_HTTP_DATA_TOO_LONG +}; +/** + * Set a callback for errors + * @see evhttp_request_error for error types. + * + * On error, both the error callback and the regular callback will be called, + * error callback is called before the regular callback. + **/ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_error_cb(struct evhttp_request *, + void (*)(enum evhttp_request_error, void *)); + +/** + * Set a callback to be called on request completion of evhttp_send_* function. + * + * The callback function will be called on the completion of the request after + * the output data has been written and before the evhttp_request object + * is destroyed. This can be useful for tracking resources associated with a + * request (ex: timing metrics). + * + * @param req a request object + * @param cb callback function that will be called on request completion + * @param cb_arg an additional context argument for the callback + */ +EVENT2_EXPORT_SYMBOL +void evhttp_request_set_on_complete_cb(struct evhttp_request *req, + void (*cb)(struct evhttp_request *, void *), void *cb_arg); + /** Frees the request object and removes associated events. */ +EVENT2_EXPORT_SYMBOL void evhttp_request_free(struct evhttp_request *req); -struct evdns_base; - /** - * A connection object that can be used to for making HTTP requests. The - * connection object tries to resolve address and establish the connection - * when it is given an http request object. + * Create and return a connection object that can be used to for making HTTP + * requests. The connection object tries to resolve address and establish the + * connection when it is given an http request object. * * @param base the event_base to use for handling the connection * @param dnsbase the dns_base to use for resolving host names; if not @@ -424,24 +638,49 @@ struct evdns_base; * @param port the port to connect to * @return an evhttp_connection object that can be used for making requests */ +EVENT2_EXPORT_SYMBOL struct evhttp_connection *evhttp_connection_base_new( struct event_base *base, struct evdns_base *dnsbase, - const char *address, unsigned short port); + const char *address, ev_uint16_t port); /** - * Return the bufferevent that an evhttp_connection is using. + * Set family hint for DNS requests. */ -struct bufferevent *evhttp_connection_get_bufferevent( - struct evhttp_connection *evcon); +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_family(struct evhttp_connection *evcon, + int family); + +/* reuse connection address on retry */ +#define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008 +/* Try to read error, since server may already send and close + * connection, but if at that time we have some data to send then we + * can send get EPIPE and fail, while we can read that HTTP error. */ +#define EVHTTP_CON_READ_ON_WRITE_ERROR 0x0010 +/* @see EVHTTP_SERVER_LINGERING_CLOSE */ +#define EVHTTP_CON_LINGERING_CLOSE 0x0020 +/* Padding for public flags, @see EVHTTP_CON_* in http-internal.h */ +#define EVHTTP_CON_PUBLIC_FLAGS_END 0x100000 +/** + * Set connection flags. + * + * @see EVHTTP_CON_* + * @return 0 on success, otherwise non zero (for example if flag doesn't + * supported). + */ +EVENT2_EXPORT_SYMBOL +int evhttp_connection_set_flags(struct evhttp_connection *evcon, + int flags); /** Takes ownership of the request object * * Can be used in a request callback to keep onto the request until * evhttp_request_free() is explicitly called by the user. */ +EVENT2_EXPORT_SYMBOL void evhttp_request_own(struct evhttp_request *req); /** Returns 1 if the request is owned by the user */ +EVENT2_EXPORT_SYMBOL int evhttp_request_is_owned(struct evhttp_request *req); /** @@ -450,46 +689,89 @@ int evhttp_request_is_owned(struct evhttp_request *req); * The user needs to either free the request explicitly or call * evhttp_send_reply_end(). */ +EVENT2_EXPORT_SYMBOL struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req); /** * Returns the underlying event_base for this connection */ +EVENT2_EXPORT_SYMBOL struct event_base *evhttp_connection_get_base(struct evhttp_connection *req); +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon, ev_ssize_t new_max_headers_size); +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_max_body_size(struct evhttp_connection* evcon, ev_ssize_t new_max_body_size); /** Frees an http connection */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_free(struct evhttp_connection *evcon); +/** Disowns a given connection object + * + * Can be used to tell libevent to free the connection object after + * the last request has completed or failed. + */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_free_on_completion(struct evhttp_connection *evcon); + /** sets the ip address from which http connections are made */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_local_address(struct evhttp_connection *evcon, const char *address); /** sets the local port from which http connections are made */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_local_port(struct evhttp_connection *evcon, ev_uint16_t port); -/** Sets the timeout for events related to this connection */ +/** Sets the timeout in seconds for events related to this connection */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_timeout(struct evhttp_connection *evcon, int timeout_in_secs); +/** Sets the timeout for events related to this connection. Takes a struct + * timeval. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon, + const struct timeval *tv); + +/** Sets the delay before retrying requests on this connection. This is only + * used if evhttp_connection_set_retries is used to make the number of retries + * at least one. Each retry after the first is twice as long as the one before + * it. */ +EVENT2_EXPORT_SYMBOL +void evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon, + const struct timeval *tv); + /** Sets the retry limit for this connection - -1 repeats indefinitely */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_retries(struct evhttp_connection *evcon, int retry_max); /** Set a callback for connection close. */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_set_closecb(struct evhttp_connection *evcon, void (*)(struct evhttp_connection *, void *), void *); /** Get the remote address and port associated with this connection. */ +EVENT2_EXPORT_SYMBOL void evhttp_connection_get_peer(struct evhttp_connection *evcon, char **address, ev_uint16_t *port); +/** Get the remote address associated with this connection. + * extracted from getpeername() OR from nameserver. + * + * @return NULL if getpeername() return non success, + * or connection is not connected, + * otherwise it return pointer to struct sockaddr_storage */ +EVENT2_EXPORT_SYMBOL +const struct sockaddr* +evhttp_connection_get_addr(struct evhttp_connection *evcon); + /** Make an HTTP request over the specified connection. @@ -503,6 +785,7 @@ void evhttp_connection_get_peer(struct evhttp_connection *evcon, @return 0 on success, -1 on failure @see evhttp_cancel_request() */ +EVENT2_EXPORT_SYMBOL int evhttp_make_request(struct evhttp_connection *evcon, struct evhttp_request *req, enum evhttp_cmd_type type, const char *uri); @@ -520,6 +803,7 @@ int evhttp_make_request(struct evhttp_connection *evcon, @param req the evhttp_request to cancel; req becomes invalid after this call. */ +EVENT2_EXPORT_SYMBOL void evhttp_cancel_request(struct evhttp_request *req); /** @@ -528,26 +812,37 @@ void evhttp_cancel_request(struct evhttp_request *req); struct evhttp_uri; /** Returns the request URI */ +EVENT2_EXPORT_SYMBOL const char *evhttp_request_get_uri(const struct evhttp_request *req); /** Returns the request URI (parsed) */ +EVENT2_EXPORT_SYMBOL const struct evhttp_uri *evhttp_request_get_evhttp_uri(const struct evhttp_request *req); /** Returns the request command */ +EVENT2_EXPORT_SYMBOL enum evhttp_cmd_type evhttp_request_get_command(const struct evhttp_request *req); +EVENT2_EXPORT_SYMBOL int evhttp_request_get_response_code(const struct evhttp_request *req); +EVENT2_EXPORT_SYMBOL +const char * evhttp_request_get_response_code_line(const struct evhttp_request *req); /** Returns the input headers */ +EVENT2_EXPORT_SYMBOL struct evkeyvalq *evhttp_request_get_input_headers(struct evhttp_request *req); /** Returns the output headers */ +EVENT2_EXPORT_SYMBOL struct evkeyvalq *evhttp_request_get_output_headers(struct evhttp_request *req); /** Returns the input buffer */ +EVENT2_EXPORT_SYMBOL struct evbuffer *evhttp_request_get_input_buffer(struct evhttp_request *req); /** Returns the output buffer */ +EVENT2_EXPORT_SYMBOL struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req); /** Returns the host associated with the request. If a client sends an absolute URI, the host part of that is preferred. Otherwise, the input headers are searched for a Host: header. NULL is returned if no absolute URI or Host: header is provided. */ +EVENT2_EXPORT_SYMBOL const char *evhttp_request_get_host(struct evhttp_request *req); /* Interfaces for dealing with HTTP headers */ @@ -558,9 +853,10 @@ const char *evhttp_request_get_host(struct evhttp_request *req); @param headers the evkeyvalq object in which to find the header @param key the name of the header to find @returns a pointer to the value for the header or NULL if the header - count not be found. + could not be found. @see evhttp_add_header(), evhttp_remove_header() */ +EVENT2_EXPORT_SYMBOL const char *evhttp_find_header(const struct evkeyvalq *headers, const char *key); @@ -572,6 +868,7 @@ const char *evhttp_find_header(const struct evkeyvalq *headers, @returns 0 if the header was removed, -1 otherwise. @see evhttp_find_header(), evhttp_add_header() */ +EVENT2_EXPORT_SYMBOL int evhttp_remove_header(struct evkeyvalq *headers, const char *key); /** @@ -583,6 +880,7 @@ int evhttp_remove_header(struct evkeyvalq *headers, const char *key); @returns 0 on success, -1 otherwise. @see evhttp_find_header(), evhttp_clear_headers() */ +EVENT2_EXPORT_SYMBOL int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *value); /** @@ -590,6 +888,7 @@ int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *va @param headers the evkeyvalq object from which to remove all headers */ +EVENT2_EXPORT_SYMBOL void evhttp_clear_headers(struct evkeyvalq *headers); /* Miscellaneous utility functions */ @@ -606,6 +905,7 @@ void evhttp_clear_headers(struct evkeyvalq *headers); @param str an unencoded string @return a newly allocated URI-encoded string or NULL on failure */ +EVENT2_EXPORT_SYMBOL char *evhttp_encode_uri(const char *str); /** @@ -622,6 +922,7 @@ char *evhttp_encode_uri(const char *str); as +, not %20. @return a newly allocate URI-encoded string, or NULL on failure. */ +EVENT2_EXPORT_SYMBOL char *evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus); /** @@ -638,6 +939,7 @@ char *evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus); @param uri an encoded URI @return a newly allocated unencoded URI or NULL on failure */ +EVENT2_EXPORT_SYMBOL char *evhttp_decode_uri(const char *uri); /** @@ -650,11 +952,12 @@ char *evhttp_decode_uri(const char *uri); The returned string must be freed by the caller. @param uri a URI-encode encoded URI - @param decode_plus determines whether we convert '+' to sapce. + @param decode_plus determines whether we convert '+' to space. @param size_out if size_out is not NULL, *size_out is set to the size of the returned string @return a newly allocated unencoded URI or NULL on failure */ +EVENT2_EXPORT_SYMBOL char *evhttp_uridecode(const char *uri, int decode_plus, size_t *size_out); @@ -677,6 +980,7 @@ char *evhttp_uridecode(const char *uri, int decode_plus, @param headers the head of the evkeyval queue @return 0 on success, -1 on failure */ +EVENT2_EXPORT_SYMBOL int evhttp_parse_query(const char *uri, struct evkeyvalq *headers); /** @@ -696,6 +1000,7 @@ int evhttp_parse_query(const char *uri, struct evkeyvalq *headers); @param headers the head of the evkeyval queue @return 0 on success, -1 on failure */ +EVENT2_EXPORT_SYMBOL int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers); /** @@ -709,26 +1014,31 @@ int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers); * @param html an unescaped HTML string * @return an escaped HTML string or NULL on error */ +EVENT2_EXPORT_SYMBOL char *evhttp_htmlescape(const char *html); /** * Return a new empty evhttp_uri with no fields set. */ +EVENT2_EXPORT_SYMBOL struct evhttp_uri *evhttp_uri_new(void); /** * Changes the flags set on a given URI. See EVHTTP_URI_* for * a list of flags. **/ +EVENT2_EXPORT_SYMBOL void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags); /** Return the scheme of an evhttp_uri, or NULL if there is no scheme has * been set and the evhttp_uri contains a Relative-Ref. */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_scheme(const struct evhttp_uri *uri); /** * Return the userinfo part of an evhttp_uri, or NULL if it has no userinfo * set. */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_userinfo(const struct evhttp_uri *uri); /** * Return the host part of an evhttp_uri, or NULL if it has no host set. @@ -742,40 +1052,52 @@ const char *evhttp_uri_get_userinfo(const struct evhttp_uri *uri); * "mailto:user@example.com" has a host of NULL, but "file:///etc/motd" * has a host of "". */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_host(const struct evhttp_uri *uri); /** Return the port part of an evhttp_uri, or -1 if there is no port set. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_get_port(const struct evhttp_uri *uri); /** Return the path part of an evhttp_uri, or NULL if it has no path set */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_path(const struct evhttp_uri *uri); /** Return the query part of an evhttp_uri (excluding the leading "?"), or * NULL if it has no query set */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_query(const struct evhttp_uri *uri); /** Return the fragment part of an evhttp_uri (excluding the leading "#"), * or NULL if it has no fragment set */ +EVENT2_EXPORT_SYMBOL const char *evhttp_uri_get_fragment(const struct evhttp_uri *uri); /** Set the scheme of an evhttp_uri, or clear the scheme if scheme==NULL. * Returns 0 on success, -1 if scheme is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme); /** Set the userinfo of an evhttp_uri, or clear the userinfo if userinfo==NULL. * Returns 0 on success, -1 if userinfo is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo); /** Set the host of an evhttp_uri, or clear the host if host==NULL. * Returns 0 on success, -1 if host is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_host(struct evhttp_uri *uri, const char *host); /** Set the port of an evhttp_uri, or clear the port if port==-1. * Returns 0 on success, -1 if port is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_port(struct evhttp_uri *uri, int port); /** Set the path of an evhttp_uri, or clear the path if path==NULL. * Returns 0 on success, -1 if path is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_path(struct evhttp_uri *uri, const char *path); /** Set the query of an evhttp_uri, or clear the query if query==NULL. * The query should not include a leading "?". * Returns 0 on success, -1 if query is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_query(struct evhttp_uri *uri, const char *query); /** Set the fragment of an evhttp_uri, or clear the fragment if fragment==NULL. * The fragment should not include a leading "#". * Returns 0 on success, -1 if fragment is not well-formed. */ +EVENT2_EXPORT_SYMBOL int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment); /** @@ -812,6 +1134,7 @@ int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment); * @return uri container to hold parsed data, or NULL if there is error * @see evhttp_uri_free() */ +EVENT2_EXPORT_SYMBOL struct evhttp_uri *evhttp_uri_parse_with_flags(const char *source_uri, unsigned flags); @@ -830,6 +1153,7 @@ struct evhttp_uri *evhttp_uri_parse_with_flags(const char *source_uri, #define EVHTTP_URI_NONCONFORMANT 0x01 /** Alias for evhttp_uri_parse_with_flags(source_uri, 0) */ +EVENT2_EXPORT_SYMBOL struct evhttp_uri *evhttp_uri_parse(const char *source_uri); /** @@ -839,6 +1163,7 @@ struct evhttp_uri *evhttp_uri_parse(const char *source_uri); * @param uri container with parsed data * @see evhttp_uri_parse() */ +EVENT2_EXPORT_SYMBOL void evhttp_uri_free(struct evhttp_uri *uri); /** @@ -854,10 +1179,11 @@ void evhttp_uri_free(struct evhttp_uri *uri); * @return an joined uri as string or NULL on error * @see evhttp_uri_parse() */ +EVENT2_EXPORT_SYMBOL char *evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit); #ifdef __cplusplus } #endif -#endif /* _EVENT2_HTTP_H_ */ +#endif /* EVENT2_HTTP_H_INCLUDED_ */ diff --git a/include/event2/http_compat.h b/include/event2/http_compat.h index 9e902a4..43c2c43 100644 --- a/include/event2/http_compat.h +++ b/include/event2/http_compat.h @@ -24,8 +24,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_HTTP_COMPAT_H_ -#define _EVENT2_HTTP_COMPAT_H_ +#ifndef EVENT2_HTTP_COMPAT_H_INCLUDED_ +#define EVENT2_HTTP_COMPAT_H_INCLUDED_ /** @file event2/http_compat.h @@ -39,10 +39,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -58,7 +58,7 @@ extern "C" { * @param port the port number on which the HTTP server should listen * @return an struct evhttp object */ -struct evhttp *evhttp_start(const char *address, unsigned short port); +struct evhttp *evhttp_start(const char *address, ev_uint16_t port); /** * A connection object that can be used to for making HTTP requests. The @@ -68,7 +68,7 @@ struct evhttp *evhttp_start(const char *address, unsigned short port); * @deprecated It does not allow an event base to be specified */ struct evhttp_connection *evhttp_connection_new( - const char *address, unsigned short port); + const char *address, ev_uint16_t port); /** * Associates an event base with the connection - can only be called @@ -87,4 +87,4 @@ void evhttp_connection_set_base(struct evhttp_connection *evcon, } #endif -#endif /* _EVENT2_EVENT_COMPAT_H_ */ +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/include/event2/http_struct.h b/include/event2/http_struct.h index 41a92a9..4bf5b1f 100644 --- a/include/event2/http_struct.h +++ b/include/event2/http_struct.h @@ -24,8 +24,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_HTTP_STRUCT_H_ -#define _EVENT2_HTTP_STRUCT_H_ +#ifndef EVENT2_HTTP_STRUCT_H_INCLUDED_ +#define EVENT2_HTTP_STRUCT_H_INCLUDED_ /** @file event2/http_struct.h @@ -39,10 +39,10 @@ extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -120,11 +120,33 @@ struct { * the regular callback. */ void (*chunk_cb)(struct evhttp_request *, void *); + + /* + * Callback added for forked-daapd so they can collect ICY + * (shoutcast) metadata from the http header. If return + * int is negative the connection will be closed. + */ + int (*header_cb)(struct evhttp_request *, void *); + + /* + * Error callback - called when error is occured. + * @see evhttp_request_error for error types. + * + * @see evhttp_request_set_error_cb() + */ + void (*error_cb)(enum evhttp_request_error, void *); + + /* + * Send complete callback - called when the request is actually + * sent and completed. + */ + void (*on_complete_cb)(struct evhttp_request *, void *); + void *on_complete_cb_arg; }; #ifdef __cplusplus } #endif -#endif /* _EVENT2_HTTP_STRUCT_H_ */ +#endif /* EVENT2_HTTP_STRUCT_H_INCLUDED_ */ diff --git a/include/event2/keyvalq_struct.h b/include/event2/keyvalq_struct.h index ab8040b..bffa54b 100644 --- a/include/event2/keyvalq_struct.h +++ b/include/event2/keyvalq_struct.h @@ -24,8 +24,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_EVENT_KEYVALQ_STRUCT_H_ -#define _EVENT2_EVENT_KEYVALQ_STRUCT_H_ +#ifndef EVENT2_KEYVALQ_STRUCT_H_INCLUDED_ +#define EVENT2_KEYVALQ_STRUCT_H_INCLUDED_ #ifdef __cplusplus extern "C" { @@ -34,7 +34,7 @@ extern "C" { /* Fix so that people don't have to run with <sys/queue.h> */ /* XXXX This code is duplicated with event_struct.h */ #ifndef TAILQ_ENTRY -#define _EVENT_DEFINED_TQENTRY +#define EVENT_DEFINED_TQENTRY_ #define TAILQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ @@ -43,7 +43,7 @@ struct { \ #endif /* !TAILQ_ENTRY */ #ifndef TAILQ_HEAD -#define _EVENT_DEFINED_TQHEAD +#define EVENT_DEFINED_TQHEAD_ #define TAILQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; \ @@ -65,11 +65,11 @@ struct evkeyval { TAILQ_HEAD (evkeyvalq, evkeyval); /* XXXX This code is duplicated with event_struct.h */ -#ifdef _EVENT_DEFINED_TQENTRY +#ifdef EVENT_DEFINED_TQENTRY_ #undef TAILQ_ENTRY #endif -#ifdef _EVENT_DEFINED_TQHEAD +#ifdef EVENT_DEFINED_TQHEAD_ #undef TAILQ_HEAD #endif diff --git a/include/event2/listener.h b/include/event2/listener.h index 2dc64be..84b4da0 100644 --- a/include/event2/listener.h +++ b/include/event2/listener.h @@ -24,8 +24,10 @@ * (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_LISTENER_H_ -#define _EVENT2_LISTENER_H_ +#ifndef EVENT2_LISTENER_H_INCLUDED_ +#define EVENT2_LISTENER_H_INCLUDED_ + +#include <event2/visibility.h> #ifdef __cplusplus extern "C" { @@ -69,6 +71,32 @@ typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *); /** Flag: Indicates that the listener should be locked so it's safe to use * from multiple threadcs at once. */ #define LEV_OPT_THREADSAFE (1u<<4) +/** Flag: Indicates that the listener should be created in disabled + * state. Use evconnlistener_enable() to enable it later. */ +#define LEV_OPT_DISABLED (1u<<5) +/** Flag: Indicates that the listener should defer accept() until data is + * available, if possible. Ignored on platforms that do not support this. + * + * This option can help performance for protocols where the client transmits + * immediately after connecting. Do not use this option if your protocol + * _doesn't_ start out with the client transmitting data, since in that case + * this option will sometimes cause the kernel to never tell you about the + * connection. + * + * This option is only supported by evconnlistener_new_bind(): it can't + * work with evconnlistener_new_fd(), since the listener needs to be told + * to use the option before it is actually bound. + */ +#define LEV_OPT_DEFERRED_ACCEPT (1u<<6) +/** Flag: Indicates that we ask to allow multiple servers (processes or + * threads) to bind to the same port if they each set the option. + * + * SO_REUSEPORT is what most people would expect SO_REUSEADDR to be, however + * SO_REUSEPORT does not imply SO_REUSEADDR. + * + * This is only available on Linux and kernel 3.9+ + */ +#define LEV_OPT_REUSEABLE_PORT (1u<<7) /** Allocate a new evconnlistener object to listen for incoming TCP connections @@ -87,6 +115,7 @@ typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *); file descriptor, and it should already be bound to an appropriate port and address. */ +EVENT2_EXPORT_SYMBOL struct evconnlistener *evconnlistener_new(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, evutil_socket_t fd); @@ -105,34 +134,42 @@ struct evconnlistener *evconnlistener_new(struct event_base *base, @param addr The address to listen for connections on. @param socklen The length of the address. */ +EVENT2_EXPORT_SYMBOL struct evconnlistener *evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, const struct sockaddr *sa, int socklen); /** Disable and deallocate an evconnlistener. */ +EVENT2_EXPORT_SYMBOL void evconnlistener_free(struct evconnlistener *lev); /** Re-enable an evconnlistener that has been disabled. */ +EVENT2_EXPORT_SYMBOL int evconnlistener_enable(struct evconnlistener *lev); /** Stop listening for connections on an evconnlistener. */ +EVENT2_EXPORT_SYMBOL int evconnlistener_disable(struct evconnlistener *lev); /** Return an evconnlistener's associated event_base. */ +EVENT2_EXPORT_SYMBOL struct event_base *evconnlistener_get_base(struct evconnlistener *lev); /** Return the socket that an evconnlistner is listening on. */ +EVENT2_EXPORT_SYMBOL evutil_socket_t evconnlistener_get_fd(struct evconnlistener *lev); /** Change the callback on the listener to cb and its user_data to arg. */ +EVENT2_EXPORT_SYMBOL void evconnlistener_set_cb(struct evconnlistener *lev, evconnlistener_cb cb, void *arg); /** Set an evconnlistener's error callback. */ +EVENT2_EXPORT_SYMBOL void evconnlistener_set_error_cb(struct evconnlistener *lev, evconnlistener_errorcb errorcb); diff --git a/include/event2/rpc.h b/include/event2/rpc.h index 5272edc..dd43df2 100644 --- a/include/event2/rpc.h +++ b/include/event2/rpc.h @@ -24,8 +24,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_RPC_H_ -#define _EVENT2_RPC_H_ +#ifndef EVENT2_RPC_H_INCLUDED_ +#define EVENT2_RPC_H_INCLUDED_ #ifdef __cplusplus extern "C" { @@ -76,7 +76,7 @@ extern "C" { #define EVTAG_HAS(msg, member) \ ((msg)->member##_set == 1) -#ifndef _EVENT2_RPC_COMPAT_H_ +#ifndef EVENT2_RPC_COMPAT_H_INCLUDED_ /** Assigns a value to the member in the message. @@ -119,7 +119,7 @@ extern "C" { #define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \ (*(msg)->base->member##_get)((msg), (pvalue), (plen)) -#endif /* _EVENT2_RPC_COMPAT_H_ */ +#endif /* EVENT2_RPC_COMPAT_H_INCLUDED_ */ /** Adds a value to an array. @@ -272,8 +272,8 @@ void *evrpc_get_reply(struct evrpc_req_generic *req); * @param rpc_req the rpc request structure provided to the server callback */ #define EVRPC_REQUEST_DONE(rpc_req) do { \ - struct evrpc_req_generic *_req = (struct evrpc_req_generic *)(rpc_req); \ - evrpc_request_done(_req); \ + struct evrpc_req_generic *req_ = (struct evrpc_req_generic *)(rpc_req); \ + evrpc_request_done(req_); \ } while (0) @@ -454,7 +454,7 @@ enum EVRPC_HOOK_TYPE { EVRPC_OUTPUT /**< apply the function to an output hook */ }; -#ifndef WIN32 +#ifndef _WIN32 /** Deprecated alias for EVRPC_INPUT. Not available on windows, where it * conflicts with platform headers. */ #define INPUT EVRPC_INPUT @@ -593,4 +593,4 @@ void evrpc_request_set_cb(struct evrpc_request_wrapper *ctx, } #endif -#endif /* _EVENT2_RPC_H_ */ +#endif /* EVENT2_RPC_H_INCLUDED_ */ diff --git a/include/event2/rpc_compat.h b/include/event2/rpc_compat.h index a4e24bb..8d8334d 100644 --- a/include/event2/rpc_compat.h +++ b/include/event2/rpc_compat.h @@ -24,8 +24,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_RPC_COMPAT_H_ -#define _EVENT2_RPC_COMPAT_H_ +#ifndef EVENT2_RPC_COMPAT_H_INCLUDED_ +#define EVENT2_RPC_COMPAT_H_INCLUDED_ /** @file event2/rpc_compat.h @@ -58,4 +58,4 @@ extern "C" { } #endif -#endif /* _EVENT2_EVENT_COMPAT_H_ */ +#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */ diff --git a/include/event2/rpc_struct.h b/include/event2/rpc_struct.h index c339ae5..8f691f4 100644 --- a/include/event2/rpc_struct.h +++ b/include/event2/rpc_struct.h @@ -24,8 +24,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_RPC_STRUCT_H_ -#define _EVENT2_RPC_STRUCT_H_ +#ifndef EVENT2_RPC_STRUCT_H_INCLUDED_ +#define EVENT2_RPC_STRUCT_H_INCLUDED_ #ifdef __cplusplus extern "C" { @@ -97,4 +97,4 @@ struct evrpc { } #endif -#endif /* _EVENT2_RPC_STRUCT_H_ */ +#endif /* EVENT2_RPC_STRUCT_H_INCLUDED_ */ diff --git a/include/event2/tag.h b/include/event2/tag.h index 9e51779..2f73bfc 100644 --- a/include/event2/tag.h +++ b/include/event2/tag.h @@ -24,8 +24,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_TAG_H_ -#define _EVENT2_TAG_H_ +#ifndef EVENT2_TAG_H_INCLUDED_ +#define EVENT2_TAG_H_INCLUDED_ /** @file event2/tag.h @@ -33,15 +33,17 @@ */ +#include <event2/visibility.h> + #ifdef __cplusplus extern "C" { #endif #include <event2/event-config.h> -#ifdef _EVENT_HAVE_SYS_TYPES_H +#ifdef EVENT__HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifdef _EVENT_HAVE_SYS_TIME_H +#ifdef EVENT__HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -56,6 +58,7 @@ struct evbuffer; * known ones - and we can just ignore the end of an event buffer. */ +EVENT2_EXPORT_SYMBOL void evtag_init(void); /** @@ -65,10 +68,13 @@ void evtag_init(void); @param ptag a pointer in which the tag id is being stored @returns -1 on failure or the number of bytes in the remaining payload. */ +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_header(struct evbuffer *evbuf, ev_uint32_t *ptag); +EVENT2_EXPORT_SYMBOL void evtag_marshal(struct evbuffer *evbuf, ev_uint32_t tag, const void *data, ev_uint32_t len); +EVENT2_EXPORT_SYMBOL void evtag_marshal_buffer(struct evbuffer *evbuf, ev_uint32_t tag, struct evbuffer *data); @@ -82,38 +88,54 @@ void evtag_marshal_buffer(struct evbuffer *evbuf, ev_uint32_t tag, @param evbuf evbuffer to store the encoded number @param number a 32-bit integer */ +EVENT2_EXPORT_SYMBOL void evtag_encode_int(struct evbuffer *evbuf, ev_uint32_t number); +EVENT2_EXPORT_SYMBOL void evtag_encode_int64(struct evbuffer *evbuf, ev_uint64_t number); +EVENT2_EXPORT_SYMBOL void evtag_marshal_int(struct evbuffer *evbuf, ev_uint32_t tag, ev_uint32_t integer); +EVENT2_EXPORT_SYMBOL void evtag_marshal_int64(struct evbuffer *evbuf, ev_uint32_t tag, ev_uint64_t integer); +EVENT2_EXPORT_SYMBOL void evtag_marshal_string(struct evbuffer *buf, ev_uint32_t tag, const char *string); +EVENT2_EXPORT_SYMBOL void evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint32_t tag, struct timeval *tv); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal(struct evbuffer *src, ev_uint32_t *ptag, struct evbuffer *dst); +EVENT2_EXPORT_SYMBOL int evtag_peek(struct evbuffer *evbuf, ev_uint32_t *ptag); +EVENT2_EXPORT_SYMBOL int evtag_peek_length(struct evbuffer *evbuf, ev_uint32_t *plength); +EVENT2_EXPORT_SYMBOL int evtag_payload_length(struct evbuffer *evbuf, ev_uint32_t *plength); +EVENT2_EXPORT_SYMBOL int evtag_consume(struct evbuffer *evbuf); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint32_t need_tag, ev_uint32_t *pinteger); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_int64(struct evbuffer *evbuf, ev_uint32_t need_tag, ev_uint64_t *pinteger); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_fixed(struct evbuffer *src, ev_uint32_t need_tag, void *data, size_t len); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_string(struct evbuffer *evbuf, ev_uint32_t need_tag, char **pstring); +EVENT2_EXPORT_SYMBOL int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint32_t need_tag, struct timeval *ptv); @@ -121,4 +143,4 @@ int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint32_t need_tag, } #endif -#endif /* _EVENT2_TAG_H_ */ +#endif /* EVENT2_TAG_H_INCLUDED_ */ diff --git a/include/event2/tag_compat.h b/include/event2/tag_compat.h index 73c1933..a276c0d 100644 --- a/include/event2/tag_compat.h +++ b/include/event2/tag_compat.h @@ -24,8 +24,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_TAG_COMPAT_H_ -#define _EVENT2_TAG_COMPAT_H_ +#ifndef EVENT2_TAG_COMPAT_H_INCLUDED_ +#define EVENT2_TAG_COMPAT_H_INCLUDED_ /** @file event2/tag_compat.h @@ -46,4 +46,4 @@ #define encode_int64(evbuf, number) evtag_encode_int64((evbuf), (number)) /**@}*/ -#endif /* _EVENT2_TAG_H_ */ +#endif /* EVENT2_TAG_H_INCLUDED_ */ diff --git a/include/event2/thread.h b/include/event2/thread.h index 0b638f0..b519986 100644 --- a/include/event2/thread.h +++ b/include/event2/thread.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_THREAD_H_ -#define _EVENT2_THREAD_H_ +#ifndef EVENT2_THREAD_H_INCLUDED_ +#define EVENT2_THREAD_H_INCLUDED_ /** @file event2/thread.h @@ -46,6 +46,8 @@ */ +#include <event2/visibility.h> + #ifdef __cplusplus extern "C" { #endif @@ -69,7 +71,7 @@ extern "C" { #define EVTHREAD_TRY 0x10 /**@}*/ -#if !defined(_EVENT_DISABLE_THREAD_SUPPORT) || defined(_EVENT_IN_DOXYGEN) +#if !defined(EVENT__DISABLE_THREAD_SUPPORT) || defined(EVENT_IN_DOXYGEN_) #define EVTHREAD_LOCK_API_VERSION 1 @@ -124,6 +126,7 @@ struct evthread_lock_callbacks { * probably shouldn't call this function; instead, use * evthread_use_windows_threads() or evthread_use_posix_threads() if you can. */ +EVENT2_EXPORT_SYMBOL int evthread_set_lock_callbacks(const struct evthread_lock_callbacks *); #define EVTHREAD_CONDITION_API_VERSION 1 @@ -174,6 +177,7 @@ struct evthread_condition_callbacks { * probably shouldn't call this function; instead, use * evthread_use_windows_threads() or evthread_use_pthreads() if you can. */ +EVENT2_EXPORT_SYMBOL int evthread_set_condition_callbacks( const struct evthread_condition_callbacks *); @@ -184,14 +188,16 @@ int evthread_set_condition_callbacks( @param id_fn the identify function Libevent should invoke to determine the identity of a thread. */ +EVENT2_EXPORT_SYMBOL void evthread_set_id_callback( unsigned long (*id_fn)(void)); -#if (defined(WIN32) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)) || defined(_EVENT_IN_DOXYGEN) +#if (defined(_WIN32) && !defined(EVENT__DISABLE_THREAD_SUPPORT)) || defined(EVENT_IN_DOXYGEN_) /** Sets up Libevent for use with Windows builtin locking and thread ID functions. Unavailable if Libevent is not built for Windows. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evthread_use_windows_threads(void); /** Defined if Libevent was built with support for evthread_use_windows_threads() @@ -199,12 +205,13 @@ int evthread_use_windows_threads(void); #define EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 1 #endif -#if defined(_EVENT_HAVE_PTHREADS) || defined(_EVENT_IN_DOXYGEN) +#if defined(EVENT__HAVE_PTHREADS) || defined(EVENT_IN_DOXYGEN_) /** Sets up Libevent for use with Pthreads locking and thread ID functions. Unavailable if Libevent is not build for use with pthreads. Requires libraries to link against Libevent_pthreads as well as Libevent. @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evthread_use_pthreads(void); /** Defined if Libevent was built with support for evthread_use_pthreads() */ #define EVTHREAD_USE_PTHREADS_IMPLEMENTED 1 @@ -217,20 +224,30 @@ int evthread_use_pthreads(void); * If you're going to call this function, you must do so before any locks are * allocated. **/ +EVENT2_EXPORT_SYMBOL +void evthread_enable_lock_debugging(void); + +/* Old (misspelled) version: This is deprecated; use + * evthread_enable_log_debugging instead. */ +EVENT2_EXPORT_SYMBOL void evthread_enable_lock_debuging(void); -#endif /* _EVENT_DISABLE_THREAD_SUPPORT */ +#endif /* EVENT__DISABLE_THREAD_SUPPORT */ struct event_base; /** Make sure it's safe to tell an event base to wake up from another thread or a signal handler. + You shouldn't need to call this by hand; configuring the base with thread + support should be necessary and sufficient. + @return 0 on success, -1 on failure. */ +EVENT2_EXPORT_SYMBOL int evthread_make_base_notifiable(struct event_base *base); #ifdef __cplusplus } #endif -#endif /* _EVENT2_THREAD_H_ */ +#endif /* EVENT2_THREAD_H_INCLUDED_ */ diff --git a/include/event2/util.h b/include/event2/util.h index dde9113..dd4bbb6 100644 --- a/include/event2/util.h +++ b/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_ -#define _EVENT2_UTIL_H_ +#ifndef EVENT2_UTIL_H_INCLUDED_ +#define EVENT2_UTIL_H_INCLUDED_ /** @file event2/util.h @@ -32,46 +32,56 @@ related socket manipulations. */ +#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 #if !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif #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 #include <sys/socket.h> #endif +#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 /** @@ -103,67 +113,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 @@ -171,30 +181,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 -#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 ... #else #define ev_off_t off_t #endif @@ -215,6 +238,7 @@ extern "C" { @{ */ +#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) @@ -227,20 +251,34 @@ 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_MAX INT16_MAX +#define EV_UINT8_MAX UINT8_MAX +#define EV_INT8_MAX INT8_MAX +#define EV_INT8_MIN INT8_MIN /** @} */ +#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 @@ -250,16 +288,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 @@ -268,12 +306,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); + /** Create two new sockets that are connected to each other. On Unix, this simply calls socketpair(). On Windows, it uses the @@ -285,12 +388,14 @@ extern "C" { Parameters and return values are as for socketpair() */ +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 int evutil_make_socket_nonblocking(evutil_socket_t sock); /** Do platform-specific operations to make a listener socket reusable. @@ -304,14 +409,29 @@ 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 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); + /** 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 int evutil_make_socket_closeonexec(evutil_socket_t sock); /** Do the platform-specific call needed to close a socket returned from @@ -320,21 +440,37 @@ int evutil_make_socket_closeonexec(evutil_socket_t sock); @param sock The socket to be closed @return 0 on success, -1 on failure */ +EVENT2_EXPORT_SYMBOL int evutil_closesocket(evutil_socket_t sock); #define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s) - -#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 int evutil_socket_geterror(evutil_socket_t sock); /** Convert a socket error to a string. */ +EVENT2_EXPORT_SYMBOL const char *evutil_socket_error_to_string(int errcode); -#elif defined(_EVENT_IN_DOXYGEN) +#elif defined(EVENT_IN_DOXYGEN_) /** @name Socket error functions @@ -375,7 +511,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 @@ -397,9 +533,9 @@ const char *evutil_socket_error_to_string(int errcode); (vvp)->tv_usec += 1000000; \ } \ } while (0) -#endif /* !_EVENT_HAVE_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 @@ -413,7 +549,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) @@ -428,19 +564,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 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 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 int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) #ifdef __GNUC__ __attribute__((format(printf, 3, 4))) @@ -449,6 +588,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 int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) #ifdef __GNUC__ __attribute__((format(printf, 3, 0))) @@ -456,8 +596,10 @@ 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 const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len); /** Replacement for inet_pton for platforms which lack it. */ +EVENT2_EXPORT_SYMBOL int evutil_inet_pton(int af, const char *src, void *dst); struct sockaddr; @@ -481,6 +623,7 @@ struct sockaddr; or if out is not large enough to hold the result. Otherwise returns 0 on success. */ +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 @@ -488,21 +631,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 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 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 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. @@ -528,32 +674,32 @@ struct evutil_addrinfo { @{ */ -#ifdef EAI_ADDRFAMILY +#if defined(EAI_ADDRFAMILY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_ADDRFAMILY EAI_ADDRFAMILY #else #define EVUTIL_EAI_ADDRFAMILY -901 #endif -#ifdef EAI_AGAIN +#if defined(EAI_AGAIN) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_AGAIN EAI_AGAIN #else #define EVUTIL_EAI_AGAIN -902 #endif -#ifdef EAI_BADFLAGS +#if defined(EAI_BADFLAGS) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_BADFLAGS EAI_BADFLAGS #else #define EVUTIL_EAI_BADFLAGS -903 #endif -#ifdef EAI_FAIL +#if defined(EAI_FAIL) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_FAIL EAI_FAIL #else #define EVUTIL_EAI_FAIL -904 #endif -#ifdef EAI_FAMILY +#if defined(EAI_FAMILY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_FAMILY EAI_FAMILY #else #define EVUTIL_EAI_FAMILY -905 #endif -#ifdef EAI_MEMORY +#if defined(EAI_MEMORY) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_MEMORY EAI_MEMORY #else #define EVUTIL_EAI_MEMORY -906 @@ -561,27 +707,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(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 -#ifdef EAI_NONAME +#if defined(EAI_NONAME) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_NONAME EAI_NONAME #else #define EVUTIL_EAI_NONAME -908 #endif -#ifdef EAI_SERVICE +#if defined(EAI_SERVICE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SERVICE EAI_SERVICE #else #define EVUTIL_EAI_SERVICE -909 #endif -#ifdef EAI_SOCKTYPE +#if defined(EAI_SOCKTYPE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SOCKTYPE EAI_SOCKTYPE #else #define EVUTIL_EAI_SOCKTYPE -910 #endif -#ifdef EAI_SYSTEM +#if defined(EAI_SYSTEM) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_EAI_SYSTEM EAI_SYSTEM #else #define EVUTIL_EAI_SYSTEM -911 @@ -589,37 +735,37 @@ struct evutil_addrinfo { #define EVUTIL_EAI_CANCEL -90001 -#ifdef AI_PASSIVE +#if defined(AI_PASSIVE) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_PASSIVE AI_PASSIVE #else #define EVUTIL_AI_PASSIVE 0x1000 #endif -#ifdef AI_CANONNAME +#if defined(AI_CANONNAME) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_CANONNAME AI_CANONNAME #else #define EVUTIL_AI_CANONNAME 0x2000 #endif -#ifdef AI_NUMERICHOST +#if defined(AI_NUMERICHOST) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_NUMERICHOST AI_NUMERICHOST #else #define EVUTIL_AI_NUMERICHOST 0x4000 #endif -#ifdef AI_NUMERICSERV +#if defined(AI_NUMERICSERV) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_NUMERICSERV AI_NUMERICSERV #else #define EVUTIL_AI_NUMERICSERV 0x8000 #endif -#ifdef AI_V4MAPPED +#if defined(AI_V4MAPPED) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_V4MAPPED AI_V4MAPPED #else #define EVUTIL_AI_V4MAPPED 0x10000 #endif -#ifdef AI_ALL +#if defined(AI_ALL) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_ALL AI_ALL #else #define EVUTIL_AI_ALL 0x20000 #endif -#ifdef AI_ADDRCONFIG +#if defined(AI_ADDRCONFIG) && defined(EVENT__HAVE_GETADDRINFO) #define EVUTIL_AI_ADDRCONFIG AI_ADDRCONFIG #else #define EVUTIL_AI_ADDRCONFIG 0x40000 @@ -638,12 +784,15 @@ struct evutil_addrinfo; * * For a nonblocking variant, see evdns_getaddrinfo. */ +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 void evutil_freeaddrinfo(struct evutil_addrinfo *ai); +EVENT2_EXPORT_SYMBOL const char *evutil_gai_strerror(int err); /** Generate n bytes of secure pseudorandom data, and store them in buf. @@ -655,6 +804,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 void evutil_secure_rng_get_bytes(void *buf, size_t n); /** @@ -673,6 +823,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 int evutil_secure_rng_init(void); /** @@ -688,6 +839,7 @@ int evutil_secure_rng_init(void); * * This API is unstable, and might change in a future libevent version. */ +EVENT2_EXPORT_SYMBOL int evutil_secure_rng_set_urandom_device_file(char *fname); /** Seed the random number generator with extra random bytes. @@ -704,10 +856,11 @@ 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 void evutil_secure_rng_add_bytes(const char *dat, size_t datlen); #ifdef __cplusplus } #endif -#endif /* _EVUTIL_H_ */ +#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ diff --git a/include/event2/visibility.h b/include/event2/visibility.h new file mode 100644 index 0000000..fb16dbe --- /dev/null +++ b/include/event2/visibility.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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_VISIBILITY_H_INCLUDED_ +#define EVENT2_VISIBILITY_H_INCLUDED_ + +#include <event2/event-config.h> + +#if defined(event_EXPORTS) || defined(event_extra_EXPORTS) || defined(event_core_EXPORTS) +# if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) +# define EVENT2_EXPORT_SYMBOL __global +# elif defined __GNUC__ +# define EVENT2_EXPORT_SYMBOL __attribute__ ((visibility("default"))) +# elif defined(_MSC_VER) +# define EVENT2_EXPORT_SYMBOL extern __declspec(dllexport) +# else +# define EVENT2_EXPORT_SYMBOL /* unknown compiler */ +# endif +#else +# if defined(EVENT__NEED_DLLIMPORT) && defined(_MSC_VER) && !defined(EVENT_BUILDING_REGRESS_TEST) +# define EVENT2_EXPORT_SYMBOL extern __declspec(dllimport) +# else +# define EVENT2_EXPORT_SYMBOL +# endif +#endif + +#endif /* EVENT2_VISIBILITY_H_INCLUDED_ */ diff --git a/include/evhttp.h b/include/evhttp.h new file mode 100644 index 0000000..549bc9b --- /dev/null +++ b/include/evhttp.h @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2007 Niels Provos <provos@citi.umich.edu> + * Copyright 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 EVENT1_EVHTTP_H_INCLUDED_ +#define EVENT1_EVHTTP_H_INCLUDED_ + +/** @file evhttp.h + + An http implementation subsystem for Libevent. + + The <evhttp.h> header is deprecated in Libevent 2.0 and later; please + use <event2/http.h> instead. Depending on what functionality you + need, you may also want to include more of the other <event2/...> + headers. + */ + +#include <event.h> +#include <event2/http.h> +#include <event2/http_struct.h> +#include <event2/http_compat.h> + +#endif /* EVENT1_EVHTTP_H_INCLUDED_ */ diff --git a/include/evrpc.h b/include/evrpc.h new file mode 100644 index 0000000..7e986f7 --- /dev/null +++ b/include/evrpc.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 EVENT1_EVRPC_H_INCLUDED_ +#define EVENT1_EVRPC_H_INCLUDED_ + +/** @file evrpc.h + + An RPC system for Libevent. + + The <evrpc.h> header is deprecated in Libevent 2.0 and later; please + use <event2/rpc.h> instead. Depending on what functionality you + need, you may also want to include more of the other <event2/...> + headers. + */ + +#include <event.h> +#include <event2/rpc.h> +#include <event2/rpc_struct.h> +#include <event2/rpc_compat.h> + +#endif /* EVENT1_EVRPC_H_INCLUDED_ */ diff --git a/include/evutil.h b/include/evutil.h new file mode 100644 index 0000000..12c137d --- /dev/null +++ b/include/evutil.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 EVENT1_EVUTIL_H_INCLUDED_ +#define EVENT1_EVUTIL_H_INCLUDED_ + +/** @file evutil.h + + Utility and compatibility functions for Libevent. + + The <evutil.h> header is deprecated in Libevent 2.0 and later; please + use <event2/util.h> instead. +*/ + +#include <event2/util.h> + +#endif /* EVENT1_EVUTIL_H_INCLUDED_ */ diff --git a/include/include.am b/include/include.am new file mode 100644 index 0000000..9aad2db --- /dev/null +++ b/include/include.am @@ -0,0 +1,46 @@ +# include/Makefile.am for libevent +# Copyright 2000-2007 Niels Provos +# Copyright 2007-2012 Niels Provos and Nick Mathewson +# +# See LICENSE for copying information. + +include_event2dir = $(includedir)/event2 + +EVENT2_EXPORT = \ + include/event2/buffer.h \ + include/event2/buffer_compat.h \ + include/event2/bufferevent.h \ + include/event2/bufferevent_compat.h \ + include/event2/bufferevent_ssl.h \ + include/event2/bufferevent_struct.h \ + include/event2/dns.h \ + include/event2/dns_compat.h \ + include/event2/dns_struct.h \ + include/event2/event.h \ + include/event2/event_compat.h \ + include/event2/event_struct.h \ + include/event2/http.h \ + include/event2/http_compat.h \ + include/event2/http_struct.h \ + include/event2/keyvalq_struct.h \ + include/event2/listener.h \ + include/event2/rpc.h \ + include/event2/rpc_compat.h \ + include/event2/rpc_struct.h \ + include/event2/tag.h \ + include/event2/tag_compat.h \ + include/event2/thread.h \ + include/event2/util.h \ + include/event2/visibility.h + +## Without the nobase_ prefixing, Automake would strip "include/event2/" from +## the source header filename to derive the installed header filename. +## With nobase_ the installed path is $(includedir)/include/event2/ev*.h. + +if INSTALL_LIBEVENT +include_event2_HEADERS = $(EVENT2_EXPORT) +nodist_include_event2_HEADERS = include/event2/event-config.h +else +noinst_HEADERS += $(EVENT2_EXPORT) +nodist_noinst_HEADERS = include/event2/event-config.h +endif |