commit - 4b435a4c4739dd67d3bc01e6b106969aaec431fe
commit + 1470eab31452d2fab50bc4965320dab7892b2ef3
blob - 8b206a283d35811665b2746568819d0e900f694a
blob + fe3986726839aa4acc7348a550215fc3d21423d5
--- compat.h
+++ compat.h
#include <stddef.h>
#include <stdint.h>
+#if HAVE_EVENT2
+# include <event2/event.h>
+# include <event2/event_compat.h>
+# include <event2/event_struct.h>
+# include <event2/buffer.h>
+# include <event2/buffer_compat.h>
+# include <event2/bufferevent.h>
+# include <event2/bufferevent_struct.h>
+# include <event2/bufferevent_compat.h>
+#else
+# include <event.h>
+# define evbuffer_freeze(a, b) /* nop */
+# define evbuffer_unfreeze(a, b) /* nop */
+#endif
+
#ifdef HAVE_QUEUE_H
# include <sys/queue.h>
#else
blob - 1ce2e137610fed82acd579fb91d15a1d9c59c0a9
blob + 2f11d8c301b3c0d0919551f3c356150037cef3ef
--- configure.ac
+++ configure.ac
AC_INIT([telescope], [0.4.1-dev], [telescope@omarpolo.com], [telescope], [gemini://telescope.omarpolo.com])
AC_CONFIG_LIBOBJ_DIR(compat)
+AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_PROG_CC_C99
AC_USE_SYSTEM_EXTENSIONS
AC_MSG_ERROR([requires libtls])
])
-AC_CHECK_LIB(event, event_init, [], [
- AC_MSG_ERROR([requires libevent])
-])
+case "$host_os" in
+ *openbsd*)
+ AC_CHECK_LIB([event], [event_init], [],
+ [AC_MSG_ERROR([requires libevent])])
+ ;;
+ *)
+ PKG_CHECK_MODULES([libevent2], [libevent_core >= 2], [
+ AC_DEFINE([HAVE_EVENT2], 1, [1 if using event2])
+ CFLAGS="$libevent2_CFLAGS $CFLAGS"
+ LIBS="$libevent2_LIBS $LIBS"
+ ], [AC_MSG_ERROR([requires libevent])])
+ ;;
+esac
AC_CHECK_LIB(util, imsg_init, [], [
AC_LIBOBJ(imsg)
blob - 3ecdbf56350b04d3746fe0bc220158cda280467e
blob + b75f88940adb4ad75a48fe23dcfda700b9cb517c
--- net.c
+++ net.c
char buf[IBUF_READ_SIZE];
int what = EVBUFFER_READ;
int howmuch = IBUF_READ_SIZE;
+ int res;
ssize_t ret;
size_t len;
goto err;
}
- if (evbuffer_add(bufev->input, buf, len) == -1) {
+ evbuffer_unfreeze(bufev->input, 0);
+ res = evbuffer_add(bufev->input, buf, len);
+ evbuffer_freeze(bufev->input, 0);
+ if (res == -1) {
what |= EVBUFFER_ERROR;
goto err;
}
blob - b557a96f53d24ed8af96b580b6cd797fea965893
blob + 7c4ee68d7d4edd32bfa32690932f387072b825f8
--- telescope.h
+++ telescope.h
#include "compat.h"
#include "phos/phos.h"
-#include <event.h>
#include <limits.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))