diff options
author | Marc Hoersken <info@marc-hoersken.de> | 2014-02-16 11:03:22 +0100 |
---|---|---|
committer | Marc Hoersken <info@marc-hoersken.de> | 2014-02-16 11:03:22 +0100 |
commit | 6239146e931fd3127f6994975a56d1b4884a708a (patch) | |
tree | 790e273e5e429e8b7fc15a753414f2f3082ece86 | |
parent | dc0f8c04ec4cddcc80cc76839da7f53c08815d9c (diff) |
warnless: add wrapper function for read and write on Windows
-rw-r--r-- | lib/warnless.c | 14 | ||||
-rw-r--r-- | lib/warnless.h | 15 | ||||
-rw-r--r-- | src/Makefile.inc | 3 |
3 files changed, 31 insertions, 1 deletions
diff --git a/lib/warnless.c b/lib/warnless.c index 7a4b01eb6..c14d05f09 100644 --- a/lib/warnless.c +++ b/lib/warnless.c @@ -400,6 +400,20 @@ curl_socket_t curlx_sitosk(int i) #endif /* USE_WINSOCK */ +#if defined(WIN32) || defined(_WIN32) + +ssize_t curlx_read(int fd, void *buf, size_t count) +{ + return (ssize_t)read(fd, buf, curlx_uztoui(count)); +} + +ssize_t curlx_write(int fd, const void *buf, size_t count) +{ + return (ssize_t)write(fd, buf, curlx_uztoui(count)); +} + +#endif /* WIN32 || _WIN32 */ + #if defined(__INTEL_COMPILER) && defined(__unix__) int curlx_FD_ISSET(int fd, fd_set *fdset) diff --git a/lib/warnless.h b/lib/warnless.h index f22f0bae4..93195f6fe 100644 --- a/lib/warnless.h +++ b/lib/warnless.h @@ -60,6 +60,21 @@ curl_socket_t curlx_sitosk(int i); #endif /* USE_WINSOCK */ +#if defined(WIN32) || defined(_WIN32) + +ssize_t curlx_read(int fd, void *buf, size_t count); + +ssize_t curlx_write(int fd, const void *buf, size_t count); + +#ifndef BUILDING_WARNLESS_C +# undef read +# define read(fd, buf, count) curlx_read(fd, buf, count) +# undef write +# define write(fd, buf, count) curlx_write(fd, buf, count) +#endif + +#endif /* WIN32 || _WIN32 */ + #if defined(__INTEL_COMPILER) && defined(__unix__) int curlx_FD_ISSET(int fd, fd_set *fdset); diff --git a/src/Makefile.inc b/src/Makefile.inc index cd890accc..f6062e7c4 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -13,7 +13,8 @@ CURLX_ONES = \ ../lib/strtoofft.c \ ../lib/strdup.c \ ../lib/rawstr.c \ - ../lib/nonblock.c + ../lib/nonblock.c \ + ../lib/warnless.c CURL_CFILES = \ tool_binmode.c \ |