From 67859a6401f2b7e4daf11067aa188c4f6f669432 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Tue, 9 Jun 2015 19:34:07 +0000 Subject: response.c: file_reader(): add support for W32 64-bit seek --- configure.ac | 1 + src/microhttpd/response.c | 5 +++++ w32/VS2013/MHD_config.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/configure.ac b/configure.ac index 3f7fb8f6..1e1187ad 100644 --- a/configure.ac +++ b/configure.ac @@ -608,6 +608,7 @@ AM_CONDITIONAL(HAVE_SPDYLAY, [test "x$have_spdylay" = "xyes"]) # large file support (> 4 GB) AC_SYS_LARGEFILE AC_FUNC_FSEEKO +AC_CHECK_FUNCS([_lseeki64]) # optional: have error messages ? AC_MSG_CHECKING(whether to generate error messages) diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 4a6382f8..32e679f4 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c @@ -329,11 +329,16 @@ file_reader (void *cls, uint64_t pos, char *buf, size_t max) if (offset64 < 0) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ +#if defined(HAVE___LSEEKI64) + if (_lseeki64 (response->fd, offset64, SEEK_SET) != offset64) + return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ +#else /* !HAVE___LSEEKI64 */ if (sizeof(off_t) < sizeof(uint64_t) && offset64 > (uint64_t)INT32_MAX) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ if (lseek (response->fd, (off_t)offset64, SEEK_SET) != (off_t)offset64) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ +#endif n = read (response->fd, buf, max); if (0 == n) diff --git a/w32/VS2013/MHD_config.h b/w32/VS2013/MHD_config.h index 07f1fbbb..645389b2 100644 --- a/w32/VS2013/MHD_config.h +++ b/w32/VS2013/MHD_config.h @@ -70,6 +70,9 @@ don't. */ #define HAVE_DECL_TCP_NOPUSH 0 +/* Define to 1 if you have the `_lseeki64' function. */ +#define HAVE___LSEEKI64 1 + /* *** Headers information *** */ /* Not really important as not used by code currently */ -- cgit v1.2.3