projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6f30995
)
Better error messages under Windows.
author
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 8 Aug 2003 19:39:41 +0000
(19:39 +0000)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 8 Aug 2003 19:39:41 +0000
(19:39 +0000)
lib/utils.c
patch
|
blob
|
history
lib/utils.h
patch
|
blob
|
history
diff --git
a/lib/utils.c
b/lib/utils.c
index
43abf96
..
2e40ef5
100644
(file)
--- a/
lib/utils.c
+++ b/
lib/utils.c
@@
-86,13
+86,16
@@
void cp_trace()
#endif
char *winerror(int err) {
#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 (!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
return buf;
}
#endif
diff --git
a/lib/utils.h
b/lib/utils.h
index
d8dc476
..
af65427
100644
(file)
--- 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);
#ifdef HAVE_MINGW
extern char *winerror(int);
+#define strerror(x) (x>0?strerror(x):winerror(GetLastError()))
#endif
#endif /* __TINC_UTILS_H__ */
#endif
#endif /* __TINC_UTILS_H__ */