summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-06-23 15:00:17 +0300
committerMartin Storsjö <martin@martin.st>2012-06-26 17:22:21 +0300
commit4b1b1449d95b3567d055fc410a1db137c811229c (patch)
tree60013e54de195e77cde267435ddf02716d351ced
parente64bceeac0cdf312d9481b3dd1ec1fda7ee2b94c (diff)
network: Don't redefine error codes if they already exist in errno.h
Since the errno.h values don't match the error codes that winsock returns, map the winsock error codes to the errno ones, to make sure explicit checks against AVERROR(x) match. Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/network.c8
-rw-r--r--libavformat/network.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/network.c b/libavformat/network.c
index 432084faa4..c2f7a9b0de 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -164,6 +164,14 @@ int ff_neterrno(void)
return AVERROR(EAGAIN);
case WSAEINTR:
return AVERROR(EINTR);
+ case WSAEPROTONOSUPPORT:
+ return AVERROR(EPROTONOSUPPORT);
+ case WSAETIMEDOUT:
+ return AVERROR(ETIMEDOUT);
+ case WSAECONNREFUSED:
+ return AVERROR(ECONNREFUSED);
+ case WSAEINPROGRESS:
+ return AVERROR(EINPROGRESS);
}
return -err;
}
diff --git a/libavformat/network.h b/libavformat/network.h
index 3e4422e4c2..793cfee9a9 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -35,10 +35,19 @@
#include <winsock2.h>
#include <ws2tcpip.h>
+#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#endif
+#ifndef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
+#endif
+#ifndef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
+#endif
+#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
+#endif
+
#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)