Merge pull request #300 from elvisfox/master
[fw/stlink] / mingw / mingw.h
index 93b3702d2aa51870009e8541edc7c59de052a62f..1fcf93da20ff8183a603a9e137eda2abab667a24 100644 (file)
@@ -2,7 +2,8 @@
 
 #include <io.h>
 
-#include <winsock.h>
+#define _USE_W32_SOCKETS 1
+#include <windows.h>
 
 #define ENOTCONN        WSAENOTCONN
 #define EWOULDBLOCK     WSAEWOULDBLOCK
@@ -38,10 +39,12 @@ struct pollfd {
  * outside of this file "shouldn't" have to worry about winsock specific error
  * handling.
  */
-#define socket(x, y, z)      win32_socket(x, y, z)
-#define connect(x, y, z)     win32_connect(x, y, z)
-#define accept(x, y, z)      win32_accept(x, y, z)
-#define shutdown(x, y)       win32_shutdown(x, y)
+#define socket(x, y, z)                win32_socket(x, y, z)
+#define connect(x, y, z)       win32_connect(x, y, z)
+#define accept(x, y, z)                win32_accept(x, y, z)
+#define shutdown(x, y)         win32_shutdown(x, y)
+#define read(x, y, z)                  win32_read_socket(x, y, z)
+#define write(x, y, z)                 win32_write_socket(x, y, z)
 
 /* Winsock uses int instead of the usual socklen_t */
 typedef int socklen_t;
@@ -51,6 +54,7 @@ SOCKET  win32_socket(int, int, int);
 int     win32_connect(SOCKET, struct sockaddr*, socklen_t);
 SOCKET  win32_accept(SOCKET, struct sockaddr*, socklen_t *);
 int     win32_shutdown(SOCKET, int);
+int    win32_close_socket(SOCKET fd);
 
 #define strtok_r(x, y, z)      win32_strtok_r(x, y, z)
 #define strsep(x,y) win32_strsep(x,y)
@@ -58,4 +62,8 @@ int     win32_shutdown(SOCKET, int);
 char *win32_strtok_r(char *s, const char *delim, char **lasts);
 char *win32_strsep(char **stringp, const char *delim);
 
+ssize_t win32_read_socket(SOCKET fd, void *buf, int n);
+ssize_t win32_write_socket(SOCKET fd, void *buf, int n);
+
+
 #endif