summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorTye McQueen <tye@metronet.com>1998-01-03 18:30:57 -0600
committerGurusamy Sarathy <gsar@cpan.org>1998-01-04 17:55:19 +0000
commit22fae026e9f4859841088a1c5609be12b0b1d4f3 (patch)
tree886f66b343fc6b88a3dfb291906a4993faa9db03 /win32/win32.c
parent2d7a92375815264badaef23c612657cbd4799f31 (diff)
downloadperl-22fae026e9f4859841088a1c5609be12b0b1d4f3.tar.gz
[win32] Add a tweaked version of:
Message-Id: <199801040630.AA29298@metronet.com> Subject: New patch for $^E==GetLastError() under Win32 p4raw-id: //depot/win32/perl@392
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index b965629383..cd67fff2bf 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1068,6 +1068,33 @@ win32_strerror(int e)
return strerror(e);
}
+DllExport void
+win32_str_os_error(SV *sv, unsigned long dwErr)
+{
+ DWORD dwLen;
+ char *sMsg;
+ dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
+ |FORMAT_MESSAGE_IGNORE_INSERTS
+ |FORMAT_MESSAGE_FROM_SYSTEM, NULL,
+ dwErr, 0, (char *)&sMsg, 1, NULL);
+ if (0 < dwLen) {
+ while (0 < dwLen && isspace(sMsg[--dwLen]))
+ ;
+ if ('.' != sMsg[dwLen])
+ dwLen++;
+ sMsg[dwLen]= '\0';
+ }
+ if (0 == dwLen) {
+ sMsg = LocalAlloc(0, 64/**sizeof(TCHAR)*/);
+ dwLen = sprintf(sMsg,
+ "Unknown error #0x%lX (lookup 0x%lX)",
+ dwErr, GetLastError());
+ }
+ sv_setpvn(sv, sMsg, dwLen);
+ LocalFree(sMsg);
+}
+
+
DllExport int
win32_fprintf(FILE *fp, const char *format, ...)
{