Cygwin needs windows.h.
[tinc] / lib / utils.c
index 9ffad70..43abf96 100644 (file)
@@ -79,3 +79,21 @@ void cp_trace()
                );
 }
 #endif
+
+#if defined(HAVE_MINGW) || defined(HAVE_CYGWIN)
+#ifdef HAVE_CYGWIN
+#include <w32api/windows.h>
+#endif
+
+char *winerror(int err) {
+       static char buf[1024];
+
+       if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+               NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), NULL)) {
+               strncpy(buf, _("(unable to format errormessage)"), sizeof(buf));
+       };
+
+       return buf;
+}
+#endif
+