commit - b16313508c7b4527c1422490c852781eadd59db8
commit + af9b96a013ee85729431044a30b2b8944c844670
blob - 2a597fe2fa46d79a76c546f5a2a62cfb13b48081
blob + eb4ddeb427f608fe75f1dfd2522a8ce16cd4eb52
--- compat.h
+++ compat.h
#define ATTR_DEAD __attribute__((noreturn))
+#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 - 24e46208501b85221f5311120defe4c6c003ae98
blob + 36e3015aa62479385c3db94cfae227eee4695fae
--- configure.ac
+++ configure.ac
AC_INIT([kamid], [0.1], [kamid@omarpolo.com], [kamid], [gemini://kamid.omarpolo.com])
AC_CONFIG_LIBOBJ_DIR(compat)
+AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_YACC
+PKG_PROG_PKG_CONFIG
+
# Some functions can be in libbsd. Thanks to lldpb for the inspiration :)
AC_ARG_WITH([libbsd],
AS_HELP_STRING([--with-libbsd], [Use libbsd @<:@default=auto@:>@]),
AC_MSG_ERROR([requires libtls])
])
-AC_CHECK_LIB(event, event_init, [], [
- AC_MSG_ERROR([requires libevent])
-])
+AS_CASE([$host_os],
+ [*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])])])
AC_CHECK_LIB(util, imsg_init, [], [
AC_LIBOBJ(imsg)
blob - f3879b8a29c0d8518efde405bc6ee9a8b9cfd726
blob + e48f3c87ed66bcaea9e5a4baad4d6d9575f425dc
--- kamid.h
+++ kamid.h
#include "compat.h"
-#include <event.h>
#include <limits.h>
#include <stdint.h>
#include <tls.h>
blob - 8cb7468d5dd547a2c6ed4125341f38cc40f479b4
blob + e5357e9f01878461221fc4ec50a79c7fc00f7d2a
--- kamirepl.c
+++ kamirepl.c
#include <assert.h>
#include <endian.h>
#include <errno.h>
-#include <event.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
blob - 6cef1a88ffb45a708d00e8e170743aa19eff55f0
blob + 448a30005ad02587f71182494b6051d60a744763
--- listener.c
+++ listener.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;
}