From: Fredrik Tolf Date: Thu, 27 Feb 2014 08:45:27 +0000 (+0100) Subject: lib: Modularized mtio implementation. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=945d02f51b66c1ca7b8ae959cd06b4f9ebbd0954;p=ashd.git lib: Modularized mtio implementation. --- diff --git a/configure.in b/configure.in index 438097f..1242e84 100644 --- a/configure.in +++ b/configure.in @@ -2,6 +2,7 @@ AC_INIT([ashd], [0.13]) AC_CONFIG_SRCDIR(src/htparser.c) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) +AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC AM_PROG_CC_C_O @@ -20,6 +21,18 @@ if test "$HAS_MAGIC" = no; then AC_MSG_ERROR([*** cannot find libmagic on this system]) fi +AH_TEMPLATE(HAVE_GLIBC_STDIO, [define to indicate system support for glibc cookie streams]) + +HAS_FOPENCOOKIE=yes +AC_CHECK_FUNC(fopencookie, [], [HAS_FOPENCOOKIE=no]) +AC_CHECK_MEMBER([cookie_io_functions_t.read], [], [HAS_FOPENCOOKIE=no]) + +if test "$HAS_FOPENCOOKIE" = yes; then + AC_DEFINE(HAVE_GLIBC_STDIO) +else + AC_MSG_ERROR([*** libc support for custom stdio streams is required]) +fi + AH_TEMPLATE(HAVE_VALGRIND, [define to include debugging support for Valgrind]) AC_CHECK_HEADER(valgrind/memcheck.h, [AC_DEFINE(HAVE_VALGRIND)], []) diff --git a/lib/Makefile.am b/lib/Makefile.am index d48cfb6..8116805 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,7 +2,6 @@ lib_LIBRARIES = libht.a libht_a_SOURCES = utils.c mt.c log.c req.c proc.c mtio.c resp.c cf.c libht_a_CFLAGS = -fPIC -libht_a_CPPFLAGS = -D_GNU_SOURCE if USE_EPOLL libht_a_SOURCES += mtio-epoll.c else diff --git a/lib/mtio.c b/lib/mtio.c index 3b728d0..b994cc2 100644 --- a/lib/mtio.c +++ b/lib/mtio.c @@ -16,6 +16,9 @@ along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include @@ -24,9 +27,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif #include #include #include @@ -107,6 +107,7 @@ static int mtclose(void *cookie) return(0); } +#ifdef HAVE_GLIBC_STDIO static cookie_io_functions_t iofuns = { .read = mtread, .write = mtwrite, @@ -129,3 +130,6 @@ FILE *mtstdopen(int fd, int issock, int timeout, char *mode) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); return(ret); } +#else +#error "No stdio implementation for this system" +#endif