35 #ifndef MHD_FILE_READ_BLOCK_SIZE
37 #define MHD_FILE_READ_BLOCK_SIZE 16384
39 #define MHD_FILE_READ_BLOCK_SIZE 4096
60 #if ! defined(_WIN32) || defined(__CYGWIN__)
63 const HANDLE fh = (HANDLE) _get_osfhandle (response->
fd);
65 const int64_t offset64 = (int64_t) (pos + response->
fd_off);
70 #if ! defined(_WIN32) || defined(__CYGWIN__)
74 #if defined(HAVE_PREAD64)
75 n = pread64 (response->
fd,
79 #elif defined(HAVE_PREAD)
80 if ( (
sizeof(off_t) <
sizeof (uint64_t)) &&
84 n = pread (response->
fd,
89 #if defined(HAVE_LSEEK64)
90 if (lseek64 (response->
fd,
92 SEEK_SET) != offset64)
95 if ( (
sizeof(off_t) <
sizeof (uint64_t)) &&
99 if (lseek (response->
fd,
101 SEEK_SET) != (off_t) offset64)
104 n = read (response->
fd,
115 if (INVALID_HANDLE_VALUE == fh)
119 OVERLAPPED f_ol = {0, 0, {{0, 0}}, 0};
120 ULARGE_INTEGER pos_uli;
124 pos_uli.QuadPart = (uint64_t) offset64;
125 f_ol.Offset = pos_uli.LowPart;
126 f_ol.OffsetHigh = pos_uli.HighPart;
135 return (ssize_t) resRead;
152 (void) close (response->
fd);
184 #if ! defined(HAVE___LSEEKI64) && ! defined(HAVE_LSEEK64)
185 if ( (
sizeof (uint64_t) >
sizeof (off_t)) &&
191 if ( ((int64_t) size < 0) ||
193 ((int64_t) (size +
offset) < 0) )
202 if (
NULL == response)
struct MHD_Response * MHD_response_from_fd(enum MHD_HTTP_StatusCode sc, int fd, uint64_t offset, uint64_t size)
struct MHD_Response * MHD_response_from_callback(enum MHD_HTTP_StatusCode sc, uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
internal shared structures
#define MHD_CONTENT_READER_END_OF_STREAM
#define MHD_CONTENT_READER_END_WITH_ERROR
static void free_callback(void *cls)
#define MHD_FILE_READ_BLOCK_SIZE
static ssize_t file_reader(void *cls, uint64_t pos, char *buf, size_t max)