From: Guus Sliepen Date: Fri, 8 Aug 2003 19:39:41 +0000 (+0000) Subject: Better error messages under Windows. X-Git-Tag: release-1.0.1~14 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=b0825f36b7b5dade1693fdbddfec7eef3f5ed86f;p=tinc Better error messages under Windows. --- diff --git a/lib/utils.c b/lib/utils.c index 43abf96e..2e40ef58 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -86,13 +86,16 @@ void cp_trace() #endif char *winerror(int err) { - static char buf[1024]; + static char buf[1024], *newline; 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)); }; + if((newline = strchr(buf, '\r'))) + *newline = '\0'; + return buf; } #endif diff --git a/lib/utils.h b/lib/utils.h index d8dc4768..af654274 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -40,6 +40,7 @@ extern void bin2hex(char *src, char *dst, int length); #ifdef HAVE_MINGW extern char *winerror(int); +#define strerror(x) (x>0?strerror(x):winerror(GetLastError())) #endif #endif /* __TINC_UTILS_H__ */