commit 67859a6401f2b7e4daf11067aa188c4f6f669432
parent 09088de0dbfb52843d4a960041b1f560b4c0e1b1
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 9 Jun 2015 19:34:07 +0000
response.c: file_reader(): add support for W32 64-bit seek
Diffstat:
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git 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
@@ -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
@@ -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 */