]> git.meshlink.io Git - catta/blobdiff - src/compat/windows/wincompat.c
add wsa error code to errnostrsocket for easier error lookup
[catta] / src / compat / windows / wincompat.c
index b60eb8f66ccd2f5e4574f2ca53edf60729ef0573..63f3e7de1469a6cc71a348c796aee6b7655763be 100644 (file)
@@ -1,8 +1,9 @@
-#include "catta/compat/wincompat.h"
+#include "wincompat.h"
 #include <errno.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <stdint.h>
+#include <stdio.h>
 
 #include <catta/log.h>
 
@@ -50,8 +51,10 @@ char *errnostrsocket(void)
 {
     static char buf[256];
 
+    int err = WSAGetLastError();
+    int len = snprintf(buf, sizeof(buf), "[%i] ", err);
     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
-                  NULL, WSAGetLastError(), 0, buf, sizeof(buf), NULL);
+                  NULL, err, 0, buf + len, sizeof(buf) - len, NULL);
 
     return buf;
 }