diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:57:42 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:57:42 +0100 |
commit | 47236ea4c1d5601fc6bea1b280d36152ec5ff32b (patch) | |
tree | 89c109c0bef460fa747a3413610034002fac1cb4 /src/stream.c | |
parent | dae92c799e85ec3b65f46da6a776e4386bc99d6c (diff) | |
download | lighttpd-47236ea4c1d5601fc6bea1b280d36152ec5ff32b.tar.gz |
Imported Upstream version 1.4.32
Diffstat (limited to 'src/stream.c')
-rw-r--r-- | src/stream.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/stream.c b/src/stream.c index ecaadc1..c29a5ca 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1,14 +1,11 @@ +#include "stream.h" + #include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> -#include "stream.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "sys-mmap.h" #ifndef O_BINARY @@ -25,33 +22,33 @@ int stream_open(stream *f, buffer *fn) { #endif f->start = NULL; - + if (-1 == stat(fn->ptr, &st)) { return -1; } - + f->size = st.st_size; #ifdef HAVE_MMAP if (-1 == (fd = open(fn->ptr, O_RDONLY | O_BINARY))) { return -1; } - - f->start = mmap(0, f->size, PROT_READ, MAP_SHARED, fd, 0); - + + f->start = mmap(NULL, f->size, PROT_READ, MAP_SHARED, fd, 0); + close(fd); - + if (MAP_FAILED == f->start) { return -1; } #elif defined __WIN32 - fh = CreateFile(fn->ptr, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_READONLY, + fh = CreateFile(fn->ptr, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_READONLY, NULL); if (!fh) return -1; @@ -64,19 +61,20 @@ int stream_open(stream *f, buffer *fn) { NULL); if (!mh) { +/* LPVOID lpMsgBuf; FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); - +*/ return -1; } - + p = MapViewOfFile(mh, FILE_MAP_READ, 0, @@ -87,9 +85,9 @@ int stream_open(stream *f, buffer *fn) { f->start = p; #else -# error no mmap found +# error no mmap found #endif - + return 0; } |